New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONVERT yolov5 TO onxx and openvino format #12987
Comments
👋 Hello @FrancoArtale, 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 a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. RequirementsPython>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. Introducing YOLOv8 🚀We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀! Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects. Check out our YOLOv8 Docs for details and get started with: pip install ultralytics |
@FrancoArtale hello! It seems you encountered an issue with tensor shape incompatibility during the OpenVINO export. The error indicates that the input tensor shape expected by OpenVINO does not match the model's input shape defined during the export. This common issue generally occurs during quantization when the configurations don't align perfectly. In your case, since For this specific situation, make sure that the image size ( If double-checking the export parameter sizes doesn't resolve the issue, it might be worthwhile to experiment with Hope that helps! Let us know how it goes. 🌟 |
--simplify didn't work but if I change from --include openvino to --include onnx it works. what's the difference of using openvino or onnx besides the format? Greetings, |
@FrancoArtale hello FA! 🌟 The key difference between using OpenVINO and ONNX is mainly the backend they are optimized for. ONNX is a more generic model format that provides interoperability across different AI frameworks. It allows you to use the model in a variety of platforms and environments. OpenVINO, on the other hand, is specifically optimized for Intel hardware. Using OpenVINO can lead to better performance optimization in terms of inference speed and efficiency when deployed on Intel CPUs, GPUs, or VPUs. As to which is better: if your deployment target includes Intel hardware, OpenVINO might give you better performance optimizations. Otherwise, ONNX provides great flexibility. Hope this clears things up! 🚀 |
Search before asking
YOLOv5 Component
Export
Bug
When I run the following command:
!python ./yolov5_train100kbdd/yolov5s_originsize_300epochs_lr_001/export.py --weights ./yolov5_train100kbdd/yolov5s_originsize_300epochs_lr_001/runs/train/exp5/weights/best.pt --include openvino --imgsz 736 1280 --data ./yolov5_train100kbdd/yolov5s_originsize_300epochs_lr_001/100KBDD/data.yaml --int8
i have the next problem in to openvino convertion:
INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, onnx, openvino
export: data=./yolov5_train100kbdd/yolov5s_originsize_300epochs_lr_001/100KBDD/data.yaml, weights=['./yolov5_train100kbdd/yolov5s_originsize_300epochs_lr_001/runs/train/exp5/weights/best.pt'], imgsz=[736, 1280], batch_size=1, device=cpu, half=False, inplace=False, keras=False, optimize=False, int8=True, per_tensor=False, dynamic=False, simplify=False, opset=17, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=['openvino']
YOLOv5 v7.0-294-gdb125a20 Python-3.10.9 torch-2.2.2+cpu CPU
Fusing layers...
Model summary: 157 layers, 7031701 parameters, 0 gradients, 15.8 GFLOPs
PyTorch: starting from yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights\best.pt with output shape (1, 57960, 13) (14.1 MB)
ONNX: starting export with onnx 1.16.0...
ONNX: export success 2.2s, saved as yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights\best.onnx (27.8 MB)
OpenVINO: starting export with openvino 2024.1.0-15008-f4afc983258-releases/2024/1...
Scanning C:\Users\franco\OneDrive\Escritorio\Final_project\yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\100KBDD\train\labels.cache... 10146 images, 0 backgrounds, 0 corrupt: 100%|██████████| 10146/10146 [00:00<?, ?it/s]
Scanning C:\Users\franco\OneDrive\Escritorio\Final_project\yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\100KBDD\train\labels.cache... 10146 images, 0 backgrounds, 0 corrupt: 100%|██████████| 10146/10146 [00:00<?, ?it/s]
OpenVINO: export failure 20.9s: Exception from src\inference\src\cpp\infer_request.cpp:121:
Exception from src\inference\src\cpp\infer_request.cpp:66:
Exception from src\plugins\intel_cpu\src\infer_request.cpp:382:
Can't set the input tensor with index: 0, because the model input (shape=[1,3,736,1280]) and the tensor (shape=(1.3.640.640)) are incompatible
Export complete (25.7s)
Results saved to C:\Users\franco\OneDrive\Escritorio\Final_project\yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights
Detect: python detect.py --weights yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights\best.onnx
Validate: python val.py --weights yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights\best.onnx
PyTorch Hub: model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5_train100kbdd\yolov5s_originsize_300epochs_lr_001\runs\train\exp5\weights\best.onnx')
Visualize: https://netron.app/
Statistics collection -------------------------- 0% 0/300 • 0:00:00 • -:--:--
Statistics collection -------------------------- 0% 0/300 • 0:00:00 • -:--:--
Statistics collection -------------------------- 0% 0/300 • 0:00:00 • -:--:--
To resume, the problem is here:
OpenVINO: export failure 20.9s: Exception from src\inference\src\cpp\infer_request.cpp:121:
Exception from src\inference\src\cpp\infer_request.cpp:66:
Exception from src\plugins\intel_cpu\src\infer_request.cpp:382:
Can't set the input tensor with index: 0, because the model input (shape=[1,3,736,1280]) and the tensor (shape=(1.3.640.640)) are incompatible.
Something interesting happen when i don't use --int8 parameter, it's work well but i don't have my nncf quantization in 8 bits.
What's wrong here?
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: