docs/en/datasets/detect/coco12-formats.md
The Ultralytics COCO12-Formats dataset is a specialized test dataset designed to validate image loading across all 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:
The dataset includes one image for each of the 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"
```
Some formats require additional dependencies:
pip install pillow pillow-heif pillow-avif-plugin
For OpenCV to read AVIF files directly, libavif must be installed before building OpenCV:
=== "macOS"
```bash
brew install libavif
```
=== "Ubuntu/Debian"
```bash
sudo apt install libavif-dev libavif-bin
```
=== "From Source"
```bash
git clone -b v1.2.1 https://github.com/AOMediaCodec/libavif.git
cd libavif
cmake -B build -DAVIF_CODEC_AOM=SYSTEM -DAVIF_BUILD_APPS=ON
cmake --build build --config Release --parallel
sudo cmake --install build
```
!!! note
The pip-installed `opencv-python` package may not include AVIF support since it's pre-built. Ultralytics uses Pillow with `pillow-avif-plugin` as a fallback for AVIF images when OpenCV lacks support.
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 all 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. Requires pillow-avif-plugin:
pip install pillow-avif-plugin
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.
HEIC requires the pillow-heif package for proper encoding:
pip install pillow-heif
from ultralytics import YOLO
def test_all_image_formats():
"""Test that all 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 formats are represented
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"Missing formats: {IMG_FORMATS - found_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 all 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:
pillow-avif-pluginpillow-heif