** I'M AWARE OF SIMILAR QUESTIONS!! **
My question is for my particular situation... I used Google Vision to train my own model to detect custom objects. I've come across similar errors about shape in the past and I resolved them by reshaping my input image.
This particular error is telling me that my shape must be an empty array or empty shape. Is that even possible? If this is not a glitch, how do i resolve it?
This is how I resolved previous errors in other projects when it complains about shape. This solution does not work for empty array/shape
const model = await autoML.loadObjectDetection('./model/model.json');
// const model = await tfjs.loadGraphModel('./model/model.json');
await tfjs.ready();
const tfImg = tfjs.browser.fromPixels(videoElement.current).expandDims(0);
const smallImg = await tfjs.image.resizeBilinear(tfImg, [224, 224]);
const resized = tfjs.cast(smallImg, 'float32');
const t4d = tfjs.tensor4d(Array.from(resized.dataSync()), [1, 224, 224, 3]);
const predictions = await modelRef.current.detect(tfImg, options);
I had the same problem with my tfjs models from Vision AI when I exported them to tfjs models and followed this article to load the model.
Workaround:
As a workaround I exported the model from Vision AI to the SavedModel format and converted it to tfjs model with tensorflow_converter following this guide. The result can be loaded as expected and works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With