I have this model:
Which is a conv layer that's suppose to detect facial emotions,
I try to implement it on my TensorFlowJS, so I converted it and when I try to enter an input, it requires a 4d tensor with null as the first input,
but the tensor4d will not allow it:

The shape should be a number only, but when I try to add it to my model it asks for null, what do I do? This is the function I convert jpg to tensors:
const imageToTensor = (rawData: ArrayBuffer) => {
const { width, height, data } = jpeg.decode(rawData, true);
const buffer = new Uint8Array(width * height * 3);
let offset = 0;
for (let i = 0; i < buffer.length; i += 3) {
buffer[i] = data[offset]; //red
buffer[i + 1] = data[offset + 1]; //green
buffer[i + 2] = data[offset + 2]; //blue
offset += 4; //skips Alpha value
}
//instead of 1 I need null, but wont let me -----
return tf.tensor4d(buffer, [1, height, width, 3]);
};
EDIT: this is my prediction function :
const trypredict = async () => {
try {
let image = require("../assets/smile.jpg");
image = tf.browser
.fromPixels(image)
.mean(2)
.toFloat()
.expandDims(0)
.expandDims(-1);
const imageAssetPath = Image.resolveAssetSource(image);
const response = await fetch(imageAssetPath.uri, {}, { isBinary: true });
const imageData = await response.arrayBuffer();
let imageTensor = imageToTensor(imageData);
imageTensor = imageTensor.resizeBilinear([48, 48]);
if (model) {
const prediction = await model.predict(imageTensor);
}
} catch (error) {
console.log(error);
}
};
