CLI and Python give different results on Raspberry Pi

When I run the command line edge-impulse-linux-runner the results are as I would expect and it correctly labels my objects, but the results from the stock classify.py example in the Python SDK are very different. It fails to register my objects and picks up on some more random shapes if the camera position is changed, items that the CLI runner doesn’t register. I have set the model to the same one as the CLI runner, in the .ei-linux-runner subfolder. The same result also appears to be true of the classify-image.py script. I’ve tried a new project with the same images to generate a new model (FOMO 2.01) and get the same result. I don’t believe the model is at fault, so assume the Python ImageImpulseRunner must be behaving differently to the CLI runner.

Project ID: 117730 or 121750

I’ve noted I’m not the first to have this issue but wasn’t able to glean anything to fix it from the year old post (Getting a different result from the Edge Impulse CLI and my local Python app - #3 by bsatrom). Sorry I tried to bump that previous post but after 5 days it looks like it failed to register, hence starting afresh.

The image appears to be fine (from Microsoft® LifeCam HD-3000) so not sure what is happening.

Hello @BombusT,

I can indeed reproduce your issue:


I’ll dig a bit deeper and if I cannot find an easy solution, I’ll defer your issue to our Core Engineering team.

Regards,

Louis

Hi @BombusT, it was an issue with color conversion. OpenCV reads images in BGR format, but we need pixels in RGB format, so we convert the color space. However… this happened twice (and thus we had BGR images again), once in the classify-image.py script and once in the runner library. I’ve pushed v1.0.7 of the Python library which resolves this.

debug

It’s a very common bug, my guess would be that 90% of “here’s how you run inference in Python w/ TFLite / ONNX / whatever” examples on the internet have the same problem :slight_smile:

Thank you very much gentlemen for the fast response and fix, I won’t be able to give it a whirl until early next week but I look forward to it!

1 Like