ultralytics / yolov5

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

Onnx model export fail #3838

Closed tkuanlun350 closed 3 years ago

tkuanlun350 commented 3 years ago

🐛 Bug

using export.py convert pretrained yolov5s.pt to onnx fail without error message

To Reproduce (REQUIRED)

git clone pip install -r requirements.txt pip install coremltools>=4.1 onnx>=1.9.0 scikit-learn==0.19.2 [download yolov5s.pt and save into models folder] python export.py --weights models/yolov5s.pt --img 640 --batch 1

message showed until program shutdown

Fusing layers... Model Summary: 224 layers, 7266973 parameters, 0 gradients

PyTorch: starting from models/yolov5s.pt (14.8 MB) TorchScript: starting export with torch 1.7.1... C:\Research\detection\yolov5\models\yolo.py:58: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic: TorchScript: export success, saved as models/yolov5s.torchscript.pt (29.4 MB) ONNX: starting export with onnx 1.9.0...

Expected behavior

an onnx model output

Environment

Windows

github-actions[bot] commented 3 years ago

👋 Hello @tkuanlun350, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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

CI CPU testing

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

glenn-jocher commented 3 years ago

@tkuanlun350 ONNX export works correctly on windows per our latest CI check one hour ago: https://github.com/ultralytics/yolov5/runs/2951098934?check_suite_focus=true

Screenshot 2021-06-30 at 13 24 24

iIt appears you may have environment problems. Please ensure you meet all dependency requirements if you are attempting to run YOLOv5 locally. If in doubt, create a new virtual Python 3.8 environment, clone the latest repo (code changes daily), and pip install -r requirements.txt again. We also highly recommend using one of our verified environments below.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

tkuanlun350 commented 3 years ago

Solved by install new environment with python=3.8