language:en license:mit region:us
---
license: mit
language:
- en
---

Load COCO Stuff dataset from local directory.

Usage:
```python
from datasets import load_dataset
name = "stuff-only"  # choose from ["stuff-only", "stuff-thing"]
DATA_DIR = "/path/to/COCOStuff"
split = "val"  # choose from ["train", "val"]
ds = load_dataset("yiqun/coco_stuff", name=name, data_dir=DATA_DIR, split=split)
```

Structure of `DATA_DIR`:
```
|_ annotations
  |_ # images
|_ images
  |_ # images
|_ labels.txt
|_ stuff_train2017.json
|_ stuff_val2017.json
```

**NOTE**: This script returns the path to image and stuff-thing segmentation maps to reduce the dataset generation time, users need to read them. Also, according to the official README:

> **Caffe-compatible stuff-thing maps**. We suggest using the stuffthingmaps, as they provide all stuff and thing labels in a single .png file per image. Note that the .png files are indexed images, which means they store only the label indices and are typically displayed as grayscale images. To be compatible with most Caffe-based semantic segmentation methods, **thing+stuff labels cover indices 0-181 and 255 indicates the 'unlabeled' or void class**.

