Skip to main content
Blog
Tutorial
Oct 19, 20266 min

How Many Images Do You Need to Train YOLO?

What Ultralytics actually recommends for images and labeled objects per class, why fine-tuning changes the starting point, and how to count what your dataset already has.

Every computer vision project hits the same planning question early: how many images do we need to label before training is worth it? The honest answer is "it depends," which is not very useful when you are trying to budget annotation time. Fortunately, Ultralytics publishes concrete targets, and they are a much better starting point than guessing.

This post covers what those targets are, what they mean in practice, and why you can (and usually should) train a first model long before you reach them.

The short answer

Ultralytics' Tips for Best Training Results guide gives these dataset recommendations for best results:

  • At least 1,500 images per class.
  • At least 10,000 instances per class. An instance is one labeled object, so one image with six forklifts counts as six instances.
  • About 0–10% background images, meaning images with none of your classes in them, to help reduce false positives.

The guide was written for YOLOv5, but it is still the most specific dataset-size advice Ultralytics publishes. The newer Model Training Tips guide does not give per-class numbers.

Two words in that guidance matter more than they seem: per class and best. The targets apply to every class separately, so a ten-class project multiplies the work. And they describe what to aim for when you want strong results, not the minimum needed for training to run.

Images vs. instances: why both numbers matter

The two targets catch different weaknesses.

The image count is about context. A model that sees a class in 1,500 different scenes has seen many backgrounds, angles, and lighting setups. The instance count is about examples of the object itself: different sizes, poses, partial occlusions, and close neighbors.

How they relate depends on your data. If a typical image contains about seven objects of a class, 1,500 images already gives you around 10,500 instances. If each image contains one object, you would need roughly 10,000 images to reach the instance target, far more than the image target.

So check both. Crowded scenes such as retail shelves tend to pass the instance target easily and fall short on image variety. Datasets with one large object per photo tend to have the opposite problem.

Fine-tuning changes the starting point

The Ultralytics guide recommends starting from pretrained weights for small to medium datasets and training from scratch only for large ones. The standard Ultralytics detection checkpoints are pretrained on COCO, so the model already knows a lot about edges, shapes, and common objects before it sees your data.

That is why you do not need 1,500 images per class to learn whether your project works. A small, carefully labeled first batch fine-tuned from pretrained weights is enough for a proof of concept. It shows you whether the classes are separable, which ones the model confuses, and where your labeling rules are unclear.

The trade-off: a proof of concept tells you the task is learnable, not that the model is ready to ship. Small datasets often look good on a validation set that is too similar to the training set, then fail on new cameras or new sites. Treat early metrics as a signal to keep going, not as a final score.

Ultralytics also recommends training with default settings first to establish a baseline. If your first run is weak, add or fix data before tuning hyperparameters. Data problems are usually the cheaper fix.

Variety beats raw count

The same guide says images must be representative of the deployed environment. In practice that means covering the conditions your model will meet:

  • Different times of day, seasons, and weather, if the camera is outdoors.
  • Different lighting, angles, and distances.
  • Every camera or device that will feed the model.

A thousand nearly identical frames from one video add far less than their count suggests. If you extract frames from video, sample them spread out over time, and keep frames from the same clip in the same split so validation stays honest. Our guide on dataset split planning covers this in more detail.

Label quality counts as much as quantity

Ultralytics lists two labeling requirements alongside the size targets:

  • Label consistency: every instance of every class in every image must be labeled. A missed object teaches the model that this object is background.
  • Label accuracy: boxes must closely enclose each object, with no gaps or loose padding.

This is where the cost of a large dataset hides. Ten thousand sloppy instances can train a worse model than a smaller, consistent set. Clear written rules for edge cases such as occlusion, truncation, and tiny objects pay off quickly. See acceptance criteria for object detection labeling for a template.

Do not skip background images

Background images contain none of your classes and need no labels. The guide suggests about 0–10% of the dataset. They are most useful when they look like the places your model could raise false alarms: empty shelves, empty roads, the same factory floor with no defects.

In Ultralytics YOLO format, an image with no objects does not need a label file at all, though many tools write an empty .txt file instead. Both work.

Count what you already have

Before labeling more, measure your current dataset per class. If your labels are already in YOLO TXT format, this short script counts images and instances per class ID:

import sys
from collections import Counter
from pathlib import Path

labels_dir = Path(sys.argv[1])
images_per_class, instances_per_class = Counter(), Counter()
label_files = empty_files = 0

for path in labels_dir.rglob("*.txt"):
    if path.name == "classes.txt":
        continue
    label_files += 1
    ids = [int(float(line.split()[0])) for line in path.read_text(encoding="utf-8-sig").splitlines() if line.strip()]
    if not ids:
        empty_files += 1
    instances_per_class.update(ids)
    images_per_class.update(set(ids))

print(f"{label_files} label files, {empty_files} empty (background)")
for class_id in sorted(instances_per_class):
    print(f"class {class_id}: {images_per_class[class_id]} images, {instances_per_class[class_id]} instances")

Run it as python count_yolo_classes.py dataset/labels. Images without any label file are not counted, so compare against your image folder to get the full background share.

If your annotations are in COCO JSON, CVAT XML, JSONL, CSV, or TSV, the free Dataset Health Report runs in your browser and flags dominant and sparse classes, crowded images, near-duplicate boxes, and out-of-bounds boxes. Sparse classes are the ones to prioritize in the next labeling round.

A practical plan

  1. Label a small pilot set that covers every class and every camera or site, with written labeling rules.
  2. Fine-tune from pretrained weights with default settings to get a baseline.
  3. Read the errors, not just the score. Which classes are confused? Which conditions fail?
  4. Label more where the model is weak, guided by per-class counts. Rare classes need targeted collection, not just more random images. Our class imbalance guide covers sampling strategies.
  5. Add background images from places where false positives show up.
  6. Move toward the Ultralytics targets for classes that matter most, and stop where validation results meet your requirements.

The targets give you a planning ceiling. Your validation results on realistic data tell you where to stop.

References

FAQ

How many images per class do I need for YOLO?

Ultralytics recommends at least 1,500 images per class and at least 10,000 labeled instances per class for best results. Those are targets for strong models, not minimums for training to run.

Can I train YOLO with 100 images?

You can fine-tune a pretrained model on a small dataset, and it is a reasonable way to test whether your task is learnable. Expect the model to struggle with conditions it has not seen, and add more varied data before relying on it.

What is the difference between images and instances?

An image is one photo. An instance is one labeled object. An image with five cars contains five car instances, which is why Ultralytics gives separate targets for each.

How many background images should a YOLO dataset have?

Ultralytics suggests about 0–10% background images, which are images with none of your classes. They help reduce false positives and need no labels.

Is more data always better for YOLO training?

More varied and correctly labeled data usually helps. Many near-duplicate frames or inconsistent labels add cost without adding much, so prioritize variety and label quality over raw count.

Take the next step with your dataset.

Use local AI, managed cloud labeling, and team review in LabelOp. Export your work or train with your own Vast.ai account.

Start free