mocleiri / tensorflow-micropython-examples

A custom micropython firmware integrating tensorflow lite for microcontrollers and ulab to implement the tensorflow micro examples.
MIT License
170 stars 79 forks source link

MemoryError: memory allocation failed, allocating 300568 bytes #113

Open abhinavrawat27 opened 1 year ago

abhinavrawat27 commented 1 year ago

Hi I have ESP-Eye board. I have downloaded the firmware.bin file from https://github.com/mocleiri/tensorflow-micropython-examples/actions/runs/4399527522

I have connected ESP Eye board to my system. Using Thonny IDE I have uploaded the firmware.bin file on the board. I have also uploaded the no_person_image_data.dat person_detect_model.tflite person_detection.py person_image_data.dat . When running person detection, I am getting below error:

Traceback (most recent call last):
  File "<stdin>", line 30, in <module>
MemoryError: memory allocation failed, allocating 300568 bytes

I am new to this board and unable to find a proper documentation of running the person detection on ESP32. Can anyone please help me here. Thanks

mocleiri commented 1 year ago

@abhinavrawat27 did you flash the spiram version? the person detection model is ~300KB which doesn't fit in the normal esp32 which has 100k effective ram. But does fit fine in the 4MB SPI ram versions of the board.

I think the latest micropython is actually splitting the spi ram into two chunks (one for the Micropython Heap and the other for C memory allocation) but still 300 KB will fit fine into 2MB.

Also the build you flashed was from an experimental branch. Try the firmware from here is which is the latest build of the main branch: https://github.com/mocleiri/tensorflow-micropython-examples/actions/runs/4791546929