File size: 3,834 Bytes
eca78de
 
ab48bb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eca78de
ab48bb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
license: apache-2.0
configs:
- config_name: default
  data_files:
  - split: train
    path: train/*.tar
  - split: validation
    path: validation/*.tar
dataset_info:
  features:
  - name: __key__
    dtype: string
  - name: __url__
    dtype: string
  - name: png
    dtype: image
  - name: json
    dtype: string
  splits:
  - name: train
    num_examples: 95150
  - name: validation
    num_examples: 5660
---

# RSReasoner

RSReasoner is a large-scale dataset for geospatial reasoning segmentation, constructed from aerial imagery and OpenStreetMap (OSM) semantics. This repository contains the training and validation splits; the held-out test set is released separately as [RSReasoner-Bench](https://huggingface.co/datasets/RicardoString/RSReasoner-Bench).

## Data scale

| Item | Train | Validation | Total |
|---|---:|---:|---:|
| Targets / images / masks | 95,150 each | 5,660 each | 100,810 each |
| Total query-mask pairs | 190,300 | 11,320 | 201,620 |
| Text answers | 95,150 | 5,660 | 100,810 |
| Area / non-area targets | 48,523 / 46,627 | 2,689 / 2,971 | 51,212 / 49,598 |
| With / without same-category competitors | 27,542 / 67,608 | 2,717 / 2,943 | 30,259 / 70,551 |

All images are RGB PNG files with a resolution of 448 × 448 pixels.

## Fields

Each JSON file describes one target and contains two query types: explicit-inferential (EI) and implicit-inferential (II). Both refer to the same target mask and share one reference answer.

| Field | Type | Description |
|---|---|---|
| `id` | integer | Unique target identifier. |
| `patch_id` | integer | Source image-patch identifier. |
| `file_name` | string | Image path inside the TAR shard, such as `images/000001.png`. |
| `type` | string | Target geometry: `area` or `non-area`. |
| `has_same_category_instance` | integer | `1` if another instance of the same category is present in the image; otherwise `0`. |
| `main_tag` | string | Normalized main OSM tag, expressed as `key=value`. |
| `full_tag` | object | Original OSM key-value dictionary; keys and values are strings. |
| `mask_rle` | object | COCO compressed RLE: `size` is `[height, width]`, and `counts` is a string. |
| `bbox` | array | Target bounding box in pixels: `[x, y, width, height]`. |
| `ei_query` | string | Explicit-inferential query. |
| `ii_query` | string | Implicit-inferential query. |
| `answer` | string | Reference reasoning answer shared by the EI and II queries. |

Original OSM tag values, including multilingual names, are preserved.

## Reading a target

```text
RSReasoner/
├── README.md
├── train/
│   ├── train-000000.tar
│   └── ...
└── validation/
    ├── validation-000000.tar
    └── ...
```

Data is stored in WebDataset TAR shards. Each target is represented by an image and a JSON record with the same filename stem, such as `images/000001.png` and `images/000001.json`.

The following example reads one target and loads its image, segmentation mask, and bounding box. Set `root` to your local dataset directory. Reading requires `webdataset`, `Pillow`, and `pycocotools`.

```python
from pathlib import Path
import webdataset as wds
from pycocotools import mask as mask_utils

root = Path("RSReasoner")
split = root / "train"  # Use "validation" for the validation split.

files = sorted(str(p) for p in split.glob("*.tar"))
dataset = wds.WebDataset(files, shardshuffle=False).decode("pil")
item = next(iter(dataset))
image = item["png"]
sample = item["json"]

rle = sample["mask_rle"]
mask = mask_utils.decode({
    "size": rle["size"],
    "counts": rle["counts"].encode("ascii"),
})  # 1 = target, 0 = background

bbox = sample["bbox"]  # [x, y, width, height] in pixels

print(sample["id"], sample["ei_query"], sample["ii_query"])
print(image.size, mask.shape)  # (448, 448), (448, 448)
print(bbox)
```