{ const a = tf.browser.fromPixels(im); console.log(a.shape); } Error: " /> { const a = tf.browser.fromPixels(im); console.log(a.shape); } Error: " /> { const a = tf.browser.fromPixels(im); console.log(a.shape); } Error: "/>

How can I convert an image to a tensor?

36 views Asked by At

Here's my code:

const im = new Image();
im.src = "image.jpg";
im.onload = () => {
    const a = tf.browser.fromPixels(im);
    console.log(a.shape);
}

Error: pixels passed to tf.browser.fromPixels() can not be null

I tried doing what seemed to work for others, but for some reason I keep getting errors in the console.

Edit:

Error messages in console are:

[Error] TypeError: undefined is not an object (evaluating 'e.length')
[Error] Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
[Error] SecurityError: The operation is insecure.

0

There are 0 answers