Skip to content
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

Is there no backwards compatablility for yolov5? #13526

Open
1 task done
guzman109 opened this issue Mar 6, 2025 · 4 comments
Open
1 task done

Is there no backwards compatablility for yolov5? #13526

guzman109 opened this issue Mar 6, 2025 · 4 comments
Labels
detect Object Detection issues, PR's question Further information is requested

Comments

@guzman109
Copy link

Search before asking

Question

I'm using the ultralytics library and loading the model via torch hub. Looks like NMS from ultralytics is different than the NMS from the yolov5 repo and I am getting completely different results between using both models as well.

Is there no backwards compatibility?

Additional

No response

@guzman109 guzman109 added the question Further information is requested label Mar 6, 2025
@UltralyticsAssistant UltralyticsAssistant added the detect Object Detection issues, PR's label Mar 6, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @guzman109, 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. Specifically, for your scenario, please include:

  1. The exact code snippet you're using to load the model via torch.hub and perform inference.
  2. Details of the YOLOv5 version(s) you're comparing, and how you're loading the models in both cases.
  3. Examples of the input image(s) and the resulting outputs you're observing for comparison.

If this is a custom model or compatibility ❓ Question, please provide as much information as possible, including the details of the models or libraries you're using. Additionally, consider ensuring that all setups are aligned with our Tips for Best Training Results.

Requirements

Python>=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

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.

This is an automated response to help guide you with helpful resources 💡. An Ultralytics engineer will review your issue and assist you further shortly.

@pderrenger
Copy link
Member

@guzman109 yOLOv5 maintains backward compatibility for inference when using the exact same model version across both torch hub and local code. For optimal results:

  1. Specify exact model version in torch.hub.load():
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', version='v6.0')  # specify version tag
  1. Verify you're using matching:
    • Model architecture (v6.0+ has updated layers)
    • Postprocessing (NMS implementation in utils.general.non_max_suppression)
    • Package versions (pip install -U ultralytics)

The YOLOv5 v6.0 release notes detail architectural changes that might affect compatibility. If issues persist, please share a minimum reproducible example per our bug report guidelines.

@guzman109
Copy link
Author

So the output changed at some point to match the other yolo models? The non_max_suppression input has a different shape than older version of the model.

Also, is scale_boxes from utils/general.py the same as scale_boxes or scale_coords in ultralytics module?

@pderrenger
Copy link
Member

@guzman109 yOLOv5 v6.0+ introduced architectural updates that changed output dimensions and postprocessing steps to align with newer YOLO versions. For compatibility:

  1. NMS Input Shape: Use matching model and code versions (v6.0+ models require v6.0+ code). Older versions have different output shapes as detailed in the YOLOv5 v6.0 release notes.

  2. Scaling Functions: scale_coords was renamed to scale_boxes in newer versions but serves the same purpose. Use the function matching your code version from the current YOLOv5 utils.

For specific version behaviors, see the Non-Maximum Suppression glossary and ensure your ultralytics package is updated (pip install -U ultralytics). Let us know if you need version-specific details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detect Object Detection issues, PR's question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants