Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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