📚 Course contents

AI & Computer Vision, lesson 13 of 52

Train, Validation & Test Splits, and Augmentation

intermediate22 min readFull course

Introduction

You've got labelled frames. Before training, they need splitting into three piles: one to learn from, one to check progress, and one to keep secret for the final test. Split them wrongly and your model will look brilliant in class and fail on match day. Today you'll split the right way, then use augmentation to get more variety out of the same photos.

By the end of this lesson you'll be able to:

  • Explain what the training, validation and test sets are for
  • Split a dataset 70/20/10 by session, so near-identical frames don't leak
  • Keep class proportions similar in each split
  • Choose augmentations that make sense for football (motion blur, brightness, crop, flip) and reject those that don't
  • Apply augmentation only to the training set, with the boxes updated correctly
  • Export the final dataset in YOLO format

Working principle

Three sets, three jobs

SetShareJobWhen it is used
Training70%The model learns from itEvery training step
Validation20%Pick settings, spot overfitting, decide when to stopDuring training
Test10%One final, honest scoreOnce, at the end

Never tune on the test set. If you do, it becomes part of training, and the score lies.

Leakage: split by session, not by frame

From lesson 10: frames from the same video are almost identical. A random split puts a frame in train and its twin in test, and the score is fake.

Each colour is one session: frames a split second apart, nearly identical. Split by frame and 13 training frames are near-copies of test frames: the exam answers leaked.

Fix: keep every frame of one session (one camera position and time, the session id in the file name from lesson 11) together in one split. Then the test set is genuinely new places and moments.

This needs enough sessions. With only 3 sessions you can't make a 70/20/10 split. Aim for at least 10 per class. That is one more reason the field trip uses several camera positions.

Keeping classes balanced

Split each class separately, so every split has players, balls and goals in similar proportions. (This is called a stratified split.)

Augmentation: more variety from the same data

AugmentationFootball useCareful?
Brightness and contrastSun, cloud, floodlightsKeep within real conditions
Motion blurSprinting players, a ball in flightRealistic: use small kernels
Random crop (keeping the boxes)Players at different distancesDon't crop out the object
Horizontal flipPitch viewed from either sideFine for football. Not for text, such as shirt numbers.
RotationSlightly tilted camerasSmall angles only (a few degrees)
Colour swap of kitsNew teamsOptional
Vertical flipNever happens in real footageNo

Rule: only augment the training set. Validation and test must stay as real as possible.

Augmentation must move the boxes too

If you crop or flip an image, the labels must change with it. Libraries such as Albumentations do this when you give them the boxes.

Train, Validation & Test Splits, and Augmentation