OSError: Expected model output width to be 1!

Hey guys,

I was trying to load a .tflite model which takes an input image of 150 x 150 and outputs an array of [1, 540, 4]. But for some reason during inference of the image I am getting the error mentioned below

OSError: Expected model output width to be 1!

Is there a proprietary shape for the input and output?

For reference, I am using an OpenMV Cam H7 Plus.

Hi, our parser expects certain sizes: tensorflow-lib/libtf.cc at master · openmv/tensorflow-lib · GitHub

So… you’ve swapped the width with the height.

Hey,

I did not exactly get it when you say I swapped the width with the height.

Output needs to be [540, 1, 4].

The first value is the height of the output array.

I might be able to make this more forgiving. Right now it’s not though.

Got it thanks.

As you mentioned I made my model output as [1917, 1, 4] instead of [ 1, 4, 1917] but I still get the error.

Note : I changed the image size from 150x150 to 300x300 hence the change from 540 to 1917, so don’t mind that.

image

Read this code:

It will pass these model types.

Hey,

I have gone through the snippet that you specified and as far as I can see it only talks about the Output dimension [n] should be 1 error but unfortunately, the error that I am getting as I mentioned before is Expected model output height/weight to be 1!.

I have also done some trial and error testing from my side and found that none of the output dimension looks to be supported.

1917x1x4 : Expected model output height to be 1!

1917x4 : Output dimension [n] should be 1!  ( I understood why this is happening )

1917x4x1 : Expected model output height to be 1!

1x1917x4 : Expected model output width to be 1!

1x1x1917x4 : Expected model output width to be 1!

I am quite new to TF and TF Lite on Microcontrollers so if you could point me to any documentation that will help me would be useful. Thanks

Please see the line of code above that I linked to:

Then this parses the result:

So, put the output values in the channels dim. Not width/height.

E.g. the model output should be [h==1][w==1][c]

Hey sorry for the delayed response.

But yes (1,1,7664) works in my case. I would suggest it is a bit difficult to use this structure in the case of any detection type algorithms that return bounding boxes.

Yeah, we’re going to do a release really soon with an updated IDE and then I’ll be overhauling this with new features. I’ll try to make this more forgiving.

1 Like