Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image preprocessing on Sense Craft AI #283

Open
yousefbilal opened this issue Feb 22, 2025 · 4 comments
Open

Image preprocessing on Sense Craft AI #283

yousefbilal opened this issue Feb 22, 2025 · 4 comments
Assignees
Labels
ModelAssistant Label for ModelAssistant UAY Unassigned yet

Comments

@yousefbilal
Copy link

I have trained a MobileNetV2 model on a custom dataset following the example configurations. Testing the quantized model on the dataset gives good results reaching above 90% in accuracy. However, when I deploy the model using Sense Craft AI on Grove Vision AI V2, I get a 99% probability on one of the classes all the time, except when I black out the camera it drops down to ~83%. I uploaded the same model tflite model to Edge Impulse and tested the model on few images of the dataset and it appeared to work correctly when the input was set to values 0..1 . Is it possible that the model is performing poorly on camera images because of a wrong preprocessing withing the Grove firmware?

@Lesords Lesords added UAY Unassigned yet ModelAssistant Label for ModelAssistant labels Feb 24, 2025
@iChizer0
Copy link
Contributor

Hi @yousefbilal at present, all the pre-processing on the firmware side is consistent, and if this is the case, other models may also appear abnormal, yet we didn't observe. If it's convenient, please send us the TFlite model and Vela model you are testing, and we will validate these models and try to solve your issue, thanks.

@yousefbilal
Copy link
Author

I think I have solved the issue for now, but can you let me know what preprocessing is happening on the firmware? Also, if possible, can you point me to the source code of the firmware that Sense Craft flashes into the device?

@iChizer0
Copy link
Contributor

@yousefbilal The source code repository for the firmware is located at https://github.com/Seeed-Studio/sscma-example-we2/tree/main/EPII_CM55M_APP_S/library, which name contains sscma as our component.

The current preprocessing is divided into two steps, first converting the image of yuv422 to rgb888, which includes an automatic resize operation (inter_nearest may introduce some errors for computational considerations), and then mapping rgb888 to a quantized space (for int8 symmetrically quantization we simply subtract 128), some of the code can be referenced here:
https://github.com/Seeed-Studio/SSCMA-Micro/blob/415035c943620de9d3380215af81a1300215b014/sscma/core/model/ma_model_classifier.cpp#L87 .

@yousefbilal
Copy link
Author

Thanks for the info. Are the vela models similarly built to match the quantized input?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ModelAssistant Label for ModelAssistant UAY Unassigned yet
Projects
Status: No status
Development

No branches or pull requests

4 participants