google-coral / edgetpu

Coral issue tracker (and legacy Edge TPU API source)
https://coral.ai
Apache License 2.0
412 stars 124 forks source link

Online colab edgetpu model compiler doesnt work #760

Closed easy-and-simple closed 1 year ago

easy-and-simple commented 1 year ago

Description

I downloaded yolov5 tflite model from tensoflow hub and used colab model compiler to convert it to edgetpu and as you can see from following information printed by edgetpu compiler all instructions will run ot CPU and 0 instructions will run on edge TPU. Excellent acceleration hahahaha On top of all when I try model with object detection script from object detection example that is included in pycoral repository is fails with error index out of range


edgetpu compiler info


Edge TPU Compiler version 16.0.384591198 Started a compilation timeout timer of 180 seconds.

Model compiled successfully in 27 ms.

Input model: lite-model_yolo-v5-tflite_tflite_model_1.tflite Input size: 7.25MiB Output model: lite-model_yolo-v5-tflite_tflite_model_1_edgetpu.tflite Output size: 7.16MiB On-chip memory used for caching model parameters: 0.00B On-chip memory remaining for caching model parameters: 0.00B Off-chip memory used for streaming uncached model parameters: 0.00B Number of Edge TPU subgraphs: 0 Total number of operations: 268 Operation log: lite-model_yolo-v5-tflite_tflite_model_1_edgetpu.log

Model successfully compiled but not all operations are supported by the Edge TPU. A percentage of the model will instead run on the CPU, which is slower. If possible, consider updating your model to use only operations supported by the Edge TPU. For details, visit g.co/coral/model-reqs. Number of operations that will run on Edge TPU: 0 Number of operations that will run on CPU: 268 See the operation log file for individual operation details. Compilation child process completed within timeout period. Compilation succeeded!


detect_image.py ERROR


PS M:\coral\pycoral> py examples/detect_image.py --model test_data/yolov5_edgetpu.tflite --labels test_data/yolo_labels.txt --input test_data/1.bmp --output Y:/111.bmp M:\coral\pycoral\examples\detect_image.py:78: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use LANCZOS or Resampling.LANCZOS instead. interpreter, image.size, lambda size: image.resize(size, Image.ANTIALIAS)) ----INFERENCE TIME---- Note: The first inference is slow because it includes loading the model into Edge TPU memory. Traceback (most recent call last): File "M:\coral\pycoral\examples\detect_image.py", line 108, in main() File "M:\coral\pycoral\examples\detect_image.py", line 87, in main objs = detect.get_objects(interpreter, args.threshold, scale) File "C:\Users\User1\AppData\Local\Programs\Python\Python39\lib\site-packages\pycoral\adapters\detect.py", line 214, in get_objects elif common.output_tensor(interpreter, 3).size == 1: File "C:\Users\User1\AppData\Local\Programs\Python\Python39\lib\site-packages\pycoral\adapters\common.py", line 29, in output_tensor return interpreter.tensor(interpreter.get_output_details()[i]['index'])() IndexError: list index out of range error

Click to expand! ### Issue Type Bug ### Operating System Windows 10 ### Coral Device M.2 Accelerator A+E ### Other Devices _No response_ ### Programming Language Python 3.9 ### Relevant Log Output _No response_
hjonnala commented 1 year ago

I downloaded yolov5 tflite model from tensoflow hub

Please inpect the log file and or compile with -s flag( !edgetpu_complier -s model.tflite). Probably all operations are float type. https://coral.ai/docs/edgetpu/models-intro/#model-requirements

easy-and-simple commented 1 year ago

Probably all operations are float, and what to do to make them int8? I can't understand what is for edgetpu_compiler if it cant convert float to int and I need to try to find way to covert models manually? If I know how to make model to meet edgetpu requirements then obviously I would compile it manually too. I looked for the way to convert float tf model to int8 tf model and didnt find such way because ft converter converts only saved models and there is no way to convert my model to saver model. What is for this all framework API then? Framework API should make things easy and simple and not hard and complicated right? Also would be helpful if you can help me to export yolo model for edgetpu, because export support lf yolo doen't work and model exported can't run on edgetpu issuing error that index is out of range

hjonnala commented 1 year ago

Please try to get a saved model for yolo model and refer to the below links to convert the saved model to int8 model. Thanks!!

easy-and-simple commented 1 year ago

Do you know why yolo model exported by yolo export function doesn't run with pycoral framework? I export yolo model and try to run detect image example from opycoral, but it issue error index out of range

hjonnala commented 1 year ago

Ouput layer for your yolo model might be different from the object detection model.

image

google-coral-bot[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No