yolov5
yolov5 copied to clipboard
Onnx inference not working for image instance segmentation, maybe a bug in ONNX model?
Search before asking
- [X] I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
I have trained my model with Yolov7 at github, but cannot run the inherence (predict.py) without issues when exported to ONNX. At Yolov5 the inference is also not working with my Pytorch .pt file however. Strange enough the .onnx given there runs with this Yolov5 version of segmentation.
I see in the onnx presented here, the input image is a fixed mask and not dynamic, where the other is dynamic with different batch size. What input and outputs to be used ? My own has various slides although the others are more dense. Is this caused by reparameterization ?
I get errors like: For my own .pt model: `PS D:\yolov5> python segment/predict.py --weights best.pt --source "d:\testimage.jpg" segment\predict: weights=['best.pt'], source=d:\testimage.jpg, data=data\coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\predict-seg, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1, retina_masks=False YOLOv5 v7.0-47-g2370a55 Python-3.10.8 torch-1.13.0+cpu CPU
Traceback (most recent call last):
File "D:\yolov5\segment\predict.py", line 284, in My the .pt model in ONNX model:
c, mh, mw = protos.shape # CHW
ValueError: too many values to unpack (expected 3)The same happens for the ONNX model in this github:
PS D:..yolov5> python segment/predict.py --weights yolov5s.onnx --source "D:..myimage.jpg"
segment\predict: weights=['yolov5s.onnx'], source=D:..myimage.jpg, data=data\coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\predict-seg, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1, retina_masks=False
YOLOv5 v7.0-47-g2370a55 Python-3.10.8 torch-1.13.0+cpu CPU
Loading yolov5s.onnx for ONNX Runtime inference...
Traceback (most recent call last):
File "D:..yolov5\segment\predict.py", line 285, in
I would suspect there is a error in the ONNX model in this project as well. But not 100% sure as my own is not working either, and the one of the other YoloV7 project runs here perfectly.
Additional
No response
👋 Hello @V4A001, 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 [email protected].
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):
-
Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
-
Docker Image. See Docker Quickstart Guide
Status
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.
@V4A001 This repo only supports yolov5. Are you seeing this error on a yolov5 trained model?
@AyushExel , yes, I see my code snippets above are glued together. I would suspect there is a error in the ONNX model in this project as well. But not 100% sure as my own is not working either, and the one of the other YoloV7 project runs here perfectly.
The same happens for the ONNX model in this github:
PS D:..yolov5> python segment/predict.py --weights yolov5s.onnx --source "D:..myimage.jpg"
The error is:
` ValueError: not enough values to unpack (expected 2, got 1) PS D:..yolov5> ``
you can try this pr https://github.com/ultralytics/yolov5/pull/9645
👋 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:
- Wiki – https://github.com/ultralytics/yolov5/wiki
- Tutorials – https://docs.ultralytics.com/yolov5
- Docs – https://docs.ultralytics.com
Access additional Ultralytics ⚡ resources:
- Ultralytics HUB – https://ultralytics.com/hub
- Vision API – https://ultralytics.com/yolov5
- About Us – https://ultralytics.com/about
- Join Our Team – https://ultralytics.com/work
- Contact Us – https://ultralytics.com/contact
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 ⭐!
Hi, I encountered similar problems. After conversion, the input and output parts of the model are not complete, thus not usable. Have you found a solution?
@yiliu-coding have you verified the model conversion process and checked if the input and output parts of the model are correct? Double-checking these steps might help in resolving the issue. If you have any further information or specific errors/messages, please provide them so that we can assist you better.