CoolFace
Datasetpublic

AllanK24/apple-dms-materials-v2

Apple Dense Material Segmentation (DMS) – Stratified 80/10/10 Split A pixel-level material segmentation dataset containing ~41K images with dense annotations across 57 material categories. Originally released by Apple as part of the Dense Material Segmentation (DMS) research project. This version uses a custom stratified 80/10/10 split (vs Apple's original 54/23/23) to maximise training data while maintaining representative validation and test sets. Why a Custom… See the full description on the dataset page: https://huggingface.co/datasets/AllanK24/apple-dms-materials-v2.

sourceHugging Faceapple-asclupdated 8mo agoView on Hugging Face
0likes171downloads
Dataset Card

Apple Dense Material Segmentation (DMS) – Stratified 80/10/10 Split

A pixel-level material segmentation dataset containing ~41K images with dense annotations across 57 material categories. Originally released by Apple as part of the Dense Material Segmentation (DMS) research project.

This version uses a custom stratified 80/10/10 split (vs Apple's original 54/23/23) to maximise training data while maintaining representative validation and test sets.

Why a Custom Split?

Apple's original split reserves nearly half the data for evaluation (23% val + 23% test). Our re-split allocates 80% to training while using stratified sampling (based on the dominant material class per image) to keep val/test distributions aligned with the training set.

Split Quality Comparison

MetricOriginal (Apple)Custom (Stratified)Improvement
Train size22,492 (54%)33,118 (80%)+47% more training data
JSD train↔val0.05240.015870% lower divergence
JSD train↔test0.05260.016369% lower divergence
Classes in all splits53/5753/57Equal coverage
JSD = Jensen-Shannon Divergence between pixel-level class distributions. Lower values mean the evaluation sets better represent the training distribution, leading to more reliable metrics.

Dataset Description

Each sample consists of:

FieldTypeDescription
imagePIL.ImageRGB input image
labelPIL.ImageSingle-channel segmentation mask (pixel values = class indices 0–56)
image_idstringUnique image identifier

Splits

SplitSamplesPercentage
Train33,11880.0%
Validation4,13810.0%
Test4,14010.0%
Total41,396100%

Material Classes (57)

<details> <summary>Click to expand full class list</summary>

IDMaterialIDMaterialIDMaterial
0No label19Gemstone/quartz38Sky
1Animal skin20Glass39Snow
2Bone/teeth/horn21Hair40Soap
3Brickwork22I cannot tell41Soil/mud
4Cardboard23Ice42Sponge
5Carpet/rug24Leather43Stone, natural
6Ceiling tile25Liquid, non-water44Stone, polished
7Ceramic26Metal45Styrofoam
8Chalkboard/blackboard27Mirror46Tile
9Clutter28Not on list47Wallpaper
10Concrete29Paint/plaster/enamel48Water
11Cork/corkboard30Paper49Wax
12Engineered stone31Pearl50Whiteboard
13Fabric/cloth32Photograph/painting51Wicker
14Fiberglass wool33Plastic, clear52Wood
15Fire34Plastic, non-clear53Wood, tree
16Foliage35Rubber/latex54Bad polygon
17Food36Sand55Multiple materials
18Fur37Skin/lips56Asphalt

</details>

Usage

Loading the Dataset

python
from datasets import load_dataset

dataset = load_dataset("AllanK24/apple-dms-materials-v2")

# Access splits
train_ds = dataset["train"]      # 33,118 samples
val_ds = dataset["validation"]   #  4,138 samples
test_ds = dataset["test"]        #  4,140 samples

# View a sample
sample = train_ds[0]
sample["image"].show()    # RGB image
sample["label"].show()    # Segmentation mask

Training with SegFormer / Mask2Former

python
from transformers import SegformerForSemanticSegmentation, SegformerImageProcessorFast
import json
from huggingface_hub import hf_hub_download

# Load class info
class_info_path = hf_hub_download(
    repo_id="AllanK24/apple-dms-materials-v2",
    filename="class_info.json",
    repo_type="dataset",
)
with open(class_info_path) as f:
    class_info = json.load(f)

id2label = {int(k): v for k, v in class_info["id2label"].items()}
label2id = class_info["label2id"]
num_labels = class_info["num_labels"]

# Initialize model
model = SegformerForSemanticSegmentation.from_pretrained(
    "nvidia/segformer-b2-finetuned-ade-512-512",
    num_labels=num_labels,
    id2label=id2label,
    label2id=label2id,
    ignore_mismatched_sizes=True,
)

# Initialize processor
processor = SegformerImageProcessorFast.from_pretrained(
    "nvidia/segformer-b2-finetuned-ade-512-512"
)

# Apply transforms
def transforms(batch):
    images = [x.convert("RGB") for x in batch["image"]]
    labels = [x for x in batch["label"]]
    return processor(images=images, segmentation_maps=labels, return_tensors="pt")

train_ds.set_transform(transforms)

Stratification Method

The split was created using a two-level stratified sampling approach:

  1. 1.Dominant class extraction – For each image, the material class with the most pixels (excluding "No label") is identified.
  2. 2.First split – Images are stratified into 80% train vs 20% eval using StratifiedShuffleSplit.
  3. 3.Second split – The 20% eval pool is stratified 50/50 into validation and test.
  4. 4.Rare class handling – Classes with <5 total images go directly to train; classes with <2 images in the eval pool are randomly assigned between val/test.

Seed: 42 (for reproducibility).

Source & Preparation

  • Original dataset: Apple DMS with images from Open Images V7
  • Original split (v1): AllanK24/apple-dms-materials
  • Preparation pipeline: Download → resize/align (prepare_images.py) → validate (check_images.py, 41,385/41,396 passed) → stratified re-split

Citation

bibtex
@article{upchurch2022dense,
  title={Dense Material Segmentation with Context-Aware Network},
  author={Upchurch, Paul and Niu, Ransen},
  year={2022},
  url={https://machinelearning.apple.com/research/dense-material-segmentation}
}

License

Released under the Apple Sample Code License (ASCL). Source images are from Open Images V7 (primarily CC BY 2.0). See the original repository for full licensing details.