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
| protected async predict(imageData: ImageData) { | |
| const pred = await tf.tidy(() => { | |
| let img:any = tf.fromPixels(imageData, 1); | |
| img = img.reshape([1, 28, 28, 1]); | |
| img = tf.cast(img, 'float32'); | |
| const output = this.model.predict(img) as any; |
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
| import * as tf from '@tensorflow/tfjs'; | |
| // Definition of the component supporting the model | |
| // ... | |
| protected async loadModel() { | |
| this.model = await tf.loadModel(AppSettings.mnistModelUrl); | |
| } |
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
| $ tensorflowjs_converter --input_format keras ./ModelPY/model.h5 ./../ModelJS |
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
| import tensorflowjs as tfjs | |
| # creating and training of model using Keras | |
| # ... | |
| tfjs.converters.save_keras_model(model, './ModelJS') |
NewerOlder