Meet YOLO26: next-gen vision AI.

Link to this sectionCityscapes データセット#

Cityscapes データセットは、ヨーロッパ50都市の市街地シーンを対象とした大規模なセマンティックセグメンテーションベンチマークです。高品質なピクセルレベルのアノテーションを提供しており、Ultralytics YOLO モデルを用いた自動運転研究や都市環境理解において最も広く利用されているデータセットの一つです。

Link to this section主な特徴#

  • Cityscapes の詳細なアノテーションには、学習用画像2,975枚、検証用画像500枚、テスト用画像1,525枚が含まれています。
  • このデータセットは、道路、車両、歩行者、建造物、物体、自然、空のカテゴリーにまたがる19の評価クラスを網羅しています。
  • Cityscapes は、セマンティックセグメンテーション向けの平均Intersection over Union (mIoU) といった標準化された評価指標を提供しており、モデル性能の効率的な比較を可能にします。

Link to this sectionデータセット構造#

Ultralytics の設定では、準備完了後に以下のレイアウトを想定しています:

cityscapes/
├── images/
│   ├── train/
│   ├── val/
│   └── test/
└── masks/
    ├── train/
    ├── val/
    └── test/

セマンティックマスクはシングルチャネルのPNGファイルです。Cityscapes オリジナルのラベルIDは label_mapping セクションを通じて標準の19の学習IDにマッピングされ、無視または無効なラベルは 255 に割り当てられるため、学習や評価から除外されます。Cityscapes ウェブサイトから公式の leftImg8bit および gtFine アーカイブをダウンロードしてデータセットルートに展開してください。その後、cityscapes.yaml の準備ブロックが画像とマスクをこのレイアウトに整理します。

Link to this section用途#

Cityscapes は、セマンティックセグメンテーションにおけるディープラーニングモデルの学習と評価に広く使用されており、特に自動運転、先進運転支援システム (ADAS)、および都市ロボティクスで利用されています。

その高解像度画像と詳細なアノテーションは、リアルタイムのシーン解析、車線や障害物の理解、そして複雑な都市環境における高密度なピクセルレベルの理解を必要とするあらゆるタスクの研究に有用です。

Link to this sectionデータセット YAML#

データセットのYAMLファイルは、Cityscapes のパス、クラス、マスクディレクトリ、およびラベルマッピングを定義します。cityscapes.yaml ファイルは https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/cityscapes.yaml で管理されています。

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

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

# Dataset root directory
path: cityscapes # dataset root dir
train: images/train # train images (relative to 'path') 2975 images
val: images/val # val images (relative to 'path') 500 images
test: images/test # test images (relative to 'path') 1525 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

# Preparation script (requires manual Cityscapes download)
download: |
  from pathlib import Path
  from shutil import copy2

  cityscapes_dir = Path(yaml["path"])  # dataset root dir
  # Download and extract the official Cityscapes leftImg8bit and gtFine archives into cityscapes_dir first.
  leftimg8bit_dir = cityscapes_dir / "leftImg8bit"
  gtfine_dir = cityscapes_dir / "gtFine"

  for split in ("train", "val", "test"):
      print(f"Processing {split} set")
      src_image_dir = leftimg8bit_dir / split
      dst_image_dir = cityscapes_dir / "images" / split
      dst_mask_dir = cityscapes_dir / "masks" / split
      dst_image_dir.mkdir(parents=True, exist_ok=True)
      dst_mask_dir.mkdir(parents=True, exist_ok=True)

      image_paths = sorted(src_image_dir.rglob("*_leftImg8bit.png"))
      for image_path in image_paths:
          relative_path = image_path.relative_to(src_image_dir)
          mask_path = gtfine_dir / split / relative_path.parent / image_path.name.replace(
              "_leftImg8bit.png", "_gtFine_labelIds.png"
          )
          if not mask_path.exists():
              raise FileNotFoundError(f"Mask not found for {image_path}: {mask_path}")

          image_name = image_path.name.replace("_leftImg8bit", "")
          mask_name = mask_path.name.replace("_gtFine_labelIds", "")
          copy2(image_path, dst_image_dir / image_name)
          copy2(mask_path, dst_mask_dir / mask_name)

Link to this section使用方法#

Cityscapes データセットで YOLO26n-sem モデルを画像サイズ1024で100エポック学習するには、以下のコードスニペットを使用できます。利用可能な引数の詳細リストについては、モデルの学習ページを参照してください。

学習例
from ultralytics import YOLO

# Load a model
model = YOLO("yolo26n-sem.pt")  # load a pretrained model (recommended for training)

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

Link to this section引用と謝辞#

研究や開発作業で 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 チームに感謝いたします。Cityscapes データセットとその作成者に関する詳細については、Cityscapes データセットウェブサイトをご覧ください。

Link to this sectionFAQ#

Link to this sectionCityscapes データセットとは何ですか、またなぜコンピュータビジョンにおいて重要なのですか?#

Cityscapes データセットは、ヨーロッパ50都市の市街地シーンを対象とした大規模なセマンティックセグメンテーションベンチマークです。5,000枚の精緻にアノテーションされた画像と19の評価クラスが含まれており、自動運転や都市環境理解の研究において基盤となるリソースです。その高解像度画像、高密度なアノテーション、そして標準化された平均 Intersection over Union (mIoU) 指標は、高密度予測モデルのベンチマークに最適です。

Link to this sectionCityscapes データセットを使用して YOLO モデルを学習するにはどうすればよいですか?#

Cityscapes データセットで YOLO26n-sem モデルを画像サイズ1024で100エポック学習するには、以下のコードスニペットを使用してください。利用可能な引数の詳細リストについては、モデルの学習ページを参照してください。

学習例
from ultralytics import YOLO

# Load a model
model = YOLO("yolo26n-sem.pt")  # load a pretrained model (recommended for training)

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

Link to this sectionCityscapes データセットはどのように構成されていますか?#

準備後、データセットは images/{train,val,test}/ および masks/{train,val,test}/ ディレクトリに構成され、各画像はシングルチャネルのPNGマスクとペアになっています。Ultralytics の YAML ファイルは masks_dir: masks フィールドを通じて各画像とマスクをペアにし、label_mapping を使用してオリジナルの Cityscapes ラベルIDを標準の19の連続した学習IDに変換し、無視または無効なラベルを 255 にマッピングします。

Link to this sectionCityscapes は手動でダウンロードする必要がありますか?#

Yes. Cityscapes requires accepting the dataset terms on the official website. Download and extract leftImg8bit and gtFine into the cityscapes dataset root before using the preparation block in cityscapes.yaml to create the expected images/ and masks/ layout.

Link to this sectionなぜ Cityscapes は label_mapping を使用するのですか?#

Cityscapes のソースマスクには、評価に使用される19の学習IDとは異なるオリジナルのラベルIDが格納されているためです。label_mapping セクションは有効なラベルを連続したクラスID 018 に変換し、無視または無効なラベルに 255 を割り当てることで、学習および検証中の損失計算や指標からそれらを除外します。

コントリビューター

コメント