YOLO Vision 2026:

Cityscapes8 数据集#

简介#

Ultralytics Cityscapes8 数据集是一个紧凑的语义分割数据集,包含从 Cityscapes 数据集中抽样出的 8 张图像:4 张用于训练,4 张用于验证。它专为使用 YOLO 语义分割模型和训练流水线进行快速测试、调试和实验而设计。其城市场景内容在扩展到完整的 Cityscapes 数据集之前,提供了一个有用的流水线检查手段。

Cityscapes8 使用与完整的 Cityscapes 数据集相同的 19 个评估类别以及相同的 label_mapping 行为,并且完全兼容 YOLO26 语义分割工作流。

注意

Cityscapes8 仅用于流水线测试,而非基准测试——其 8 张图像对于有意义的 mIoU 比较来说太少了。请使用完整的 Cityscapes 验证集来获取具有代表性的结果。

数据集结构#

Cityscapes8 镜像了完整数据集的布局,没有 test 拆分:

cityscapes8/
├── images/
│   ├── train/  # 4 images
│   └── val/    # 4 images
└── masks/
    ├── train/  # 4 single-channel PNG masks
    └── val/    # 4 single-channel PNG masks

掩码通过 masks_dir: masks 字段与图像配对,并且 label_mapping 将原始 Cityscapes 标签 ID 转换为完整 Cityscapes 数据集结构中所述的 19 个连续训练 ID。

数据集 YAML#

Cityscapes8 数据集配置定义在一个数据集 YAML 文件中,该文件指定了数据集路径、类名和其他重要元数据。你可以在 Ultralytics GitHub repository 中查看官方的 cityscapes8.yaml 文件。该 YAML 包含一个小打包子集的下载 URL。

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

# Cityscapes semantic segmentation dataset (19 classes)
# Documentation: https://docs.ultralytics.com/datasets/semantic/cityscapes8
# Example usage: yolo semantic train data=cityscapes8.yaml model=yolo26n-sem.pt
# parent
# ├── ultralytics
# └── datasets
#     └── cityscapes8 ← downloads here (small subset)
#         └── images
#         └── masks

# Dataset root directory
path: cityscapes8 # dataset root dir
train: images/train # train images (relative to 'path') 4 images
val: images/val # val images (relative to 'path') 4 images

masks_dir: masks # semantic mask directory

# Cityscapes 19-class labels
names:
  0: road
  1: sidewalk
  2: building
  3: wall
  4: fence
  5: pole
  6: traffic light
  7: traffic sign
  8: vegetation
  9: terrain
  10: sky
  11: person
  12: rider
  13: car
  14: truck
  15: bus
  16: train
  17: motorcycle
  18: bicycle

# Map source label IDs to train IDs; ignore_label is converted to 255.
label_mapping:
  -1: ignore_label
  0: ignore_label
  1: ignore_label
  2: ignore_label
  3: ignore_label
  4: ignore_label
  5: ignore_label
  6: ignore_label
  7: 0
  8: 1
  9: ignore_label
  10: ignore_label
  11: 2
  12: 3
  13: 4
  14: ignore_label
  15: ignore_label
  16: ignore_label
  17: 5
  18: ignore_label
  19: 6
  20: 7
  21: 8
  22: 9
  23: 10
  24: 11
  25: 12
  26: 13
  27: 14
  28: 15
  29: ignore_label
  30: ignore_label
  31: 16
  32: 17
  33: 18

# Download URL (optional)
download: https://github.com/ultralytics/assets/releases/download/v0.0.0/cityscapes8.zip

用法#

若要以 1024 的图像大小在 Cityscapes8 数据集上训练 YOLO26n-sem 模型 100 个轮次,请使用以下示例。有关训练选项的完整列表,请参阅 YOLO 训练文档

训练示例
from ultralytics import YOLO

# Load a pretrained YOLO26n-sem model
model = YOLO("yolo26n-sem.pt")

# Train the model on Cityscapes8
results = model.train(data="cityscapes8.yaml", epochs=100, imgsz=1024)

你还可以使用 Ultralytics Platform 在云端管理 Cityscapes8 并训练语义分割模型。

引用、许可和致谢#

Cityscapes8 采样自 Cityscapes,后者根据自定义非商业许可证发布——详情请参阅完整的 Cityscapes 数据集页面

如果你在研究或开发中使用 Cityscapes 数据集,请引用以下论文:

引用
@inproceedings{Cordts2016Cityscapes,
  title={The Cityscapes Dataset for Semantic Urban Scene Understanding},
  author={Cordts, Marius and Omran, Mohamed and Ramos, Sebastian and Rehfeld, Timo and Enzweiler, Markus and Benenson, Rodrigo and Franke, Uwe and Roth, Stefan and Schiele, Bernt},
  booktitle={Proc. of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2016}
}

特别感谢 Cityscapes 团队对自动驾驶和计算机视觉社区的持续贡献。

常见问题解答#

Ultralytics Cityscapes8 数据集有什么用途?#

Ultralytics Cityscapes8 数据集专为快速测试和调试 semantic segmentation 模型而设计。它仅包含 8 张图像(4 张用于训练,4 张用于验证),非常适合在扩展到完整的 Cityscapes 数据集之前,验证 YOLO 语义分割流水线,包括掩码加载、增强、验证和导出路径。探索 Cityscapes8 YAML configuration 以了解更多详细信息。

Cityscapes8 与完整的 Cityscapes 数据集有何区别?#

Cityscapes8 从 Cityscapes 的 2,975 个训练/500 个验证拆分中采样了 8 个图像(4 个训练,4 个验证),使用了相同的 19 个类别和 label_mapping,因此在 Cityscapes8 上运行的流水线可以在完整数据集上无修改地运行——只需将 data= 指向 cityscapes.yaml 而不是 cityscapes8.yaml。与完整数据集不同,Cityscapes8 没有手动下载步骤,也没有 test 拆分。

如何使用 Cityscapes8 数据集训练 YOLO26 模型?#

你可以使用 Python 或 CLI 在 Cityscapes8 上训练 YOLO26 语义分割模型:

训练示例
from ultralytics import YOLO

# Load a pretrained YOLO26n-sem model
model = YOLO("yolo26n-sem.pt")

# Train the model on Cityscapes8
results = model.train(data="cityscapes8.yaml", epochs=100, imgsz=1024)

有关其他训练选项,请参考 YOLO 训练文档

我应该使用 Cityscapes8 进行基准测试吗?#

不能。Cityscapes8 对于有意义的模型比较来说太小了,仅用于训练和评估流水线检查。当你需要用于语义分割的代表性基准测试结果时,请使用完整的 Cityscapes 验证集。

评论