Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 5, 2019 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/ab0f3f823d2eb49d671f9516a5a9b767 to your computer and use it in GitHub Desktop.
Save NMZivkovic/ab0f3f823d2eb49d671f9516a5a9b767 to your computer and use it in GitHub Desktop.
private getImage(canvasHtmlElement)
{
this.context.drawImage(canvasHtmlElement, 0, 0, 28, 28);
let imageData = this.context.getImageData(0, 0, 28, 28);
let img = tf.browser.fromPixels(imageData, 1);
let imgtmp = img.reshape([1, 28, 28, 1]);
imgtmp = tf.cast(imgtmp, 'float32');
return imgtmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment