License YOLO
Back to Ultralytics Glossary

MixUp

MixUp blends training examples and their targets to reduce overfitting. It creates soft class labels for classification and keeps boxes for detection.

MixUp is a data augmentation technique that blends two training examples into one and combines their targets. In image classification, the same ratio controls both blends: if one image contributes 70% of the pixel blend, its class gets 70% of the target weight. Training on these in-between examples encourages the model's predictions to change gradually between samples.

How MixUp Works#

Standard MixUp draws a weight between zero and one from a symmetric Beta distribution parameterized by alpha. Below 1, draws favor the endpoints, so one image typically dominates. At 1, intervals of equal width are equally likely. Above 1, draws concentrate near 0.5, producing more even blends. The mixing ratio determines how much each sample contributes; a separate application probability, when available, determines how often the transform runs.

Hongyi Zhang, Moustapha Cissé, Yann N. Dauphin, and David Lopez-Paz introduced the technique in mixup: Beyond Empirical Risk Minimization, first posted in 2017 and presented at ICLR 2018. In their 200-epoch CIFAR-10 experiment with a pre-activation ResNet-18 and weight decay of 0.0001, MixUp with alpha=1 reduced the median test error over the final 10 epochs from 5.53% to 4.24%.

CIFAR-10 preview 1
CIFAR-10 preview 2
CIFAR-10 preview 3
CIFAR-10 preview 4
60,000
CIFAR-10
ultralytics
PublicClassify

Tiny 32x32 color photos of common vehicles and animals, the classic small-image classification benchmark from the University of Toronto. Collected by Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton as a hand-labeled subset of the 80 Million Tiny Images collection, with balanced, mutually exclusive classes. Source: Krizhevsky, "Learning Multiple Layers of Features from Tiny Images," University of Toronto tech report 2009; cs.toronto.edu/~kriz/cifar.html.

110 classes66 MBOct 23, 2026
airplaneautomobilebirdcat+6
image-classificationcifar10object-recognition+1

MixUp for Image Classification#

An image classification label is often stored as an integer class ID. MixUp combines class vectors instead: when the images come from different classes, the result is a soft target with two weights that sum to one. When both images belong to the same class, that class keeps its full weight. With cross-entropy loss, using the soft target is equivalent to computing the loss against each original label from the same blended-image prediction, then taking a weighted sum of the two losses.

Torchvision's batch MixUp transform applies a shared mixing weight across a batch. The example uses the cat and coffee images from scikit-image's sample collection.

import torch
from skimage import data
from torchvision.transforms import v2

resize = v2.Resize((128, 128))
to_image = v2.ToImage()
cat = resize(to_image(data.chelsea()))
coffee = resize(to_image(data.coffee()))
images = torch.stack((cat, coffee)).float() / 255
labels = torch.tensor([0, 1])

mixup = v2.MixUp(alpha=1.0, num_classes=2)
mixed_images, mixed_targets = mixup(images, labels)
print(mixed_targets)

Each printed row shows the cat and coffee weights for one blended image. The weights swap between rows because the transform reverses the roles of the two images in this batch.

How Object Detection Handles Mixed Labels#

An object detection target contains a bounding box and a class for each object. Averaging two boxes could put the resulting box between the objects. Ultralytics YOLO's MixUp transform blends the images while keeping both sets of boxes and class IDs as separate targets. The mixup setting controls how often the transform runs and defaults to 0.0; the pixel ratio is sampled separately from Beta(32, 32), yielding near-even blends, and the close_mosaic training cutoff also switches MixUp off when it takes effect.

How MixUp Compares With Other Augmentations#

MixUp acts as regularization by training the model on combinations of examples it could otherwise memorize. Full-image blending can also create patterns that resemble a third class. In one MNIST experiment, a blend of handwritten digits 1 and 5 resembled an 8, even though the target assigned 53% to 1 and 47% to 5. The image thus provided visual evidence for a class that received zero target weight.

  • CutMix replaces a rectangular region with a patch from another image. In classification, the target weights follow the area each image contributes.
  • Mosaic arranges multiple images on a single canvas and remaps their annotations to the new layout.
  • Label smoothing redistributes some target weight across classes while leaving the input unchanged.

Manifold Mixup moves the interpolation from the raw inputs to a hidden layer of the network. It still uses the same mixing weight for the hidden activations and the class targets.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning