ultralytics / yolov5

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

Multiple detections when using mps #9601

Closed lightonthefloor closed 1 year ago

lightonthefloor commented 2 years ago

Search before asking

YOLOv5 Component

No response

Bug

When running on --source 0, there are multiple detections. ![Uploading 截屏2022-09-26 20.48.03.png…]()

Environment

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

lightonthefloor commented 2 years ago
截屏2022-09-26 20 48 03
glenn-jocher commented 2 years ago

@lightonthefloor you don't need any fallback, normal inference command runs, but yes the MPS model is differing from the CPU model. There may some MPS issue here.

You should put breakpoints in the model to debug where the differences start. This may be an issue that needs to be raised with the torch team if you can isolate the cause of the difference.

Screenshot 2022-09-26 at 14 52 56
lightonthefloor commented 2 years ago

Oops, and my detections of demo is right. bus

glenn-jocher commented 2 years ago

@lightonthefloor are you sure? I get incorrect results on MPS, even though MPS inference runs without error.

Screenshot 2022-09-26 at 15 02 42
lightonthefloor commented 2 years ago

Sorry, I check again. I get the correct answer when I run on cpu.

glenn-jocher commented 2 years ago

I tested PYTORCH_ENABLE_MPS_FALLBACK=1 classify/predict.py, and this works correctly, so it seems perhaps an issue with Detect(), maybe grids that MPS is not converting correctly.

github-actions[bot] commented 2 years ago

👋 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:

Access additional Ultralytics ⚡ resources:

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 ⭐!

ehallein commented 2 years ago

FYI another detector https://github.com/microsoft/CameraTraps which uses YOLOv5 works on MPS with GPU acceleration with no issues, so it appears detect.py may be the issue, not PyTorch.

See here microsoft/CameraTraps#297

jgoo9410 commented 2 years ago

Also having this issue, was any progress made in finding the cause @lightonthefloor?

github-actions[bot] commented 1 year ago

👋 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:

Access additional Ultralytics ⚡ resources:

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 ⭐!