Tflite to be used with Google Coral

Can Edge Impulse create a tflite file that can be used in Google Coral?

Hi @UlfAndersson

You need to download the trained tflite model from the Edge Impulse dashboard and use the Edge TPU compiler to convert it to a format compatible with the Google Coral Edge TPU. You can have a look st this for more details https://coral.ai/docs/edgetpu/compiler/

Regards,
Clinton

Thanks for the reply,
Be patient with me, I have just started with Open MV.
I have exported tflite to Opne MV, can I use that file, or should I export to something else.
I have looked at https://coral.ai/docs/edgetpu/compiler/ is it "TensorFlow toco_convert "tool you mean?
Regards,
Ulf

Hi @UlfAndersson

For OpenMV you can just use the tflite file as it is. Follow this blog tutorial for more info on how to deploy your impulse on OpenMV cam https://docs.edgeimpulse.com/docs/openmv-cam-h7-plus

Thanks,
Clinton

Hi Clinton,
I have successfully used OpenMV.
With Edge Impulse I have created a tflite file and used it with OpenMV.

My question is can I use the same tflite file with Google Coral?
Or should I use a different way to produce a tflite file that can be converted Google Coral?

Earlier you explained “You need to download the trained tflite model from the Edge Impulse dashboard and use the Edge TPU compiler to convert it to a format compatible with the Google Coral Edge TPU”

How and were can I access the “Edge TPU compiler”

Regards
Ulf

Hi @UlfAndersson,

Great to hear that the model ran well on OpenMV!

For google coral, find more instructions on how to download and use the compiler here https://coral.ai/docs/edgetpu/compiler/#usage.

Thanks,
Clinton

Hi @UlfAndersson,

I have been able to compile my edge impulse tflite model to a format compatible with the Google Coral Edge TPU using this colab notebook provided by the google coral team (https://colab.research.google.com/github/google-coral/tutorials/blob/master/compile_for_edgetpu.ipynb#scrollTo=joxrIB0I3cdi).

Could you try that out and deploy it on your coral dev board then share the results here?

Make sure to use the fully quantized int 8 model.

Thanks,
Clinton

Hey @oduor_c I hope you don’t mind me asking here, because I got a similar problem: I want to use Edge Impulse trained models with the USB Google Coral accelerator. I downloaded the int 8 quantized model and converted it using the Colab you shared. This did somewhat work:

Edge TPU Compiler version 16.0.384591198
Input: test.tflite
Output: test_edgetpu.tflite

Operator                       Count      Status

RESHAPE                        1          Operation is otherwise supported, but not mapped due to some unspecified limitation
SOFTMAX                        1          More than one subgraph is not supported
FULLY_CONNECTED                1          More than one subgraph is not supported
CONV_2D                        2          Mapped to Edge TPU
MAX_POOL_2D                    2          Mapped to Edge TPU

However, running the created file with the normal example ( pycoral/classify_image.py at master · google-coral/pycoral · GitHub ) [ using: python examples/classify_image.py --model labSentinel2/test_edgetpu.tflite --labels labSentinel2/labels.txt --input labSentinel2/test.jpg ]

results in the following error:

Traceback (most recent call last):
  File "C:\Users\-\Desktop\coral\pycoral\examples\classify_image.py", line 121, in <module>
    main()
  File "C:\Users\-\Desktop\coral\pycoral\examples\classify_image.py", line 76, in main
    raise ValueError('Only support uint8 input type.')
ValueError: Only support uint8 input type.

This leads me to believe that the conversion from int8 to uint8 did not take place?
Do you have any additional ideas I could try to make an Edge Impulse model working on Google Coral?

Thanks a lot!