Compile failure when deploying model to Portenta H7

Hello,

I have a descent model that recognizes images, socks and chair legs. I’m happy enough with the accuracy that I wanted to try running it on my Portenta H7 with Vision Shield to start incorporating it into our larger project.

I went to Deployment on the Edge Impulse site and I chose the Arduino Library option. I got the zip library into the Arduino IDE and I opened the auto-generated example, “portent_h7_camera”. However, when I try to upload the code to the Portenta I get the following compile error:

Arduino: 1.8.16 (Mac OS X), Board: "Arduino Portenta H7 (M7 core), 1.5MB M7 + 0.5MB M4"

In file included from /Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/Socker_inferencing.h:55:0,
                 from /Users/iang/Documents/Arduino/libraries/Socker_inferencing/examples/portenta_h7_camera/portenta_h7_camera.ino:24:
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h: In function 'EI_IMPULSE_ERROR {anonymous}::inference_tflite_run(uint64_t, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*, uint8_t*, ei_impulse_result_t*, bool)':
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h:591:44: error: 'post_process_boxes' is not a member of 'tflite'
     fill_result_struct_f32(result, tflite::post_process_boxes, tflite::post_process_scores, tflite::post_process_classes, debug);
                                            ^~~~~~~~~~~~~~~~~~
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h:591:72: error: 'post_process_scores' is not a member of 'tflite'
     fill_result_struct_f32(result, tflite::post_process_boxes, tflite::post_process_scores, tflite::post_process_classes, debug);
                                                                        ^~~~~~~~~~~~~~~~~~~
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h:591:101: error: 'post_process_classes' is not a member of 'tflite'
     fill_result_struct_f32(result, tflite::post_process_boxes, tflite::post_process_scores, tflite::post_process_classes, debug);
                                                                                                     ^~~~~~~~~~~~~~~~~~~~
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h: In function 'EI_IMPULSE_ERROR {anonymous}::run_inference(ei::matrix_t*, ei_impulse_result_t*, bool)':
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/src/edge-impulse-sdk/classifier/ei_run_classifier.h:668:69: warning: division by zero [-Wdiv-by-zero]
                 input->data.uint8[ix] = static_cast<uint8_t>((pixel / EI_CLASSIFIER_TFLITE_INPUT_SCALE) + EI_CLASSIFIER_TFLITE_INPUT_ZEROPOINT);
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/examples/portenta_h7_camera/portenta_h7_camera.ino: In function 'void loop()':
portenta_h7_camera:191:44: error: 'struct ei_impulse_result_t' has no member named 'classification'
         ei_printf("    %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
                                            ^~~~~~~~~~~~~~
portenta_h7_camera:191:77: error: 'struct ei_impulse_result_t' has no member named 'classification'
         ei_printf("    %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
                                                                             ^~~~~~~~~~~~~~
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/examples/portenta_h7_camera/portenta_h7_camera.ino: In function 'int calculate_resize_dimensions(uint32_t, uint32_t, uint32_t*, uint32_t*, bool*)':
/Users/iang/Documents/Arduino/libraries/Socker_inferencing/examples/portenta_h7_camera/portenta_h7_camera.ino:398:56: warning: variable length array 'list' is used [-Wvla]
     const ei_device_resize_resolutions_t list[list_size] = {
                                                        ^
exit status 1
'struct ei_impulse_result_t' has no member named 'classification'


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And here is the line of code where the error is from IDE:

for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
        ei_printf("    %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
    }

Anyone have any ideas on how to fix this?

Hello @iangillespie,

Can you make sure you selected the Arduino Portenta H7 (M7 core) board and the Flash Split 2 MB M7 + M4 in SDRAM:

Also, please see here for more info: https://docs.edgeimpulse.com/docs/running-your-impulse-arduino

If it still does not work, can you share your project ID so I can have a deeper look at your model and try it on my side please?

Regards,

Louis

I just noticed that it was in the first line of the code you shared…

I just had a look at your project and you used an “Object Detection” project instead of an “Image Classification” project. Indeed this won’t fit on the Arduino Portenta , you’d need to have a linux board at the moment.

Note that we are currently working on a smaller version of the Object Detection that could run on microcontroller but it has not been released yet.

Regards,

Louis

Short answer: you’re missing the EI_CLASSIFIER_ENABLE_DETECTION_POSTPROCESS_OP macro (once you have it the symbols will appear).

Longer answer: this generates a model that’s too large for the Portenta, which is why we’ve disabled the macro. Would indeed be good to hide the Arduino library until we’ve released the new constrained object detection pipeline (around January 2022).

Thanks for the replies Jan and Louis. So I guess I’m out of luck until the constrained object detection pipeline is released, unless there is a way to store the model and data in the micro SD card that you can put in the Portenta?

Hello @iangillespie,

FYI, we just released FOMO, our object detection models for constrained devices: https://www.edgeimpulse.com/blog/announcing-fomo-faster-objects-more-objects

Regards,