Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
Cannot load the dataset split (in streaming mode) to extract the first rows.
Error code:   StreamingRowsError
Exception:    ValueError
Message:      Invalid string class label massachusetts-roads@ec8a8893362f56c6f21da57f97e74a9548e81fb5
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/utils.py", line 147, in get_rows_or_raise
                  return get_rows(
                      dataset=dataset,
                  ...<4 lines>...
                      column_names=column_names,
                  )
                File "/src/libs/libcommon/src/libcommon/utils.py", line 272, in decorator
                  return func(*args, **kwargs)
                File "/src/services/worker/src/worker/utils.py", line 127, in get_rows
                  rows_plus_one = list(itertools.islice(safe_iter(ds, dataset=dataset), rows_max_number + 1))
                File "/src/services/worker/src/worker/utils.py", line 483, in safe_iter
                  yield from ds.decode(False) if ds.features else ds
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2840, in __iter__
                  for key, example in ex_iterable:
                                      ^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2386, in __iter__
                  example = _apply_feature_types_on_example(
                      example, self.features, token_per_repo_id=self.token_per_repo_id
                  )
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2303, in _apply_feature_types_on_example
                  encoded_example = features.encode_example(example)
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 2178, in encode_example
                  return encode_nested_example(self, example)
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 1460, in encode_nested_example
                  {k: encode_nested_example(schema[k], obj.get(k), level=level + 1) for k in schema}
                      ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 1483, in encode_nested_example
                  return schema.encode_example(obj) if obj is not None else None
                         ~~~~~~~~~~~~~~~~~~~~~^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 1158, in encode_example
                  example_data = self.str2int(example_data)
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 1095, in str2int
                  output = [self._strval2int(value) for value in values]
                            ~~~~~~~~~~~~~~~~^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/features/features.py", line 1116, in _strval2int
                  raise ValueError(f"Invalid string class label {value}")
              ValueError: Invalid string class label massachusetts-roads@ec8a8893362f56c6f21da57f97e74a9548e81fb5

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Massachusetts Roads Benchmark Dataset

High-resolution aerial imagery benchmark for remote sensing road extraction, based on the canonical Massachusetts Roads dataset introduced by Volodymyr Mnih (2013).

Dataset Overview

The Massachusetts Roads Dataset covers diverse urban, suburban, coastal, and forested rural environments throughout the Commonwealth of Massachusetts.

  • Image Resolution: $1500 \times 1500$ pixels per tile.
  • Ground Sampling Distance (GSD): $1.0\text{ m/pixel}$.
  • Channels: 3-channel RGB optical imagery (*_sat.jpg).
  • Ground Truth: Binary road segmentation masks (*_mask.png), where pixel value 255 (or 1) denotes road corridors rasterized from OpenStreetMap with an approximate line width of 7 pixels, and 0 denotes background.

Benchmark Partition

Standard benchmark partition for road extraction research:

Split Tiles Images Binary Masks Description
Training (train) 540 540 540 Training set partitioned from the standard 600-image training pool (seed 42)
Validation (val) 60 60 60 Held-out validation split for model selection & threshold calibration
Testing (test) 178 178 178 Standard official evaluation benchmark
Total 778 778 778 Full benchmark corpus

Directory Structure

massachusetts/
β”œβ”€β”€ metadata.csv                # Complete index (split, tile_id, image_path, mask_path, resolution)
β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ images/                 # 540 aerial tiles (*_sat.jpg)
β”‚   └── masks/                  # 540 road masks (*_mask.png)
β”œβ”€β”€ val/
β”‚   β”œβ”€β”€ images/                 # 60 aerial tiles (*_sat.jpg)
β”‚   └── masks/                  # 60 road masks (*_mask.png)
└── test/
    β”œβ”€β”€ images/                 # 178 aerial tiles (*_sat.jpg)
    └── masks/                  # 178 road masks (*_mask.png)

Quick Start & Usage

1. Fast Download via Python (huggingface_hub)

import zipfile
from huggingface_hub import hf_hub_download

# Download the complete benchmark archive (~530 MB)
zip_file = hf_hub_download(
    repo_id="lammtfkday/massachusetts-roads",
    filename="datasetmassa.zip",
    repo_type="dataset"
)

# Extract into local data folder
with zipfile.ZipFile(zip_file, "r") as zf:
    zf.extractall("./data")

2. Downloading Individual Splits

from huggingface_hub import hf_hub_download

train_zip = hf_hub_download(repo_id="lammtfkday/massachusetts-roads", filename="train.zip", repo_type="dataset")
val_zip   = hf_hub_download(repo_id="lammtfkday/massachusetts-roads", filename="val.zip", repo_type="dataset")
test_zip  = hf_hub_download(repo_id="lammtfkday/massachusetts-roads", filename="test.zip", repo_type="dataset")

3. PyTorch Dataset Loader

import cv2
import torch
from pathlib import Path
from torch.utils.data import Dataset

class MassachusettsRoadDataset(Dataset):
    def __init__(self, root_dir, split="train", transform=None):
        self.img_dir = Path(root_dir) / split / "images"
        self.mask_dir = Path(root_dir) / split / "masks"
        self.images = sorted(list(self.img_dir.glob("*_sat.jpg")))
        self.transform = transform

    def __len__(self):
        return len(self.images)

    def __getitem__(self, idx):
        img_path = self.images[idx]
        mask_path = self.mask_dir / img_path.name.replace("_sat.jpg", "_mask.png")
        image = cv2.cvtColor(cv2.imread(str(img_path)), cv2.COLOR_BGR2RGB)
        mask = cv2.imread(str(mask_path), cv2.IMREAD_GRAYSCALE)
        mask = (mask > 127).astype("float32")
        if self.transform:
            augmented = self.transform(image=image, mask=mask)
            image, mask = augmented["image"], augmented["mask"]
        return torch.tensor(image).permute(2, 0, 1) / 255.0, torch.tensor(mask).unsqueeze(0)

Citations

If you use this dataset in your research, please cite:

@phdthesis{mnih2013aerial,
  title={Machine Learning for Aerial Image Labeling},
  author={Mnih, Volodymyr},
  year={2013},
  school={University of Toronto}
}
Downloads last month
98