Ashna Eldho
Ashna Eldho

Reputation: 482

How many images(minimum) should be there in each classes for training YOLO?

I am trying to implement YOLOv2 on my custom dataset. Is there any minimum number of images required for each class?

Upvotes: 17

Views: 37050

Answers (4)

Ynjxsjmh
Ynjxsjmh

Reputation: 30050

Ultralytics has a page documenting how to get best training results for YOLOv5: Tips for Best Training Results, in which the recommended number of images and labeled instances are:

  • Images per class. ≥ 1500 images per class recommended
  • Instances per class. ≥ 10000 instances (labeled objects) per class recommended

There is a further discussion for YOLOv8 on Github discussion: Tips for Best Training Results - Ultralytics YOLOv8 Docs, the YOLOv5 tricks also apply to YOLOv8.

There is also a discussion on Github issue about training model from scratch at begining, Glenn Jocher, the creator of YOLOv5 and YOLOv8, states:

  • For object detection models, we recommend using at least 100 annotated images for a single class object detection model and train for more epochs (around 100) to potentially see improvements in accuracy.
  • For segmentation models, we recommend starting with at least 200-300 annotated images per class.

Upvotes: 1

Roscoe - ROSCODE
Roscoe - ROSCODE

Reputation: 39

Here’s the truth: a model can work with 100 images, 500 images, or with 10,000. It just depends on what you are doing and the level of accuracy required for you to use your model." Roboflow answer

Couldn't word it better myself.

How many images do I need for training Ultralytics YOLO models?

For effective transfer learning and object detection with Ultralytics YOLO models, start with a minimum of a few hundred annotated objects per class. If training for just one class, begin with at least 100 annotated images and train for approximately 100 epochs. More complex tasks might require thousands of images per class to achieve high reliability and performance. Quality annotations are crucial, so ensure your data collection and annotation processes are rigorous and aligned with your project's specific goals. Explore detailed training strategies in the YOLOv8 training guide." Ultralytics

Upvotes: 0

iv67
iv67

Reputation: 4151

There is no minimum images per class for training. Of course the lower number you have, the model will converge slowly and the accuracy will be low.

What important, according to Alexey's (popular forked darknet and the creator of YOLO v4) how to improve object detection is :

For each object which you want to detect - there must be at least 1 similar object in the Training dataset with about the same: shape, side of object, relative size, angle of rotation, tilt, illumination. So desirable that your training dataset include images with objects at diffrent: scales, rotations, lightings, from different sides, on different backgrounds - you should preferably have 2000 different images for each class or more, and you should train 2000*classes iterations or more

https://github.com/AlexeyAB/darknet

So I think you should have minimum 2000 images per class if you want to get the optimum accuracy. But 1000 per class is not bad also. Even with hundreds of images per class you can still get decent (not optimum) result. Just collect as many images as you can.

Upvotes: 23

penkovsky
penkovsky

Reputation: 993

It depends.

There is an objective minimum of one image per class. That may work with some accuracy, in principle, if using data-augmentation strategies and fine-tuning a pretrained YOLO network.

The objective reality, however, is that you may need as many as 1000 images per class, depending on your problem.

Upvotes: 5

Related Questions