COCO8-Grayscale 数据集#
简介#
Ultralytics COCO8-Grayscale 数据集是一个小巧但强大的目标检测数据集,由 COCO train 2017 集的前 8 张图片组成并转换为灰度格式——其中 4 张用于训练,4 张用于验证。该数据集专门设计用于对 YOLO 灰度模型和训练流程进行快速测试、调试和实验。它的小尺寸使其非常易于管理,而其多样性确保了它在扩展到更大数据集之前能够作为一个有效的健全性检查。
Watch: How to Train Ultralytics YOLO on Grayscale and Multispectral Datasets | Multi-Channel VisionAI 🚀
数据集结构#
COCO8-Grayscale 与 COCO8 相似——即 COCO train 2017 集的前 8 张图片,在所有 80 个 COCO 对象类别中分为 4 张用于训练和 4 张用于验证——但每张图片都以单通道(channels: 1)灰度图像的形式存储在 YOLO 标签格式中:
coco8-grayscale/
├── images/
│ ├── train/ # 4 images
│ └── val/ # 4 images
└── labels/
├── train/
└── val/在 Ultralytics 平台上探索 COCO8-Grayscale,以浏览带有标注叠加层的每张图片,在图表标签页中查看类别分布和边界框热力图,并将其克隆以在云端训练你自己的模型。
数据集 YAML#
COCO8-Grayscale 数据集配置定义在一个 YAML 文件中,该文件指定了数据集路径、类别名称以及其他重要的元数据。你可以在 Ultralytics GitHub 仓库中查看官方的 coco8-grayscale.yaml 文件。
要在灰度中训练你的 RGB 图像,你只需将 channels: 1 添加到你的数据集 YAML 文件中。这会在训练期间将所有图像转换为灰度,使你无需单独的数据集即可利用灰度的好处。
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# COCO8-Grayscale dataset (first 8 images from COCO train2017) by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/detect/coco8-grayscale
# Example usage: yolo train data=coco8-grayscale.yaml
# parent
# ├── ultralytics
# └── datasets
# └── coco8-grayscale ← 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: coco8-grayscale # dataset root dir
train: images/train # train images (relative to 'path') 4 images
val: images/val # val images (relative to 'path') 4 images
test: # test images (optional)
channels: 1
# 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/coco8-grayscale.zip用法#
COCO8-Grayscale 数据集(1 MB)在你第一次开始训练时会自动下载。要在 COCO8-Grayscale 上训练一个 YOLO26n 模型,训练 100 个轮次,图像大小为 640,请使用以下示例。有关训练选项的完整列表,请参阅 YOLO 训练文档。
from ultralytics import YOLO
# Load a pretrained YOLO26n model
model = YOLO("yolo26n.pt")
# Train the model on COCO8-Grayscale
results = model.train(data="coco8-grayscale.yaml", epochs=100, imgsz=640)样本图像和标注#
以下是来自 COCO8-Grayscale 数据集的马赛克训练批次示例:
- 马赛克图像:此图像展示了一个训练批次,其中通过马赛克增强将多个数据集图像组合在一起。马赛克增强增加了每个批次内对象和场景的多样性,有助于模型更好地泛化到各种对象尺寸、纵横比和背景。
这种技术对于像 COCO8-Grayscale 这样的小型数据集特别有用,因为它能在训练过程中最大化每张图像的价值。
引用与致谢#
如果你在研究或开发中使用了 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}
}常见问题解答#
Ultralytics COCO8-Grayscale 数据集的用途是什么?#
目标检测模型的快速测试和调试。凭借仅 8 张图片(4 张用于训练,4 张用于验证),它是验证你的 YOLO 训练流程并在扩展到更大数据集之前确保一切按预期工作的理想选择。探索 COCO8-Grayscale YAML 配置以了解更多详情。
如何使用 COCO8-Grayscale 数据集训练 YOLO26 模型?#
你可以使用 Python 或 CLI 在 COCO8-Grayscale 上训练 YOLO26 模型:
from ultralytics import YOLO
# Load a pretrained YOLO26n model
model = YOLO("yolo26n.pt")
# Train the model on COCO8-Grayscale
results = model.train(data="coco8-grayscale.yaml", epochs=100, imgsz=640)有关其他训练选项,请参考 YOLO 训练文档。
在 COCO8-Grayscale 数据集训练中使用马赛克增强有什么好处?#
马赛克增强在 COCO8-Grayscale 训练中使用,在每个批次中将多张图片组合成一张。这增加了对象和背景的多样性,帮助你的 YOLO 模型更好地泛化到新场景。马赛克增强对小型数据集特别有价值,因为它能最大化每个训练步骤中可用的信息。有关这方面的更多信息,请参阅训练指南。
如何验证我在 COCO8-Grayscale 数据集上训练的 YOLO26 模型?#
在 COCO8-Grayscale 上训练后,要验证你的 YOLO26 模型,请在 Python 或 CLI 中使用模型的验证命令。这会使用标准指标评估你的模型性能。有关分步说明,请访问 YOLO 验证文档。