Skip to content

Instantly share code, notes, and snippets.

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