Arduino Deployment with Nicla Vision - Initial Success Followed by “Failed to run classifier”

Question/Issue:
I have created a FOMO image classification model and exported it as an Arduino Library. I am following this tutorial. I have successfully compiled and uploaded the model to the board. Better still, I can see from the serial output from one of the examples (“nicla_vision_camera”) that the model can successfully classify the object I’m looking for, which is a box shape. That shows me things are very close to working properly!

The issue is that following this first classification, I get a stream of errors:

ERR: failed to allocate tensor arena
Failed to initialize the model (error code 1)
ERR: Failed to run classified (-6)

Project ID:
672920

Context/Use case:

I am getting the same errors whether I run the “static_buffer” example, or, the “nicla_vision_camera” example. Both throw the same errors above. However, the “nicla_vision_camera” example does run properly at least once before throwing those errors after detecting an object.

Upon pressing the board’s reset button (or setting fin 5 on the board to low), the classification model successfully runs again, but encounters the same issue upon detecting an object. Perhaps something needs to be included in the code to reset the board? Or, perhaps there is an issue with the memory allocation?

Steps Taken:

  1. Export arduino library and run per tutorial steps.
  2. Open Examples >> Examples from custom library >> Compile and run the “nicla_vision_camera.ino” or “static_buffer”. Note: I’ve made no edits to these other than to paste in the features to the static buffer example per instructions.
  3. See above photo… errors only for the static buffer example, but initial success followed by errors for the “nicla_vision_camera.ino” example.

Expected Outcome:
After successfully ID the object, I’d expect the serial output to return to it default state, again trying to run the model and find an object.

The only work around I currently have available is to trigger the reset pin, which seems clunky.

Actual Outcome:
Repeated errors as above

Reproducibility:

  • [ X] Always
  • [ ] Sometimes
  • [ ] Rarely

Environment:

  • Platform: Arduino Nicla Vision
  • Build Environment Details: [Arduino IDE 2.3.4
  • OS Version: Windows 11
  • Edge Impulse Version (Firmware): In powershell typing edge-impulse-daemon --version gives “Edge impulse runner v1.30.6”
  • Edge Impulse CLI Version: How do I determine this? How is it different from above?
  • Project Version: 1.0.0 initial commit
  • Custom Blocks / Impulse Configuration: No custom blocks
  • Logs/Attachments: See attached screenshot
  • Additional Information: None

Still hoping for a response, but in the absence of one I’m going to head down the route of working with what I have, and triggering a reset of the board once a detection is made. Fingers crossed that someone will be able to provide a more practical path to troubleshoot and resolve this.

Hi @BrianMacG - the first thing I would check is the amount of RAM that your model requires, it may be more than is available.

Are you exporting the float32 or int8 version of your model? If you have been using the float32 version, please try the int8 version.

In the meantime, I will also check with our embedded team.

@BrianMacG try defining EI_CLASSIFIER_ALLOCATION_STATIC 1
for your entire project. This will allocate the tensor at compile time rather than runtime via heap. If you’re right on the bubble RAM wise, you might be getting bit by heap fragmentation. It won’t make a difference to final footprint unless you’re malloc/free something large in between running inference.

Ok, awesome. I will try this. Thank you!

I should say that Ive been attracted to exploring this in part by the notion that those with little coding experience can interact with your platform and have functional results… unfortunately that describes me… Im not yet well versed in memory allocation (malloc, free etc). I think I’m on the cusp of success, but, could I ask for a few more specific instructions on how exactly i should go about defining that?

Do you mean including a specific line of code in the sketch, and if so what exaclty? E.g. “#define EI_CLASSIFIER_ALLOCATION_STATIC 1;” at the start of my sketch? Are other changes to ither files required?