Development of an image augmentation pipeline for training a CV model

The model makes mistakes on rare angles and defects, and there are not enough labeled images. We develop a turnkey image augmentation pipeline: we expand the dataset while preserving its realism. This reduces data preparation time and improves model robustness on real-world frames.
Frequently Asked Questions

Image Augmentation: Where Training Breaks on a Small Dataset

Training on a small dataset almost always looks the same: with a few hundred labeled frames, the model trains confidently, but on the holdout set it fails on rare classes.

Formally, the error drops, but the gap between performance on familiar and new examples grows — this is model overfitting, where the network memorizes specific frames instead of object features.

Class imbalance makes the picture worse. When a rare class accounts for fractions of a percent of examples, it is more profitable for the model to predict the frequent one: overall accuracy grows, while recall for the defect or anomaly drops to zero.

Metrics diverge, and the aggregate number hides the fact that the solution does not work where it was intended to.

The cost of such a failure is not just a spoiled iteration. Dataset preparation turns into a manual conveyor: annotators cannot keep up with the task, rare cases have to be hunted down manually, and each next attempt to improve the model hits the same few hundred frames. The team either stops training or releases a model that misses half of the significant objects.

Simple image augmentation alone does not solve the problem. Random rotations, flips, and shifts generate nearly identical frames: the model memorizes the background, lighting, and shooting artifacts, and validation built from the same shots confirms this illusion.

We discuss how this is addressed — from example selection rules and class balancing to monitoring metrics for each class separately.

Measurable Effect: Model Quality, Timelines, Labor Costs

Metrics on the Holdout Set Stop "Floating"

The data augmentation policy is set explicitly: which rotations, scale, shifts, brightness and contrast changes, noise, and blur are acceptable for a specific class. Training runs on the extended set, while validation runs on the holdout set that was not touched by augmentation.

Therefore, the numbers reflect the real quality of the computer vision model, not fitting to the training examples.

Less Manual Labeling for the Same Data Volume

One labeled frame turns into dozens of correct variants — bounding boxes and masks are recalculated along with the image geometry, rather than drawn anew. The share of manual labeling decreases, and annotators' time goes where it is really needed: to rare classes and edge cases.

Robustness to Distortions Instead of Memorizing Shooting Conditions

The model stops relying on specific lighting, angle, or lens quality because it sees these variations during training.

A separate set with distortions shows that the drop when changing the camera, shooting point, or time of day is noticeably smaller than for a model trained on "clean" frames.

Hypothesis Testing Cycle — Hours Instead of Days

The augmentation policy is described by configuration, and the dataset version is reproducible: the same experiment repeats with the same result.

Comparing two augmentation strategies and seeing the difference in metrics can be done in one iteration, not in a week of manual dataset reassembly.

Data Augmentation Methods: Comparison of Approaches

The choice of technique is dictated not by fashion, but by the gap between the training set and what the camera sees in real operation.

Some transformations add diversity with almost no risk, others provide fundamentally new information — but require control of labeling and the share of such examples.

Options and Their Boundaries

Option When Suitable Limitations
Geometric transformations object appears at different angles, and labeling is robust to shift and rotation mirroring and cropping break meaning: text, symbols, asymmetric details, objects at frame boundary
Color distortions shooting with different optics, changing lighting and white balance do not help if the object changes shape or is occluded by others
Noise and blur low light, motion in frame, compression during transmission mask shooting defects but do not replace real frames; strong noise eats small objects
Fragment mixing dense scenes, many objects, scarcity of rare classes unnatural boundaries appear, model calibrates worse, example selection is needed
Synthetic examples rare class, expensive or long collection of real data, need precise parameter control gap between synthetic and reality, risk of overfitting to generator artifacts
Scene simulation rare conditions needed: angles, weather, mutual occlusions of objects high cost of setting up scene and materials, mandatory validation on real frames

In practice, two or three techniques are taken, and their strength is tuned on a control set of real frames. If quality on it drops while quality on augmented data grows, the augmentation is excessive: geometry and synthetic data start replacing object features with artifacts.

Implementation Stages: From Data Audit to Handover to the Team

Augmentation begins not with choosing a transformation library, but with the question of which shooting conditions the model lacks. Therefore, the first step is an inventory of what is already in the dataset, not code. Below is the workflow: each stage ends with an artifact that can be checked and passed on.

  1. Dataset audit. We look at class distribution, duplicates and near-duplicates, corrupted and overexposed frames, and discrepancies in labeling between annotators. The output is a list of defects and an estimate of how many frames are actually suitable for training.
  2. Data preparation scheme and metrics. We fix target metrics — precision and recall by class, false positive rate — and describe the procedure: reading, resizing, normalization, splitting into training, validation, and test parts.
  3. Setup and validation of transformations. We select geometry, color, noise, simulation of lighting and weather. We set ranges conservatively: a transformation should not create an object that is not in the labeling. Then we run each transformation separately and in combination and verify that labels are recalculated correctly and that an object at the frame boundary is not lost.
  4. Validation on control sets. We keep a set that is never augmented and a set of difficult frames — low light, motion, occlusions. They show whether augmentation helps generalization or simply masks overfitting.
  5. Measuring impact on the model. We train the baseline and augmented versions under identical conditions and compare by metrics and by robustness to changes in shooting conditions. We record the gain as a number, not a feeling.
  6. Handover and team training. We provide configurations, launch scripts, and a run log. Reproducibility of experiments rests on the fact that any result is repeated using a fixed set of parameters without manual edits.

Configurations, Schemes, and Regulations: Handover Kit

The handover kit is not an archive with scripts, but working documentation by which the customer's engineer independently reproduces the build and changes parameters without contacting us.

Everything is stored alongside the code: a separate folder with configurations, data flow diagrams, versioning rules, and regulations. Below is what exactly remains with the team after the stage is delivered.

  • Transformation configuration — files with sets of operations (rotations, crop, brightness and contrast changes, noise, blur), value ranges, and application probabilities. A separate profile for each task so that augmentation for detection does not break labeling for classification.
  • Data flow diagrams — how an image travels from source to the finished dataset: where labeling is, where augmentation is applied, where rejection occurs, and what goes into the archive.
  • Dataset versioning rules — manifests with checksums of source and generated datasets, the link "dataset version → model version → metrics." Any experiment is reproduced or rolled back.
  • Data update regulations — how a new batch of images is added, how often augmentation is run, and by what criteria the decision to retrain is made.
  • Data quality control rules — filters for artifacts: blurry frames, duplicates, brightness outliers, labeling violations; rejection thresholds and a report on class distribution.
  • Pipeline documentation — launch order, dependencies, extension points, and analysis of typical failures with signs by which they are recognized.
  • Test set with reference result — a short slice used to check that the environment is assembled correctly and reproduces the expected output.

Case Study: Defect Detection on a Production Line

What Was

A computer vision case study on a production line: there are several types of defects, but microcracks on the edge occurred in about 3 out of 1000 cases — the rare class was drowning in the overall flow of images.

A model trained on the original archive confidently found frequent defects, but for the rare one it held recall at 0.4-0.5.

The cost of error was twofold: a missed crack went into shipment, and the flow of false positives made operators stop reviewing them manually — the signal became devalued.

What Was Changed

The labeling was sorted by type and a balanced sample was assembled: the rare class was supplemented with controlled image augmentation — rotations and reflections at angles acceptable for the edge, changes in contrast and brightness for different lighting zones of the workshop, sensor grain, and local darkening.

Each transformation was checked for physical plausibility: synthetic data should not create a picture that does not occur on the line, otherwise the model learns from invented features and the gain remains only in the report.

Then the trigger threshold was selected using the precision-recall curve, rather than "by eye," and acceptance was carried out according to a regulation agreed with the quality service within the procedures of ISO 9001.

What Happened

Recall for the rare class rose from 0.5 to 0.93, and the share of missed cracks decreased by more than seven times. False positives per shift dropped from about 40 to 6 — the operator again looks at the signal instead of ignoring it.

Retraining was done on data where the rare class is represented fairly, so quality did not drop on new batches.

How Does On-the-Fly Image Augmentation Differ from Precomputed?

On-the-fly augmentation applies transformations to each batch at training time: the same image looks different across epochs, and the dataset is effectively infinite.

Precomputed expansion is a pre-assembled dataset: the originals go through the transformation pipeline once, the result is written to disk, and read as ordinary data.

The key difference is the amount of data storage. The precomputed set grows proportionally to the number of transformations: ten variants per image turn one corpus into ten, plus snapshots for each policy version that are kept while comparisons are ongoing.

With on-the-fly augmentation, only the originals remain on disk, and diversity is set by configuration.

Training speed depends on the balance. On the fly, preparation falls on the CPU: if the reading pipeline cannot keep up with the accelerator, the epoch stretches. With precomputed expansion, the epoch is shorter, but changing the policy means a complete rebuild of the dataset.

A mixed mode often wins: heavy transformations — geometry, fragment cutting, overlay — are computed once and stored next to the original, while cheap ones — brightness, contrast, noise — are applied on the fly.

Diversity across epochs is preserved, and the disk footprint is several times smaller than a full set. Validation is performed without augmentation: only resizing and normalization, otherwise metrics are incomparable between runs.

The criterion is simple: if the policy is still being tuned, we work on the fly; if it is fixed and training is limited by accelerator speed, we pre-assemble the dataset. Libraries like Albumentations switch modes without rewriting code.

Doubts and Limitations: What Is Clarified Before Starting

Before starting, the boundaries of the method are most often clarified: what it takes on and what remains with the data team. Below are questions that arise in almost every image augmentation task, and our answers without rounding.

Will augmentation replace manual labeling?

No. It expands diversity within already labeled classes, but does not create examples of what is not in the dataset. If a class does not appear at all or is labeled inconsistently, no transformation will fix it — labeling or additional frames are needed first.

The dataset is already collected and labeled — will the scheme have to be redone?

We work with what exists: inventory, search for imbalance and noisy labels, then the augmentation rule is applied only to the training part.

We leave validation and test sets untouched, otherwise the metric stops reflecting real data and model quality on new images drops unnoticed.

How to understand that a transformation does not distort the class?

Some operations change the meaning of the label: a strong rotation or crop takes the object out of frame, mirroring breaks asymmetric classes, hue shift confuses classes that differ in color.

We test each transformation on representatives of the class, and narrow parameter ranges based on the result — the share of frames with a lost object remains within labeling error.

Can the scheme be transferred to another task?

The workflow, transformation proportions, and quality control are transferable. The set of operations and ranges are not: they depend on what exactly the model must distinguish. On a new task, we repeat the measurement and rebuild the rule, rather than copying the configuration.

What legal restrictions do we take into account?

Augmentation does not remove license terms: a derivative image remains under the same restrictions as the original. We separately check frames with people, personal and medical data — they require legal grounds for processing. Synthetic data also does not circumvent the prohibition on using a closed image set.

Let's Discuss the Task and Come Back with an Estimate and Plan

Formulating a task for augmentation is not "make more images." First, we need to understand which class of objects the model confuses, what is missing in the dataset, and how we will agree to measure quality.

Therefore, the start of cooperation begins not with a contract, but with an analysis of the input data: this way the project estimate is based on facts, not assumptions.

What to describe or send so that we come back with a plan:

  • current dataset: volume, labeling type, share of rare classes, and typical model errors on holdout examples;
  • 10–20 images where the model errs most often;
  • target metric and how to measure it — recall for the rare class, robustness to changes in shooting conditions;
  • infrastructure constraints: labeling format, data storage rules, access mode to your infrastructure;
  • shooting conditions and equipment — this determines which transformations are acceptable and which will introduce distortions;
  • acceptance mode: frame-by-frame review, metric report, or regular demonstrations of intermediate results.

In response, we send a step-by-step work plan: dataset cleaning and labeling, a set of transformations for your task class, control of synthetic realism, fine-tuning, and comparison with the baseline model. Each stage has an acceptance criterion so that the result is verifiable, not "by eye."

Describe the task in a convenient form — we will come back with an estimate of timelines and a work plan.

AI Development Areas

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1394
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1368
  • B2B Advance company logo design
    B2B Advance company logo design
    815
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1139
  • AIDER company logo development
    AIDER company logo development
    1057
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1152