跳转至内容

COCO12-格式数据集

简介

The Ultralytics COCO12-Formats数据集是一个专门设计的测试数据集,用于验证所有12种支持的图像格式扩展名的加载情况。该数据集包含12张图像(6张用于训练,6张用于验证),每张图像均以不同格式保存,以确保对图像加载管道进行全面测试。

该数据集对于以下方面具有不可估量的价值:

  • 测试图像格式支持:验证所有支持的格式能否正确加载
  • 持续集成/持续交付管道:格式兼容性的自动化测试
  • 调试:在训练管道中隔离格式特定问题
  • 开发:验证新增或变更的格式

支持的格式

该数据集包含12种支持的格式扩展名,每种扩展名对应一张图像,这些格式扩展名在 ultralytics/data/utils.py:

格式扩展名描述火车/瓦尔
AVIF.avifAV1图像文件格式(现代)训练
BMP.bmp位图 - 未压缩的点阵格式训练
DNG.dng数字负片 - Adobe RAW格式训练
HEIC.heic高效能影像编码训练
JPEG.jpeg带完整扩展名的JPEG文件训练
JPG.jpgJPEG(带短扩展名)训练
JP2.jp2JPEG 2000 - 医疗/地理空间验证
MPO.mpo多图像对象(立体图像)验证
PNG.png便携式网络图形验证
TIF.tifTIFF(带短扩展名)验证
多伦多国际电影节.tiff带标签的图像文件格式验证
WebP.webp现代网络图像格式验证

数据集结构

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

COCO12-Formats数据集通过YAML文件进行配置,该文件定义了数据集路径和类名。您可以查阅官方文档。 coco12-formats.yaml 文件在 Ultralytics GitHub 仓库.

ultralytics.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

数据集生成

该数据集可通过提供的脚本生成,该脚本能COCO8 COCO128 COCO8 源图像转换COCO128 所有支持的格式:

from ultralytics.data.scripts.generate_coco12_formats import generate_coco12_formats

# Generate the dataset
generate_coco12_formats()

要求

某些格式需要额外的依赖项:

pip install pillow pillow-heif pillow-avif-plugin

AVIF系统库(可选)

OpenCV 直接读取AVIF文件, libavif 必须安装 之前 构建OpenCV:

brew install libavif
sudo apt install libavif-dev libavif-bin
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

注意

通过pip安装的 opencv-python 由于该软件包是预编译的,可能不包含AVIF支持。Ultralytics Pillow库, pillow-avif-plugin 当OpenCV AVIF图像时,作为其备用方案。

用法

要在COCO12-Formats数据集上训练YOLO ,请参考以下示例:

训练示例

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)
# Train YOLO on COCO12-Formats
yolo detect train data=coco12-formats.yaml model=yolo26n.pt epochs=1 imgsz=640

格式特定说明

AVIF(AV1图像文件格式)

AVIF是一种基于AV1视频编解码器的现代图像格式,提供卓越的压缩性能。需要 pillow-avif-plugin:

pip install pillow-avif-plugin

DNG(数字负片)

DNG是Adobe基于TIFF开发的开放式RAW格式。为便于测试,本数据集采用基于TIFF的文件格式,其 .dng 扩展。

JP2(JPEG 2000)

JPEG 2000是一种基于小波的图像压缩标准,其压缩率和图像质量均优于传统JPEG格式。该标准广泛应用于医学影像(DICOM)、地理空间应用及数字影院领域。OpenCV 均原生支持该格式。

MPO(多图对象)

MPO文件用于存储立体(3D)图像。该数据集存储标准JPEG数据,并包含 .mpo 格式测试扩展。

HEIC(高效图像编码)

HEIC 需要 pillow-heif 用于正确编码的封装:

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

引用和致谢

若您在研究中COCO ,请引用:

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

常见问题

COCO12-Formats数据集用于什么?

COCO12-Formats数据集专为Ultralytics YOLO 管道中的图像格式兼容性而设计。该数据集确保所有12种支持的图像格式(AVIF、BMP、DNG、HEIC、JP2、JPEG、JPG、MPO、PNG、TIF、TIFF、WebP)均能正确加载和处理。

为何要测试多种图像格式?

不同图像格式具有独特特性(压缩、位深度、色彩空间)。测试所有格式可确保:

  • 健壮的图像加载代码
  • 跨多样化数据集的兼容性
  • 格式特异性缺陷的早期检测

哪些格式需要特殊依赖项?

  • AVIF需要 pillow-avif-plugin
  • HEIC需要 pillow-heif

我可以添加新的格式测试吗?

是的!修改 generate_coco12_formats.py 脚本以包含其他格式。请确保同时更新 IMG_FORMATSultralytics/data/utils.py.



📅 创建于 0 天前 ✏️ 更新于 0 天前
glenn-jocher

评论