Skip to content

Instantly share code, notes, and snippets.

@vabarbosa
Last active March 11, 2019 21:16
Show Gist options
  • Save vabarbosa/5a821e2242c4f67c215e7dd2d9e021d7 to your computer and use it in GitHub Desktop.
Save vabarbosa/5a821e2242c4f67c215e7dd2d9e021d7 to your computer and use it in GitHub Desktop.
// create a tensor from an image - tensorflow.js 1.0.0
// https://js.tensorflow.org/api/1.0.0/#browser.fromPixels
const imageTensor = tf.browser.fromPixels(imageElement)
// insert a dimension into the tensor's shape
const preprocessedInput = imageTensor.expandDims()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment