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

MAP is too small when train on my own datasets #9641

Closed DrewdropLife closed 2 years ago

DrewdropLife commented 2 years ago

Search before asking

Question

The task is "Icons Detection" in the image, I think it is too easy, but, I use the yolov5s pretrained weight and train about 200 epochs, while mp & mr is too high, map also too small, and the visualized result always have many small boxes.

Train dataset: about 30000+ image Val dataset: about 300+ image

(I try to use the images which are come from training dataset to val, but the result is also bad.)

mp mr map@50 map 0.9801 0.8799 0.9542 0.3903

2022-09-29 10-22-54 的屏幕截图

what may the reason be? Thanks.

Additional

No response

MartinPedersenpp commented 2 years ago

Have you checked that your annotations are correct?

DrewdropLife commented 2 years ago

Have you checked that your annotations are correct?

yes, all annotations are correct, I have visualized them.

MartinPedersenpp commented 2 years ago

Have you checked that your annotations are correct?

yes, all annotations are correct, I have visualized them.

Using the format class x_center y_center width height? If you keep seeing an increase in the MaP after 200 epochs, then you can keep training for better precision.

Could you try running inference where the confidence is printed on the bbox?

Another note: If you are detecting logos, I assume that there will almost never be overlaps? If that is the case you can reduce the IOU to filter the inner boxes away.

glenn-jocher commented 2 years ago

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

DrewdropLife commented 2 years ago

@MartinPedersenpp @glenn-jocher Thank you for your reply! I've found the problem, because the code I use belongs to tag v6.1, and the Detect structure have some error! When I update the Detect structure with the latest version, the problem is solved! Now the map has risen to 0.94x~!

glenn-jocher commented 2 years ago

Awesome!

DrewdropLife commented 2 years ago

Because the problem has been solved, I closed it.

glenn-jocher commented 11 months ago

@DrewdropLife great! If you ever have more questions or run into any issues in the future, feel free to open a new one. Happy coding!