I recently using tensorflow.js to learn image classification in the browser, now I just convert one picture to tensor, but I want to load lots of pictures, and its doesn't work, just one picture is converted to tensor, this is my code when just convert one picture:
const im = new Image()
im.src = "/folder_name/1.jpg";
im.onload = () => {
const a = tf.fromPixels(im, 4)
a.print()
console.log(a.shape)
}
and this is code when I trying to convert lots of images:
const im = new Image()
for(let i=1;i<= 15;i++){
im.src = "folder_name/"+i+".jpg";
im.onload[i] = () => {
const a = tf.browser.fromPixels(im, 4)
console.log(a.shape);
}
}
when I open the console, just one output, just like when I convert a single image