espressif / esp-dl

Espressif deep-learning library for AIoT applications
MIT License
516 stars 115 forks source link

How to convert ONNX model to work with ESP-DL (AIV-550) #102

Closed skodippily closed 1 year ago

skodippily commented 1 year ago

Hello,

I'm very new to machine learning. I have a working object detection model for the onnx and I tried it on the PC. May I have some instructions on how to use this to detect objects from esp32-s3. I do the optimization successfully, but when I call the _checkmodel function it has a large list of operators which is not supported on esp-dl yet.

image

If someone can help me with this error much appreciate with it.

Thank you

Auroragan commented 1 year ago

Hi, can you provide your python script?

skodippily commented 1 year ago

I modified this https://github.com/espressif/esp-dl/blob/master/tools/quantization_tool/examples/example.py file to test my code as in the zip file example_optimizer.zip

and https://github.com/espressif/esp-dl/blob/master/tools/quantization_tool/optimizer.py also modified make the onnx model simplified optimizer.zip

Let me know if you want the model file. The file is too big to upload here

Auroragan commented 1 year ago

you mentioned that you do the quantization successfully, did you mean running generate_quantization_table successfully or this resnet50_192.onnx model is already quantized?

skodippily commented 1 year ago

Actually, I got one of the pre-trained models from PyTorch, and it was not quantized. then I convert to ONNX. Is there any way that I can double check the model is quantized or not.

skodippily commented 1 year ago

generate_quantization_table Sorry actually, quantization failed but I was able to do the optimization part. "generate_quantization_table" failed because of the missing operators. I will update the issue as well

Auroragan commented 1 year ago

ok, then unfortunately this model cannot be deployed using esp-dl since these operations are not implemented, please check https://github.com/espressif/esp-dl/tree/master/include/layer for the supported operations.

skodippily commented 1 year ago

oh.. thank you for your help. I was trying to create customer layers but didn't work well for me. Is there any model architecture that I need to follow if I want to detect objects for the library? like rrcnn or etc.

Auroragan commented 1 year ago

better use a model architecture that all layers in the model are supported.

skodippily commented 1 year ago

okay I will close the issue then. thank you