ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.03k stars 16.17k forks source link

Exporting model to tflite including edgetpu shows some strange behavior with certain resolutions #10405

Closed mexxBf closed 1 year ago

mexxBf commented 1 year ago

Search before asking

Question

Hi all, currently I'm training a yolo5s model for my Coral Edge TPU. While experimenting with the resolution in the training part, I found that I can not convert the models properly, if I choose e.g. 512px in training and export. The result is:

` Number of operations that will run on Edge TPU: 123 Number of operations that will run on CPU: 139

Operator Count Status

STRIDED_SLICE 9 More than one subgraph is not supported MAX_POOL_2D 3 Mapped to Edge TPU ADD 3 More than one subgraph is not supported ADD 7 Mapped to Edge TPU PAD 5 Mapped to Edge TPU PAD 2 More than one subgraph is not supported CONCATENATION 12 More than one subgraph is not supported CONCATENATION 5 Mapped to Edge TPU RESHAPE 6 More than one subgraph is not supported RESIZE_NEAREST_NEIGHBOR 2 More than one subgraph is not supported CONV_2D 34 Mapped to Edge TPU CONV_2D 26 More than one subgraph is not supported LOGISTIC 32 More than one subgraph is not supported LOGISTIC 34 Mapped to Edge TPU MUL 34 Mapped to Edge TPU MUL 41 More than one subgraph is not supported QUANTIZE 5 More than one subgraph is not supported QUANTIZE 1 Operation is otherwise supported, but not mapped due to some unspecified limitation QUANTIZE 1 Mapped to Edge TPU Compilation child process completed within timeout period. Compilation succeeded! Edge TPU: export success ✅ 26.8s, saved as runs/train/exp84/weights/best-int8_edgetpu.tflite (7.3 MB) ` But if I choose 416px or 672px and up as resolution for training and export its says "Number of operations that will run on CPU: 3".

It works up to 800px with an 32px increment. If I remember correctly, even 1024px works.

My model only has two classes, if that is interesting to you.

The command I use for export: python export.py --weights runs/train/exp83/weights/best.pt --include edgetpu --img 544

Maybe someone knows why this happens, or how I can make it work.

Thank you

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @mexxBf, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 1 year ago

@mexxBf Edge TPU exports support a variety of options if I remember correctly, you may need to experiment with the arguments to see what works best for your use case. See https://coral.ai/docs/edgetpu/faq/ and view the export code at: https://github.com/ultralytics/yolov5/blob/5dc1ce4e865960f5b5dfe4e4f5148a4731433bca/export.py#L403-L426

mexxBf commented 1 year ago

@glenn-jocher Thank you for your response.

Maybe you can explain to me, what the consequences in yolo are if changing the --img argument. I changed nothing but this option and get completely different results on export. My guess would be, that something internal changes and becomes kind of incompatible with the export of the edgetpu. Its kind of strange, that the resolutions 416, 448, 672,704 and 800 are okay, but 480, 512, 544, 576,608,640 are incompatible with export.

Thank you, best regards

glenn-jocher commented 1 year ago

@mexxBf I'd ask question on Coral/Edge TPU forums, as this what their software does it really outside of our control.

github-actions[bot] commented 1 year ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!