A
SegFormer-B0 model fine-tuned on
Cityscapes for
7-class semantic segmentation of road scenes. This model uses a purpose-built taxonomy where every class maps directly to a game element — road texture, sky backdrop, tree sprites, building silhouettes, etc.
1from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
2from PIL import Image
3import torch
4import torch.nn.functional as F
5
6processor = SegformerImageProcessor.from_pretrained("Marco333/segformer-b0-road-scene-7class")
7model = SegformerForSemanticSegmentation.from_pretrained("Marco333/segformer-b0-road-scene-7class")
8
9image = Image.open("road_photo.jpg")
10inputs = processor(images=image, return_tensors="pt")
11
12with torch.no_grad():
13 outputs = model(**inputs)
14
15# Upsample logits to original image size
16mask = F.interpolate(
17 outputs.logits,
18 size=image.size[::-1], # (H, W)
19 mode="bilinear",
20 align_corners=False,
21).argmax(dim=1)[0]
22
23# mask values: 0=road, 1=sidewalk, 2=building, 3=vegetation, 4=sky, 5=vehicle, 6=roadside_object
Chris1/cityscapes_segmentation — urban street scenes from 50 European cities.
The model converges quickly thanks to transfer learning — the pretrained encoder already understands road scene features; only the 7-class decoder head is learned from scratch.
1@misc{corbetta_segformer_road_scene_7class_2026,
2 author = {Marco Corbetta},
3 title = {segformer-b0-road-scene-7class: SegFormer-B0 fine-tuned on Cityscapes for 7-class game-asset segmentation},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/Marco333/segformer-b0-road-scene-7class}}
7}
1@inproceedings{xie2021segformer,
2 title={SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers},
3 author={Xie, Enze and Wang, Wenhai and Yu, Zhiding and Anandkumar, Anima and Alvarez, Jose M and Luo, Ping},
4 booktitle={NeurIPS},
5 year={2021}
6}