Skip to content

Instantly share code, notes, and snippets.

@zaidalyafeai
Created July 2, 2018 08:43
Show Gist options
  • Save zaidalyafeai/2c2d7fc0d89fa3a9862cb6ab3b5bf627 to your computer and use it in GitHub Desktop.
Save zaidalyafeai/2c2d7fc0d89fa3a9862cb6ab3b5bf627 to your computer and use it in GitHub Desktop.
function getFrame()
{
const ctx = canvas.getContext("2d");
//get the minimum bounding box
const mbb = getMinBox()
imgData = ctx.getImageData(mbb.min.x, mbb.min.y, mbb.max.x - mbb.min.x, mbb.max.y - mbb.min.y);
//get the predictions, top 5
const pred = model.predict(preprocess(imgData)).dataSync()
//find the top predictiosn
const indices = findIndicesOfMax(pred, 5)
const probs = findTopValues(pred, 5)
const symbols = getSymbols(indices)
//set the table
setTable(symbols, probs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment