Skip to content

Instantly share code, notes, and snippets.

@vabarbosa
Last active March 11, 2019 21:12
Show Gist options
  • Save vabarbosa/e085304561ee05cdfe6a879e45c1c79d to your computer and use it in GitHub Desktop.
Save vabarbosa/e085304561ee05cdfe6a879e45c1c79d to your computer and use it in GitHub Desktop.
// create a tensor from an image - tensorflow.js 0.15.1
// https://js.tensorflow.org/api/0.15.1/#fromPixels
const imageTensor = tf.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