You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After converting from .pt to .torchscript, bounding box is off #6947
I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
I am playing around with YOLOv5 and exporting to different formats (.pt & .torchscript). But I found that after I exported the pre-trained models using this command: !python "/content/drive/MyDrive/yolov5/export.py" --weights "/content/drive/MyDrive/yolov5/yolov5s.pt" --include torchscript
The .torchscript model's bounding is off, please advise me on why this is happening and how to resolve it. Thank you.
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.
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
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), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
@willsonyee 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. Torchscript export and inference works well for me, I'm unable to reproduce any box issues.
We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.
How to create a Minimal, Reproducible Example
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
✅ Minimal – Use as little code as possible to produce the problem
✅ Complete – Provide all parts someone else needs to reproduce the problem
✅ Reproducible – Test the code you're about to provide to make sure it reproduces the problem
For Ultralytics to provide assistance your code should also be:
✅ Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
✅ Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.
If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Reporttemplate with a minimum reproducible example to help us better understand and diagnose your problem.
import torch
model = torch.hub.load('/content/drive/MyDrive/yolov5', 'custom', path='/content/drive/MyDrive/yolov5/yolov5s.torchscript', source='local')
result = model("/content/drive/MyDrive/yolov5/data/images/zidane.jpg")
result.save()
The reason I am doing it like this because I am trying to load the model from local and inference without using the detect.py. So I can later on integrate the .torchscript model into my swift IOS app.
Could you advise me why by running the code I attached will cause the bounding box off ?
Activity
github-actions commentedon Mar 11, 2022
👋 Hello @willsonyee, 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:
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
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), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
glenn-jocher commentedon Mar 11, 2022
@willsonyee 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. Torchscript export and inference works well for me, I'm unable to reproduce any box issues.
We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.
How to create a Minimal, Reproducible Example
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
For Ultralytics to provide assistance your code should also be:
git pullorgit clonea new copy to ensure your problem has not already been solved in master.If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.
Thank you! 😃
willsonyee commentedon Mar 11, 2022
@glenn-jocher thanks for your prompt response.
I am running the code like this:
The reason I am doing it like this because I am trying to load the model from local and inference without using the detect.py. So I can later on integrate the .torchscript model into my swift IOS app.
Could you advise me why by running the code I attached will cause the bounding box off ?
glenn-jocher commentedon Mar 11, 2022
@willsonyee ah yes you are right there is a bug. I'm able to reproduce with this code:
I'll take a look!
Fix PyTorch Hub export inference shapes
Fix PyTorch Hub export inference shapes (#6949)
Update Neuralmagic-YoloV5 integration to v6.1 (#29)
Fix PyTorch Hub export inference shapes (ultralytics#6949)
Fix PyTorch Hub export inference shapes (#6949)
Fix PyTorch Hub export inference shapes (#6949)