Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 5, 2019 09:00
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/3cb7668ec520ca07ded18180e0ea6316 to your computer and use it in GitHub Desktop.
Save NMZivkovic/3cb7668ec520ca07ded18180e0ea6316 to your computer and use it in GitHub Desktop.
const pred = await tf.tidy(() => {
// Convert the canvas pixels to
let image = this.getImage(canvasHtmlElement)
// Make and format the predications
const output = this.model.predict(image) as any;
let predictions = Array.from(output.dataSync());
console.log(predictions);
// Write out the prediction.
for (let i = 0; i < predictions.length; i++) {
if (predictions[i] == "1") {
this.predicted = i.toString();
}
}
if (this.predicted == "") {
this.predicted = ":(";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment