ultralytics / yolov5

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

Image inverting when using the CPU-backend #11726

Closed HerrAskinSM closed 1 year ago

HerrAskinSM commented 1 year ago

Search before asking

YOLOv5 Component

Validation

Bug

Greetings, colleagues! At startup val.ру using the python command val.py --weights yolov5n.pt --batch-size 1 --dnn --verbose --device cpu images with labels are saved in the results folder. Some images are inverted by color. The strange thing is that when using --device 0 instead --device cpu, the same images are saved in normal form. In general, the problem is deeper. I have after training when inference of yolov5n.onnx using OpenCV cv::dnn::Net has no detection when using CPU, but when switching to CUDA, detections appear. I thought that the inversion of the image and the lack of detection may be related. val_batch0_labels val_batch0_pred val_batch1_labels val_batch1_pred val_batch2_labels val_batch2_pred

Environment

Minimal Reproducible Example

val.py --weights yolov5n.onnx --batch-size 1 --dnn --verbose --device cpu val.py --weights yolov5n.onnx --batch-size 1 --verbose --device 0

val.py --weights yolov5m.pt --batch-size 1 --dnn --verbose --device cpu val.py --weights yolov5m.pt --batch-size 1 --verbose --device 0

Additional

No response

Are you willing to submit a PR?

glenn-jocher commented 1 year ago

@HerrAskinSM hi there! Thank you for reaching out and reporting this issue.

Regarding the images being inverted when using the CPU backend, it seems like there might be an inconsistency between the CPU and CUDA backends. We appreciate you providing the specific command examples for reproduction.

Additionally, you mentioned that after training when using the yolov5n.onnx model and OpenCV's cv::dnn::Net for inference, you noticed no detections when using the CPU, but detections appeared when switching to CUDA. This could indeed be related.

To better assist you, we kindly ask you to provide more details on your system environment, such as the version of OpenCV used and any relevant specifications of your hardware setup.

Our team will look into this issue and investigate a possible solution. In the meantime, if you have any other information or insights that might be useful, please feel free to share them. We appreciate your willingness to contribute and submit a pull request to help resolve this issue.

Thank you for your patience, and we'll do our best to address this as soon as possible.

HerrAskinSM commented 1 year ago

Used OpenCV versions: 4.5.5.62, 4.7.0, 4,7,0_dev (latest)

glenn-jocher commented 1 year ago

Hi @HerrAskinSM,

Thank you for providing the OpenCV versions you have used (4.5.5.62, 4.7.0, 4.7.0_dev).

We will investigate this issue further and try to reproduce it using the provided OpenCV versions. It will help us narrow down the possible causes and find a solution.

Please allow us some time to analyze the problem and get back to you. If you have any additional details or insights that you think might be relevant, please don't hesitate to share them.

We appreciate your patience and contribution to resolving this issue.

Thank you.

github-actions[bot] commented 1 year ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

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 YOLO 🚀 and Vision AI ⭐

EliSheppard commented 2 months ago

Is there a solution to this? ultralytics 8.2.86 opencv-python-headless 4.10.0.84

I'm fine tuning YoloV8s.

glenn-jocher commented 2 months ago

@EliSheppard please ensure you're using the latest YOLOv5 version and verify if the issue persists. If it does, provide more details about the problem for further assistance.

EliSheppard commented 2 months ago

As I said, I I using YoloV8s.

glenn-jocher commented 2 months ago

For YOLOv8-specific issues, please refer to the Ultralytics YOLOv8 repository and documentation for guidance. If you encounter any problems, ensure you're using the latest version.