Created
May 16, 2018 16:15
-
-
Save SkalskiP/cc063ebf9f3ef26c02d524cb27d7804a to your computer and use it in GitHub Desktop.
making predictions based on image data
This file contains 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.predictions = Array.from(output.dataSync()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment