Skip to content

Instantly share code, notes, and snippets.

@vabarbosa
Last active January 15, 2020 14:54
Show Gist options
  • Save vabarbosa/8bf676b8a16b3d9ef7716b064d3c1dd5 to your computer and use it in GitHub Desktop.
Save vabarbosa/8bf676b8a16b3d9ef7716b064d3c1dd5 to your computer and use it in GitHub Desktop.
load tfjs model and run prediction
// load a graph model from a URL
const model = await tf.loadGraphModel(MODEL_URL)
// create a tensor from an image
const inputTensor = tf.browser.fromPixels(imageNode)
// run prediction
const prediction = model.predict(inputTensor)
// process output/prediction
const output = Array.from(prediction.dataSync())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment