docs/en/datasets/detect/coco12-formats.md
The Ultralytics COCO12-Formats dataset is a specialized test dataset designed to validate image loading across 12 supported image format extensions. It contains 12 images (6 for training, 6 for validation), each saved in a different format to ensure comprehensive testing of the image loading pipeline.
This dataset is invaluable for:
When you manage datasets on Ultralytics Platform, images in any of these formats are handled automatically—no manual conversion required.
The dataset includes one image for each of 12 supported format extensions defined in ultralytics/data/utils.py:
| Format | Extension | Description | Train/Val |
|---|---|---|---|
| AVIF | .avif | AV1 Image File Format (modern) | Train |
| BMP | .bmp | Bitmap - uncompressed raster format | Train |
| DNG | .dng | Digital Negative - Adobe RAW format | Train |
| HEIC | .heic | High Efficiency Image Coding | Train |
| JPEG | .jpeg | JPEG with full extension | Train |
| JPG | .jpg | JPEG with short extension | Train |
| JP2 | .jp2 | JPEG 2000 - medical/geospatial | Val |
| MPO | .mpo | Multi-Picture Object (stereo images) | Val |
| PNG | .png | Portable Network Graphics | Val |
| TIF | .tif | TIFF with short extension | Val |
| TIFF | .tiff | Tagged Image File Format | Val |
| WebP | .webp | Modern web image format | Val |
coco12-formats/
├── images/
│ ├── train/ # 6 images (avif, bmp, dng, heic, jpeg, jpg)
│ └── val/ # 6 images (jp2, mpo, png, tif, tiff, webp)
├── labels/
│ ├── train/ # Corresponding YOLO format labels
│ └── val/
└── coco12-formats.yaml # Dataset configuration
The COCO12-Formats dataset is configured using a YAML file that defines dataset paths and class names. You can review the official coco12-formats.yaml file in the Ultralytics GitHub repository.
!!! example "ultralytics/cfg/datasets/coco12-formats.yaml"
```yaml
--8<-- "ultralytics/cfg/datasets/coco12-formats.yaml"
```
No manual setup is needed. OpenCV reads most formats directly, and Ultralytics falls back to Pillow for AVIF, HEIC, and HEIF. AVIF is decoded natively by Pillow 11.3 or newer, so upgrade Pillow if AVIF files fail to load, and HEIC/HEIF decoding installs the lightweight pi-heif package automatically on first use.
The COCO12-Formats dataset (1 MB) downloads automatically the first time you start training. To train a YOLO model on the COCO12-Formats dataset, use the following examples:
!!! example "Train Example"
=== "Python"
```python
from ultralytics import YOLO
# Load a pretrained YOLO model
model = YOLO("yolo26n.pt")
# Train on COCO12-Formats to test 12 supported image formats
results = model.train(data="coco12-formats.yaml", epochs=1, imgsz=640)
```
=== "CLI"
```bash
# Train YOLO on COCO12-Formats
yolo detect train data=coco12-formats.yaml model=yolo26n.pt epochs=1 imgsz=640
```
AVIF is a modern image format based on the AV1 video codec, offering excellent compression. Ultralytics decodes it through Pillow 11.3 or newer when OpenCV lacks AVIF support, with no extra packages required.
DNG is Adobe's open RAW format based on TIFF. For testing purposes, the dataset uses TIFF-based files with the .dng extension.
JPEG 2000 is a wavelet-based image compression standard offering better compression and quality than traditional JPEG. Commonly used in medical imaging (DICOM), geospatial applications, and digital cinema. Natively supported by both OpenCV and Pillow.
MPO files are used for stereoscopic (3D) images. The dataset stores standard JPEG data with the .mpo extension for format testing.
Both .heic and .heif extensions reference the same ISO/IEC 23008-12 container. By convention, .heic denotes HEVC-encoded HEIF files (the variant produced by Apple devices), while .heif is the broader umbrella extension.
Ultralytics decodes both via the OpenCV → Pillow fallback in ultralytics/utils/patches.py, which auto-installs pi-heif (lightweight, decode-only) on first use — no manual setup required for reading. To produce HEIC/HEIF files yourself (e.g., re-encoding sample images), install the full pillow-heif package, which includes encoders:
pip install pillow-heif
from ultralytics import YOLO
def test_image_formats():
"""Test that 12 supported image formats load correctly."""
model = YOLO("yolo26n.pt")
results = model.train(data="coco12-formats.yaml", epochs=1, imgsz=64)
assert results is not None
from pathlib import Path
from ultralytics.data.utils import IMG_FORMATS
# Verify all dataset formats are supported
dataset_dir = Path("datasets/coco12-formats/images")
found_formats = {f.suffix[1:].lower() for f in dataset_dir.rglob("*.*")}
assert found_formats <= IMG_FORMATS, f"Unsupported formats: {found_formats - IMG_FORMATS}"
If you use the COCO dataset in your research, please cite:
!!! quote ""
=== "BibTeX"
```bibtex
@misc{lin2015microsoft,
title={Microsoft COCO: Common Objects in Context},
author={Tsung-Yi Lin and Michael Maire and Serge Belongie and Lubomir Bourdev and Ross Girshick and James Hays and Pietro Perona and Deva Ramanan and C. Lawrence Zitnick and Piotr Doll{\'a}r},
year={2015},
eprint={1405.0312},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```
The COCO12-Formats dataset is designed for testing image format compatibility in Ultralytics YOLO training pipelines. It ensures 12 supported image formats (AVIF, BMP, DNG, HEIC, JP2, JPEG, JPG, MPO, PNG, TIF, TIFF, WebP) load and process correctly.
Different image formats have unique characteristics (compression, bit depth, color spaces). Testing all formats ensures:
None need manual installation. AVIF is decoded natively by Pillow 11.3 or newer, and HEIC/HEIF decoding installs pi-heif automatically on first use. Install the full pillow-heif package only if you need to write HEIC/HEIF files yourself.