Guest User

Untitled

a guest
May 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. protected async predict(imageData: ImageData) {
  2.  
  3. const pred = await tf.tidy(() => {
  4.  
  5. let img:any = tf.fromPixels(imageData, 1);
  6. img = img.reshape([1, 28, 28, 1]);
  7. img = tf.cast(img, 'float32');
  8.  
  9. const output = this.model.predict(img) as any;
  10.  
  11. this.predictions = Array.from(output.dataSync());
  12. });
  13. }
Add Comment
Please, Sign In to add comment