Link to this sectionCOCO 数据集#
COCO (Common Objects in Context) 数据集是一个大规模的对象检测、分割和图像标注数据集。它旨在鼓励对各种对象类别的研究,并常用于对计算机视觉模型进行基准测试。对于从事对象检测、分割和姿态估计任务的研究人员和开发人员来说,这是一个必不可少的数据集。
Watch: Ultralytics COCO Dataset Overview
Link to this sectionCOCO 预训练模型#
| 模型 | 尺寸 (像素) | mAPval 50-95 | mAPval 50-95(e2e) | 速度 CPU ONNX (ms) | 速度 T4 TensorRT10 (ms) | 参数量 (M) | FLOPs (B) |
|---|---|---|---|---|---|---|---|
| YOLO26n | 640 | 40.9 | 40.1 | 38.9 ± 0.7 | 1.7 ± 0.0 | 2.4 | 5.4 |
| YOLO26s | 640 | 48.6 | 47.8 | 87.2 ± 0.9 | 2.5 ± 0.0 | 9.5 | 20.7 |
| YOLO26m | 640 | 53.1 | 52.5 | 220.0 ± 1.4 | 4.7 ± 0.1 | 20.4 | 68.2 |
| YOLO26l | 640 | 55.0 | 54.4 | 286.2 ± 2.0 | 6.2 ± 0.2 | 24.8 | 86.4 |
| YOLO26x | 640 | 57.5 | 56.9 | 525.8 ± 4.0 | 11.8 ± 0.2 | 55.7 | 193.9 |
Link to this section主要特性#
- COCO 包含 33 万张图像,其中 20 万张图像带有用于对象检测、分割和标注任务的标注信息。
- 该数据集包含 80 个对象类别,包括汽车、自行车和动物等常见对象,以及雨伞、手提包和运动器材等更具体的类别。
- 标注信息包括每张图像的对象边界框、分割掩码和说明文字。
- COCO 提供了标准化的评估指标,例如用于对象检测的 mean Average Precision (mAP),以及用于分割任务的 mean Average Recall (mAR),使其适用于模型性能比较。
Link to this section数据集结构#
COCO 数据集被分为三个子集:
- Train2017:该子集包含 11.8 万张图像,用于训练对象检测、分割和标注模型。
- Val2017:该子集拥有 5000 张图像,用于模型训练期间的验证。
- Test2017: 该子集包含 20K 张用于测试和基准测试已训练模型的图像。该子集的真值标注(Ground truth annotations)并未公开,你需要将结果提交至 COCO evaluation server 进行性能评估。
Link to this section应用#
COCO 数据集广泛用于训练和评估 深度学习 模型,包括目标检测(如 Ultralytics YOLO、Faster R-CNN 和 SSD)、实例分割(如 Mask R-CNN)以及关键点检测(如 OpenPose)。该数据集多样化的目标类别、大量的标注图像以及标准化的评估指标,使其成为计算机视觉研究人员和从业者的重要资源。
Link to this section数据集 YAML#
YAML (Yet Another Markup Language) 文件用于定义数据集配置。它包含了有关数据集路径、类和其他相关信息。对于 COCO 数据集,coco.yaml 文件托管在 https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml。
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# COCO 2017 dataset https://cocodataset.org by Microsoft
# Documentation: https://docs.ultralytics.com/datasets/detect/coco/
# Example usage: yolo train data=coco.yaml
# parent
# ├── ultralytics
# └── datasets
# └── coco ← downloads here (20.1 GB)
# 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: coco # dataset root dir
train: train2017.txt # train images (relative to 'path') 118287 images
val: val2017.txt # val images (relative to 'path') 5000 images
test: test-dev2017.txt # 20288 of 40670 images, submit via https://cocodataset.org/#detection-eval
# 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: |
from pathlib import Path
from ultralytics.utils import ASSETS_URL
from ultralytics.utils.downloads import download
# Download labels
segments = True # segment or box labels
dir = Path(yaml["path"]) # dataset root dir
urls = [ASSETS_URL + ("/coco2017labels-segments.zip" if segments else "/coco2017labels.zip")] # labels
download(urls, dir=dir.parent)
# Download data
urls = [
"http://images.cocodataset.org/zips/train2017.zip", # 19G, 118k images
"http://images.cocodataset.org/zips/val2017.zip", # 1G, 5k images
"http://images.cocodataset.org/zips/test2017.zip", # 7G, 41k images (optional)
]
download(urls, dir=dir / "images", threads=3)Link to this section用法#
若要在 COCO 数据集上训练 YOLO26n 模型 100 个 epoch,且图像大小为 640,你可以使用以下代码片段。有关可用参数的完整列表,请参阅模型 Training 页面。
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="coco.yaml", epochs=100, imgsz=640)Link to this section样本图像和标注#
COCO 数据集包含多种对象类别和复杂场景的多样化图像。以下是来自该数据集的图像示例及其相应的标注:

- 马赛克图像:此图像展示了一个由马赛克数据集图像组成的训练批次。马赛克是一种在训练期间使用的技术,它将多张图像合并为单张图像,以增加每个训练批次中物体和场景的多样性。这有助于提高模型对不同物体尺寸、宽高比和上下文的泛化能力。
该示例展示了 COCO 数据集中图像的多样性和复杂性,以及在训练过程中使用马赛克(mosaicing)技术的好处。
Link to this section引用与致谢#
如果你在研究或开发工作中使用了 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ár},
year={2015},
eprint={1405.0312},
archivePrefix={arXiv},
primaryClass={cs.CV}
}我们要感谢 COCO 联盟为计算机视觉社区创建并维护了这一宝贵资源。有关 COCO 数据集及其创建者的更多信息,请访问 COCO 数据集网站。
Link to this section常见问题解答#
Link to this section什么是 COCO 数据集,为什么它对计算机视觉很重要?#
COCO 数据集 (Common Objects in Context) 是一个用于对象检测、分割和标注的大规模数据集。它包含 33 万张带有 80 个对象类别详细标注的图像,使其成为对计算机视觉模型进行基准测试和训练的重要资源。研究人员使用 COCO 是因为它具有多样化的类别和诸如 mean Average Precision (mAP) 等标准化的评估指标。
Link to this section我该如何使用 COCO 数据集训练 YOLO 模型?#
若要使用 COCO 数据集训练 YOLO26 模型,你可以使用以下代码片段:
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="coco.yaml", epochs=100, imgsz=640)有关可用参数的更多详细信息,请参阅 Training 页面。
Link to this sectionCOCO 数据集的主要特点是什么?#
COCO 数据集包括:
- 33 万张图像,其中 20 万张已标注用于对象检测、分割和标注。
- 80 个对象类别,涵盖从汽车和动物等常见物品到手提包和运动器材等特定物品。
- 针对对象检测 (mAP) 和分割 (mean Average Recall, mAR) 的标准化评估指标。
- 马赛克 (Mosaicing) 技术用于训练批次,以增强模型在各种对象大小和上下文中的泛化能力。
Link to this section在哪里可以找到在 COCO 数据集上训练的预训练 YOLO26 模型?#
在 COCO 数据集上训练的预训练 YOLO26 模型可以从文档中提供的链接下载。示例包括:
这些模型在尺寸、mAP 和推理速度上各不相同,为不同的性能和资源需求提供了多种选择。
Link to this sectionCOCO 数据集是如何构成的,我该如何使用它?#
COCO 数据集被分为三个子集:
- Train2017:11.8 万张用于训练的图像。
- Val2017:5000 张用于训练期间验证的图像。
- Test2017: 20K 张用于基准测试已训练模型的图像。你需要将结果提交至 COCO evaluation server 以进行性能评估。
该数据集的 YAML 配置文件可在 coco.yaml 找到,其中定义了路径、类和数据集详细信息。