CV Datasets and Annotation

Data decides the quality of every vision model. A mid-sized network with clean, varied, well-labeled images often beats a giant network trained on messy data. Teams that invest early in datasets save weeks of debugging later.

Famous Datasets Worth Knowing

Dataset        Size            Task                       Good for
-------------  --------------  -------------------------  ----------------------
MNIST          70,000 images   digit classification       first experiments
CIFAR-10       60,000 images   10-class classification    small CNN practice
ImageNet       over 1 million  1,000-class classification pretraining
COCO           about 330,000   detection, segmentation    detection benchmarks
Pascal VOC     about 20,000    detection, segmentation    classic comparisons
Open Images    millions        detection, labels          large-scale training

Beginners can download any of these for free and focus on modeling rather than collecting photos.

Types of Labels

Image Labels

One tag per picture, such as "cat" or "defect". Classification needs this label type.

Bounding Boxes

A rectangle around each object plus a class name. Detection models learn from boxes.

Masks

A pixel-by-pixel outline of each object. Segmentation models need masks, and labeling them takes the most time.

Keypoints

Dots placed on joints or landmarks for pose and face tasks.

Label type      Effort per image    Detail
--------------  ------------------  --------
Image label     seconds             lowest
Bounding box    tens of seconds     medium
Keypoints       about a minute      medium
Mask            several minutes     highest

Common Annotation Formats

  • Folder names: one folder per class, the simplest format for classification
  • YOLO text files: one line per box with normalized values
  • Pascal VOC XML: one XML file per image with box coordinates
  • COCO JSON: one large file that holds images, boxes, masks, and categories

Conversion scripts move data between formats, so pick the format your training tool reads.

Annotation Tools

Free tools such as LabelImg, CVAT, and Label Studio let annotators draw boxes and masks in a browser or desktop window. Many tools suggest labels from a pretrained model, and humans correct the suggestions. Correcting costs less time than drawing from zero.

Writing Clear Labeling Rules

Two annotators will disagree unless the guide spells out every case. A good guide answers questions such as these:

  • Does the box include a partly hidden object?
  • How tight should the box sit around the object?
  • Does a reflection in a mirror count as an object?
  • What happens to objects smaller than 20 pixels?

Add picture examples of good and bad boxes. Measure agreement by having two people label the same 50 images and comparing results with IoU.

Splitting Data Correctly

Three separate groups of images serve three jobs.

All labeled images
 |-- Training set    70%   the model learns from these
 |-- Validation set  15%   tune settings during development
 |-- Test set        15%   final report card, touched once
from sklearn.model_selection import train_test_split

train, rest = train_test_split(files, test_size=0.30, random_state=42)
val, test = train_test_split(rest, test_size=0.50, random_state=42)

Avoiding Data Leaks

A leak happens when near-duplicate images land in both training and test sets. The model memorizes them, and the test score looks falsely excellent. Frames from the same video, photos from one session, and augmented copies of one picture must stay together in a single split.

Class Imbalance

Real data rarely arrives in equal portions. A factory may photograph 10,000 good parts and 50 defective ones. Fix imbalance by collecting more rare examples, weighting rare classes more in the loss function, or augmenting the rare class.

Quality Checks Before Training

  • Open a random sample of 100 labeled images and inspect them by eye
  • Count images per class and look for lopsided numbers
  • Search for duplicates using image hashes
  • Check that boxes stay inside the image borders
  • Confirm that lighting and camera types match the deployment setting

Data Rights and Privacy

Use images that you own, that carry a suitable license, or that people consented to share. Remove personal details from filenames and metadata.

Practice Exercise

Photograph 30 coins and 30 buttons. Label each photo by moving it into a folder. Split the folders into training, validation, and test sets with the code above and check that no near-identical photos cross the split.