Skip to content Skip to sidebar Skip to footer

Given The Url, How To Load An Image And Then Transform It Into A Tf.tensor Data In Javascript?

I am new to frontend and javascript. Now I am writing a CNN-based web application. To load an image from the given url, and then feed the image into a CNN, I tried to write the fol

Solution 1:

The tensor has to be created once the image has completed to be loaded

async function getImage() {
  var img = new Image();
  img.src = 'https://www.google.com/favicon.ico';

  img.onload = () => {
  var output = tf.browser.fromPixels(img);
  return output;
  }

}

Post a Comment for "Given The Url, How To Load An Image And Then Transform It Into A Tf.tensor Data In Javascript?"