---
source: https://iinventedlight.com/library/notes/hf-datasets-semantic-segmentation.md
title: "Prepare semantic segmentation datasets"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/datasets docs); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face (datasets docs), Semantic segmentation · Hugging Face, Apache-2.0 (huggingface/datasets docs); Hugging Face (datasets docs), Process image data · Hugging Face, Apache-2.0 (huggingface/datasets docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched Hugging Face datasets docs pages were read."
category: hf-datasets
topic_area: "code-ai-eng: Hugging Face datasets library"
tags: huggingface, datasets, segmentation, vision
sources:
  - id: S1
    title: "Semantic segmentation · Hugging Face"
    publisher: Hugging Face (datasets docs)
    url: https://huggingface.co/docs/datasets/semantic_segmentation
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
  - id: S2
    title: "Process image data · Hugging Face"
    publisher: Hugging Face (datasets docs)
    url: https://huggingface.co/docs/datasets/image_process
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
---
# Prepare semantic segmentation datasets

## Short answer
Semantic segmentation pairs each image with a mask that labels every pixel. Apply the same geometric augmentation to image and mask together (Albumentations takes both), and run it on the fly with `set_transform()`. [S1][S2]

## Claims
- id: C1
  claim: Segmentation datasets classify every pixel in an image.
  source: S1
  evidence: "Semantic segmentation datasets are used to train a model to classify every pixel in an"
- id: C2
  claim: The annotation is a segmentation mask of the image.
  source: S1
  evidence: "annotation: segmentation mask of the image."
- id: C3
  claim: Augmentations are applied with set_transform().
  source: S2
  evidence: "Apply data augmentations to a dataset with set_transform()."

## Sources
- [S1] Semantic segmentation · Hugging Face. Hugging Face (datasets docs). https://huggingface.co/docs/datasets/semantic_segmentation . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.
- [S2] Process image data · Hugging Face. Hugging Face (datasets docs). https://huggingface.co/docs/datasets/image_process . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
