Converting png to Tensor tensorflow.js
tensorflowjs already has a method for this: tf.fromPixels(), tf.browser.fromPixels()
.
You just need to load the image into on of the accepted types(ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement
).
Your image loading Promise returns nothing because your async function doesn't return anything, just your callback, to fix this you need to create and resolve a promise yourself:
const imageGet = require('get-image-data');async fucntion loadLocalImage(filename) { return new Promise((res, rej) => { imageGet(filename, (err, info) => { if (err) { rej(err); return; } const image = tf.fromPixels(info.data) console.log(image, '127'); res(image); }); });}