How to label images for object detection

A detector can only be as good as its labels. A few rules, applied every time, matter more than any training setting.

6 min read

Draw tight boxes

The box should touch the outermost visible pixels of the object, no more. Loose boxes teach the model to draw loose boxes, and they cost you accuracy on the strict IoU thresholds of mAP50-95.

Never skip an object

An unlabeled object is not neutral: it tells the model that this thing is background. If you label people, label every person, including the small ones far away and the ones cut off by the edge of the image.

Write down the hard cases

  • Partly hidden objects: box the visible part, or the whole estimated object? Pick one.
  • Groups: a crowd, a stack of boxes, a bunch of bananas. One box per item, or skip items you cannot separate?
  • Reflections, pictures of objects, toys: do they count?

Any answer works if it is the same everywhere. Write the rules in a short document before you start, especially if more than one person labels.

Choose classes the eye can separate

If you cannot tell two classes apart from the image, the model cannot either. Merge them, or fix the camera so the difference is visible.

Add backgrounds

Include images that contain none of your classes, from the same place. They cut false alarms. Ten percent of the dataset is a reasonable share.

Balance

A class with ten examples next to one with ten thousand will be found less often. Collect more of the rare class rather than duplicating images.

Tools

fotonet reads labels in the common YOLO text format, so any labeling tool that exports it works. fotonet Studio's Label tab adds a magic wand, auto-labeling with a trained model and a dataset health view. See fotonet Studio.