Dataset augmentation · YOLO labels follow the picture

Image Dataset Augmenter

Multiply a small image set with random flips, rotations, crops, brightness and contrast changes, noise and blur. Boxes in YOLO label files are moved with every flip and crop, and the sources are split into train, validation and test sets before copying so copies never leak across sets.

Source images

Drop images here or click to choose

PNG, JPG, WEBP, GIF or BMP, up to 25 MB each, 200 images.

Optional: drop YOLO label files

One .txt per image with the same file name, plus classes.txt or data.yaml for class names

Augmentations

Boxes become the bounding box of the rotated corners, so they grow a little.

Crops are zoomed back to full size. Boxes under 40% visible are dropped.

Copies and split

Sources are assigned to a set before copies are made.

The same seed and settings give the same dataset.

Output

Sample copies

Add images to see sample augmentations.

Image Dataset Augmenter

Operator: Abdulla Al Fahad. How tools are built and checked

Forty labeled photos split 70/20/10 land as 28 sources in train, 8 in validation and 4 in test. Making 3 augmented copies plus the original of each gives 160 images: 112 in train, 32 in val and 16 in test. Because the split happens before the copies are made, no validation image is a flipped or darkened copy of a training image, a leak that makes validation scores look better than they are.

The labels follow the picture. A box 128 x 96 at (64, 48) in a 640 x 480 image is at x = 448 after a horizontal flip and at y = 336 after a vertical one. A box of 100 x 100 at (400, 100) becomes 200 x 100 at (160, 100) after a crop to the right half, which is zoomed back to full size: the same transform as the pixels.

A seed makes every random choice repeatable, and a manifest.json in the ZIP records the parameters used for each output.

Key features

  • Random flips, rotation up to 45 degrees, crops down to 40 percent of each side, brightness, contrast, noise and blur
  • Up to 10 copies per image, with the original optionally included
  • YOLO boxes moved through the same flip, rotation and crop as the picture, with clipping and a visibility rule
  • A train, val and test split by source image, a data.yaml and a manifest of every copy's parameters

How copies, boxes and splits are made

Up to 200 source images (PNG, JPG, WEBP, GIF first frame or BMP, 25 MB each) and 1,500 output images per run, with about 600 MB the most the ZIP may reach. Outputs are JPG at quality 92 or PNG, with the long side limited to 640, 1024, 1280 or 1920 px, or the original up to 4096 px. YOLO label files are matched to images by file name, and classes.txt or data.yaml supplies the class names.

The ZIP holds images/train, images/val and images/test, the same tree under labels/ when labels were added, classes.txt, data.yaml (path, train, val, an optional test, nc and names) and manifest.json. Copies are named name_aug1.jpg, name_aug2.jpg and so on, and the original keeps its name. If no validation share is requested, data.yaml points val at the training folder and says so in a comment.

How it works

Each copy draws its parameters from a generator seeded by the seed, the file name and the copy number: a flip with probability one half, and a rotation, crop size and position, brightness, contrast, noise and blur, each uniform up to the limit you set. Pixels are drawn with one transform (flip, rotate about the centre, crop, zoom back to full size) and then the tone, noise and blur steps.

Boxes go through the same transform. The four corners are mapped and the new box is their bounding rectangle, clipped to the picture. A flip or a crop leaves a box exact. A rotation turns it into the bounding box of the rotated corners, which is larger than the object. A box with less than 40 percent of its area left after clipping is dropped.

Sources are shuffled with a seeded generator and dealt to train, val and test by the largest-remainder rule, so the counts add up exactly to the number of sources: 10 sources at 70/20/10 give 7, 2 and 1, and 3 sources give 2, 1 and 0.

Common use cases

  • A 40-photo set of hard hats from a site: 3 copies each with horizontal flip, rotation up to 10 degrees, brightness and contrast up to 20 percent and a crop to at least 75 percent, split 70/20/10, gives 160 images from 40.
  • A classification set with no labels: leave the label files out and the tool still flips, crops and splits, writing images/train, images/val and images/test for a loader that reads those folders.
  • A detector that fails on dark scenes: set brightness up to 50 percent and noise up to 15 and switch rotation off, so boxes stay exact through the flips and crops.

How to use this tool

  1. Add the source images, and optionally the YOLO .txt files and classes.txt or data.yaml.
  2. Switch on the augmentations you want and set their limits; the six sample copies update as you go and draw the moved boxes.
  3. Choose copies per image, the train, val and test percentages, the format and the size.
  4. Press Build dataset; Cancel stops it.

Example

Box x 64, y 48, 128 x 96 in a 640 x 480 image

horizontal flip
vertical flip
rotation by 10 degrees

The box afterwards

x 448, y 48, 128 x 96
x 64, y 336, 128 x 96
x 84.6, y 6.5, 142.7 x 116.8 (the box grows)

Common pitfalls

Boxes under 40 percent visible after a crop are dropped, so a crop can leave an image with fewer labels than the original. Raise the minimum crop size if most of your objects are large.

Corners revealed by a rotation are filled with a flat colour (black, grey or white), and a detector can learn to treat those wedges as a cue. Keep rotation small, or use grey.

A strong blur or heavy noise can make small objects unrecognisable while their boxes stay. Keep blur under 2 px on a 1000 px picture unless blurry objects are what you want to detect.

  • Turn rotation off when box accuracy matters more than variety. Flips and crops keep boxes exact, while a 10 degree rotation turns the 128 x 96 box at (64, 48) into a 143 x 117 box, about 36 percent more area.

Common errors and how to fix them

200 images x 10 outputs is 2000; the limit is 1500
Use fewer copies or fewer source images, or run the set in two batches with different seeds.

Best practices

  • Keep one seed for each dataset release and store it with the manifest; the same seed and settings recreate the same copies.
  • Keep validation honest. If you already have a validation set, build only the training set here with the split 100/0/0 and copy your untouched validation images into images/val yourself.

Frequently asked questions

Why split before augmenting?

Augmented copies of one photo are near-duplicates. If one lands in validation while the original or another copy is in training, the model has effectively seen the validation picture and its score is optimistic. Splitting the sources first keeps every copy of a source in one set.

What happens to a box that a crop cuts in half?

It is clipped to the crop and kept if at least 40 percent of its transformed area is still visible, so a box cut exactly in half stays as a half-box. Under 40 percent the box is dropped from that copy's label file, and the picture is still saved.