ultralytics / yolov5

YOLOv5 šŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.86k stars 16.37k forks source link

val.py don't show the P, R, mAP50 and mAP50-95 score, and cannot run detect.py with custom model #12384

Closed anhtr-nguyn closed 12 months ago

anhtr-nguyn commented 12 months ago

Search before asking

YOLOv5 Component

Validation, Detection

Bug

The data I collected through roboflow and choose correct type: yolov5pytorch. I have also trained my custom model successfully on https://hub.ultralytics.com/ and download it. I also download the data and change the path to val and test.

When I run python3 val.py --weights traffic_sign_yolov5s.pt --data /home/tronganh/hcmut/datasets/data.yaml --batch-size 1, the output was quite normal:

Class Images Instances P R mAP50 mAP50-95: 2%|ā– | 3/174 [00:00<00:49, 3.44itException in thread Thread-7: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/tronganh/hcmut/yolov5/utils/plots.py", line 172, in plot_images cls = names[cls] if names else cls KeyError: 8975 Class Images Instances P R mAP50 mAP50-95: 100%|ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆ| 174/174 [00:31<00:00, 5.46 all 174 227 0 0 0 0 , However, it could not show the score.

Moreover, when I run python3 detect.py --weights traffic_sign_yolov5s.pt --source /home/tronganh/hcmut/datasets/test/images/ , the error is: Traceback (most recent call last): File "detect.py", line 285, in <module> main(opt) File "detect.py", line 280, in main run(**vars(opt)) File "/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py", line 34, in decorate_context return func(*args, **kwargs) File "detect.py", line 175, in run s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string . When I change to default model yolov5s.pt, it could run normally

Environment

OS: Ubuntu on Jetson Xavier, run on image of pytorch (l4t) Python: 3.8.10 YOLOv5 šŸš€ 2023-11-15 Python-3.8.10 torch-2.0.0a0+ec3941ad.nv23.02 CUDA:0 (Xavier, 6857MiB)

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

github-actions[bot] commented 12 months ago

šŸ‘‹ Hello @anhtr-nguyn, 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.

If this is a custom training ā“ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following 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.

Introducing YOLOv8 šŸš€

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 šŸš€!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 12 months ago

@anhtr-nguyn hi there! It looks like you're experiencing some issues with YOLOv5 validation and detection using a custom model. The validation val.py seems to be running normally but without displaying the scores, and the detect.py is throwing an error when using your custom model. The error may be caused by class name mapping or an incompatible custom model.

You could start by checking your custom model's class names and ensuring they correspond to the expected format. Also, ensure that the custom model you downloaded is compatible with the YOLOv5 implementation.

For the detection issue, you can try updating your custom model's class names and ensuring it is compatible with the detect.py script.

Let me know if you need further assistance with this! Also, make sure to refer to the YOLOv5 documentation (https://docs.ultralytics.com/yolov5/) for guidance on using custom models and troubleshooting common issues. šŸ˜Š

anhtr-nguyn commented 12 months ago

@glenn-jocher Thanks for your reply. I have tried many methods including changing the name of model. I realized that the model which was trained through ultralytics HUB has some error and could not run normally, maybe the version on ultralytics HUB is Yolov5su. After I trained the model on local, everything has worked. Thanks for your dedication

glenn-jocher commented 12 months ago

You're welcome, @anhtr-nguyn! I'm glad to hear that you were able to resolve the issue by training the model locally. The YOLOv5 community and the Ultralytics team are dedicated to providing a seamless experience for users, and your feedback is valuable for improving the platform. If you have any more questions or need further assistance in the future, feel free to reach out. Good luck with your YOLOv5 projects!