Skip to content

Instantly share code, notes, and snippets.

@SkalskiP
Created May 16, 2018 16:15
Show Gist options
  • Save SkalskiP/cc063ebf9f3ef26c02d524cb27d7804a to your computer and use it in GitHub Desktop.
Save SkalskiP/cc063ebf9f3ef26c02d524cb27d7804a to your computer and use it in GitHub Desktop.
making predictions based on image data
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