Dataset COCO12-Formats

Introduzione

Il dataset COCO12-Formats di Ultralytics è un dataset di test specializzato progettato per convalidare il caricamento delle immagini per tutte le 12 estensioni di formato immagine supportate. Contiene 12 immagini (6 per l'addestramento, 6 per la convalida), ciascuna salvata in un formato diverso per garantire un test completo della pipeline di caricamento delle immagini.

Questo dataset è prezioso per:

  • Test del supporto ai formati immagine: Verifica che tutti i formati supportati vengano caricati correttamente
  • Pipeline CI/CD: Test automatizzati della compatibilità dei formati
  • Debug: Isolare problemi specifici del formato nelle pipeline di addestramento
  • Sviluppo: Convalidare l'aggiunta o le modifiche di nuovi formati

Formati supportati

Il dataset include un'immagine per ciascuna delle 12 estensioni di formato supportate definite in ultralytics/data/utils.py:

FormatoEstensioneDescrizioneTrain/Val
AVIF.avifAV1 Image File Format (moderno)Train
BMP.bmpBitmap - formato raster non compressoTrain
DNG.dngDigital Negative - formato RAW di AdobeTrain
HEIC.heicHigh Efficiency Image CodingTrain
JPEG.jpegJPEG con estensione completaTrain
JPG.jpgJPEG con estensione breveTrain
JP2.jp2JPEG 2000 - medico/geospazialeVal
MPO.mpoMulti-Picture Object (immagini stereo)Val
PNG.pngPortable Network GraphicsVal
TIF.tifTIFF con estensione breveVal
TIFF.tiffTagged Image File FormatVal
WebP.webpFormato immagine web modernoVal

Struttura del dataset

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

YAML del dataset

Il dataset COCO12-Formats è configurato utilizzando un file YAML che definisce i percorsi del dataset e i nomi delle classi. Puoi consultare il file ufficiale coco12-formats.yaml nel repository GitHub di Ultralytics.

ultralytics/cfg/datasets/coco12-formats.yaml
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license

# COCO12-Formats dataset (12 images testing all supported image formats) by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/detect/coco12-formats/
# Example usage: yolo train data=coco12-formats.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── coco12-formats ← downloads here (1 MB)

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco12-formats # dataset root dir
train: images/train # train images (relative to 'path') 6 images
val: images/val # val images (relative to 'path') 6 images
test: # test images (optional)

# Classes
names:
  0: person
  1: bicycle
  2: car
  3: motorcycle
  4: airplane
  5: bus
  6: train
  7: truck
  8: boat
  9: traffic light
  10: fire hydrant
  11: stop sign
  12: parking meter
  13: bench
  14: bird
  15: cat
  16: dog
  17: horse
  18: sheep
  19: cow
  20: elephant
  21: bear
  22: zebra
  23: giraffe
  24: backpack
  25: umbrella
  26: handbag
  27: tie
  28: suitcase
  29: frisbee
  30: skis
  31: snowboard
  32: sports ball
  33: kite
  34: baseball bat
  35: baseball glove
  36: skateboard
  37: surfboard
  38: tennis racket
  39: bottle
  40: wine glass
  41: cup
  42: fork
  43: knife
  44: spoon
  45: bowl
  46: banana
  47: apple
  48: sandwich
  49: orange
  50: broccoli
  51: carrot
  52: hot dog
  53: pizza
  54: donut
  55: cake
  56: chair
  57: couch
  58: potted plant
  59: bed
  60: dining table
  61: toilet
  62: tv
  63: laptop
  64: mouse
  65: remote
  66: keyboard
  67: cell phone
  68: microwave
  69: oven
  70: toaster
  71: sink
  72: refrigerator
  73: book
  74: clock
  75: vase
  76: scissors
  77: teddy bear
  78: hair drier
  79: toothbrush

# Download script/URL (optional)
download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco12-formats.zip

Requisiti

Alcuni formati richiedono dipendenze aggiuntive:

pip install pillow pillow-heif pillow-avif-plugin

Libreria di sistema AVIF (Opzionale)

Affinché OpenCV possa leggere direttamente i file AVIF, libavif deve essere installato prima di compilare OpenCV:

brew install libavif
Nota

Il pacchetto opencv-python installato tramite pip potrebbe non includere il supporto AVIF poiché è pre-compilato. Ultralytics utilizza Pillow con pillow-avif-plugin come fallback per le immagini AVIF quando OpenCV non dispone del supporto.

Utilizzo

Per addestrare un modello YOLO sul dataset COCO12-Formats, utilizza i seguenti esempi:

Esempio di training
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)

Note specifiche sul formato

AVIF (AV1 Image File Format)

AVIF è un formato immagine moderno basato sul codec video AV1, che offre un'eccellente compressione. Richiede pillow-avif-plugin:

pip install pillow-avif-plugin

DNG (Digital Negative)

DNG è il formato RAW aperto di Adobe basato su TIFF. A fini di test, il dataset utilizza file basati su TIFF con l'estensione .dng.

JP2 (JPEG 2000)

JPEG 2000 è uno standard di compressione delle immagini basato su wavelet che offre una compressione e una qualità migliori rispetto al JPEG tradizionale. È comunemente usato nell'imaging medico (DICOM), nelle applicazioni geospaziali e nel cinema digitale. Supportato nativamente sia da OpenCV che da Pillow.

MPO (Multi-Picture Object)

I file MPO sono utilizzati per immagini stereoscopiche (3D). Il dataset archivia dati JPEG standard con l'estensione .mpo per il test del formato.

HEIC (High Efficiency Image Coding)

HEIC richiede il pacchetto pillow-heif per una codifica corretta:

pip install pillow-heif

Casi d'Uso

Test CI/CD

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

Convalida del formato

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}"

Citazioni e ringraziamenti

Se utilizzi il dataset COCO nella tua ricerca, cita:

Citazione
@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}
}

FAQ

A cosa serve il dataset COCO12-Formats?

Il dataset COCO12-Formats è progettato per testare la compatibilità del formato immagine nelle pipeline di addestramento YOLO di Ultralytics. Garantisce che tutti i 12 formati immagine supportati (AVIF, BMP, DNG, HEIC, JP2, JPEG, JPG, MPO, PNG, TIF, TIFF, WebP) vengano caricati ed elaborati correttamente.

Perché testare formati immagine multipli?

Diversi formati immagine hanno caratteristiche uniche (compressione, profondità di bit, spazi colore). Testare tutti i formati garantisce:

  • Codice di caricamento immagini robusto
  • Compatibilità tra diversi dataset
  • Rilevamento precoce di bug specifici del formato

Quali formati richiedono dipendenze speciali?

  • AVIF: Richiede pillow-avif-plugin
  • HEIC: Richiede pillow-heif

Commenti