ultralytics / yolov5

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

How yolov5 calculates map when testing datasets? #7794

Closed shisenglin closed 2 years ago

shisenglin commented 2 years ago

Search before asking

Question

I'm a novice, and I don't know how yolov5 calculates map when testing datasets. Hope to receive an answer.

Additional

No response

glenn-jocher commented 2 years ago

@shisenglin mAP is the area under the Precision-Recall curve. See https://en.wikipedia.org/wiki/Precision_and_recall

shisenglin commented 2 years ago

@shisenglin mAP 是精度-召回率曲线下的面积。请参见 https://en.wikipedia.org/wiki/Precision_and_recall Thank you for your reply!I understand the concept of mAP, but I just can't find the code you wrote to calculate mAP in yolov5, or I don't know if there is any code in YOLOv5 to calculate mAP, and I don't know how to run it to generate an image of mAP.

glenn-jocher commented 2 years ago

@shisenglin see utils/metrics.py

shisenglin commented 2 years ago

@shisenglin see utils/metrics.py

Can I run the file metrics.py to generate mAP images?

glenn-jocher commented 2 years ago

@shisenglin val.py computes mAP:

python val.py --weights yolov5s.pt --data coco128.yaml
shisenglin commented 2 years ago

@shisenglin val.py 计算 mAP:

python val.py --weights yolov5s.pt --data coco128.yaml

f31b1a410387c411f304e2c7c7088ab This error occurs after running : OSError: [WinError 1455] The page file is too small to complete the operation. Error loading "D:\Anaconda3\envs\luoge\lib\site-packages\torch\lib\cudnn_adv_infer64_8.dll" or one of its dependencies. What is the reason for this error?

glenn-jocher commented 2 years ago

@shisenglin this is a windows error unrelated to YOLOv5. See https://www.thewindowsclub.com/increase-page-file-size-virtual-memory-windows

shisenglin commented 2 years ago

@shisenglin this is a windows error unrelated to YOLOv5. See https://www.thewindowsclub.com/increase-page-file-size-virtual-memory-windows

image Thanks to the author's answer, the problem of reporting errors has been solved, and now the operation has results, but the values of P and R seem to be a little low.

glenn-jocher commented 2 years ago

@shisenglin 👋 Hello! Thanks for asking about improving YOLOv5 🚀 training results.

Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement.

If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your project/name directory, typically yolov5/runs/train/exp.

We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below.

Dataset

COCO Analysis

Model Selection

Larger models like YOLOv5x and YOLOv5x6 will produce better results in nearly all cases, but have more parameters, require more CUDA memory to train, and are slower to run. For mobile deployments we recommend YOLOv5s/m, for cloud deployments we recommend YOLOv5l/x. See our README table for a full comparison of all models.

YOLOv5 Models

Training Settings

Before modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.

Further Reading

If you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/

Good luck 🍀 and let us know if you have any other questions!

shisenglin commented 2 years ago

@glenn-jocher Thank you very much to the author for helping me so patiently with the problems that arose during the use of yolov5. I think the answers you gave were extremely comprehensive and useful for me as a novice. I will come back to you again if I encounter any other problems in using yolov5, and I hope you would like to give me answers again. Thank you very much!

shisenglin commented 2 years ago

@glenn-jocher I have trained my own dataset using yolov5 to get the training model. I've learned to put the training model to detect images by using detect.py, but I don't know how to detect videos. If I want to detect videos, where do I need to change the code? I hope the author can reply and answer, thanks a lot!

glenn-jocher commented 2 years ago

@shisenglin see https://github.com/ultralytics/yolov5#quick-start-examples for inference examples on videos:

Screen Shot 2022-05-13 at 6 26 39 PM
shisenglin commented 2 years ago

1652460656(1) @glenn-jocher So in the above image I just need to change the f1.jpg in default = ROOT / 'data/images/f1.jpg' to vid.mp4 and I will be able to detect the video right?

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

glenn-jocher commented 11 months ago

@shisenglin yes, you are correct! Changing the path from f1.jpg to vid.mp4 would allow you to detect the video. Additionally, you may also need to specify the output directory for the video detections by setting the --save-txt flag. Good luck with your video detections!