Different classification results in Studio vs on device?

Running into a very strange error with an image classification model. The classification result for the same image is completely different in Studio vs on the device. In this example, a thermal image is classified as “warm” in Studio (this is correct):

However on the device (in my case RPi Zero 2 using the Python SDK) the result w/ the same exact image is always “anomaly”:

Result (68 ms.) anomaly: 1.00 cold: 0.00 hot: 0.00 warm: 0.00

Here is the original image as saved on the Pi:

ir_1643831728

And here is the “debug” image as written with: cv2.imwrite('debug.jpg', cv2.cvtColor(cropped, cv2.COLOR_RGB2BGR)) (so I don’t think the problem is with the cropping/resizing):

debug

Any ideas? Project ID is 74354. Thanks!

Hi @roblauer,

Does this issue occur on only this one specific image? Or all of your images?

As a few troubleshooting steps, I would try printing out your processed image as hex values and compare those to the value you see in the studio on the DSP block page (prior to generating your features).

How are you passing your new image into your DSP function and then into the model with the Python SDK?

– Jenny

@jenny thanks for the suggestions!

I ran with this idea for a bit and I think I found the problem! Previously I was generating the image then converting it into a numpy array:

img = thermal.takePicture()
img = np.array(img)
features, cropped = runner.get_features_from_image(img)

…but when I switched to using cv2 to read the image, it all magically works!

filename = thermal.takePicture()
img = cv2.imread("images/" + filename)
features, cropped = runner.get_features_from_image(img)
2 Likes

Great! Glad you figured it out, and thank you for posting your solution!

– Jenny