Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting the error "tf.fromPixels is not a function"?

I have some basic tensorflow.js code from an example on the documentation:

const image = new ImageData(1, 1);
image.data[0] = 100;
image.data[1] = 150;
image.data[2] = 200;
image.data[3] = 255;
const xs = tf.fromPixels(image);
xs.print();
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>

With this version (the one the website tells you to use):

https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js

And getting the error: Uncaught TypeError: tf.fromPixels is not a function what might cause this? Are others getting this error when you run the snippet?

like image 461
J.Todd Avatar asked Mar 28 '19 16:03

J.Todd


1 Answers

You are looking at the documentation for version 0.12.0.

tf.fromPixels was deprecated in version 1.0.0, use: tf.browser.fromPixels()

like image 70
BMcFadyen Avatar answered Oct 11 '22 13:10

BMcFadyen