2026-02-04 6:31 AM - last edited on 2026-02-04 6:48 AM by Andrew Neil
Hi,
I've been trying to set up an experiment that deploys the MobileNet v2 model from the STM32AI Model Zoo (mobilenetv2_a035_128_fft_int8.tflite) to do some classification of images using my own test dataset; so that's a set of discrete images, not real-time camera data. I want to use a Python script on a PC to send each test image, one at a time, to the MCU via serial (USB C), have the model run inference, and then return the classification results to the PC. This will repeat in a loop so all images are processed and the Python script will then calculate final metrics, based on all the individual image classification results.
I already have some Python code and can send an image as a tensor to the MCU, but I am struggling to correctly return, or interpret, the classification results. I.e., using the model trained on the Flowers dataset, I expect a classification result consisting of 5 float values (one for each class in the dataset) to be returned. But the values I get back don't seem right. E.g., for a daisy image I get these probability results:
0: daisy 0.332031,
1: dandelion 0.332031,
4: tulips 0.332031,
2: roses 0.000000,
3: sunflowers 0.000000
I think my problem/task is similar to this post: https://community.st.com/t5/edge-ai/inferencing-image-files-from-pc-on-stm32n6570-dk-target/td-p/838807, but I am using the STM32H7 MCU on a NUCLEO-H753ZI board. I followed some of the links suggested in that thread (https://stedgeai-dc.st.com/assets/embedded-docs/stneuralart_getting_started.html, https://stedgeai-dc.st.com/assets/embedded-docs/stm32_on_target_validation.html) and have a few questions:
1. Can I use the built-in ST Edge AI validate command to do this work instead, so that it sends images from a test dataset one at a time and returns classification results to the PC from the model on the MCU?
2. Do the test dataset images need any preprocessing before being sent to the MCU for inference? I.e., it looks like I need to convert the images to a NumPy array format, is that right? What about scaling and normalising the images to make sure they match the properties of the images used to train the model in the first place?
3. If I do use the built-in validate command, do I get back a classification result per image, or just a confusion matrix of overall classification performance? If it is the second one, is there a way to get classification-result-per-image output back to the PC?
Any help would be greatly appreciated.