This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <style> | |
| body { | |
| display: flex; | |
| flex-direction: row; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| canvas { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <style> | |
| body { | |
| display: flex; | |
| flex-direction: row; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| canvas { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <style> | |
| body { | |
| display: flex; | |
| flex-direction: row; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| canvas { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app = Flask(__name__) | |
| graph = tf.get_default_graph() | |
| @app.route('/predict', methods=['POST', 'GET']) | |
| @cross_origin() | |
| def predict_(): | |
| ''' | |
| returns a flower prediction | |
| ''' | |
| global graph |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == "__main__": | |
| app.run("0.0.0.0", port=5000, debug=False, threaded=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = Sequential() | |
| model.add(GlobalAveragePooling2D(train_inception_v3.shape[1:])) | |
| model.add(Dense(133, activation='softmax')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bottleneck_features = np.load('inception_v3_file.npz') | |
| train_inception_v3 = bottleneck_features['train'] | |
| valid_inception_v3 = bottleneck_features['valid'] | |
| test_inception_v3 = bottleneck_features['test'] | |
| model = Sequential() | |
| model.add(Dense(input_shape=train_inception_v3.shape[1:]), units=16)) | |
| model.add(Conv2D(filters = 16, kernel_size=2, strides=1, padding ='valid', activation='relu')) | |
| model.add(MaxPooling2D(pool_size = (2), strides=(2), padding ='valid')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model.add(Dense(input_shape=[224, 224, 3], units=16)) | |
| model.add(Conv2D(filters = 16, kernel_size=2, strides=1, padding ='valid', activation='relu')) | |
| model.add(MaxPooling2D(pool_size = (2), strides=(2), padding ='valid')) | |
| model.add(Conv2D(filters = 32, kernel_size=2, strides=1, padding ='valid', activation='relu')) | |
| model.add(MaxPooling2D(pool_size = (2), strides=(2), padding ='valid')) | |
| model.add(Conv2D(filters = 64, kernel_size=2, strides=1, padding ='valid', activation='relu')) | |
| model.add(MaxPooling2D(pool_size = (2), strides=(2), padding ='same')) | |
| model.add(GlobalAveragePooling2D()) | |
| model.add(Dense(units=133, activation='softmax')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script> | |
| <script> | |
| const worker_function = () => { | |
| onmessage = () => { | |
| console.log('from web worker') | |
| this.window = this | |
| importScripts('https://cdn.jsdelivr.net/npm/[email protected]/setImmediate.min.js') | |
| importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function buildModel(featureExtractor, units) { | |
| return tf.sequential({ | |
| layers: [ | |
| // Flattens the input to a vector so we can use it in a dense layer. While | |
| // technically a layer, this only performs a reshape (and has no training | |
| // parameters). | |
| // slice so as not to take the batch size | |
| tf.layers.flatten( | |
| { inputShape: featureExtractor.outputs[0].shape.slice(1) }), | |
| // add all the layers of the model to train |
NewerOlder