Add PSG dataset description (#1)
Browse files- Add PSG dataset description (35882c77ac044c242fbcc64075c5247bc6d874f5)
README.md
CHANGED
|
@@ -247,3 +247,123 @@ configs:
|
|
| 247 |
- split: validation
|
| 248 |
path: data/validation-*
|
| 249 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
- split: validation
|
| 248 |
path: data/validation-*
|
| 249 |
---
|
| 250 |
+
|
| 251 |
+
# Panoptic Scene Graph
|
| 252 |
+
|
| 253 |
+
PSG(Panoptic Scene Graph)是面向全景场景图生成的数据集。每个场景图节点不仅包含对象类别和边界框,还通过 panoptic segmentation mask 与像素级区域对应。数据集同时覆盖 thing 和 stuff 类别。
|
| 254 |
+
|
| 255 |
+
本仓库将 RGB 图片和 panoptic PNG 直接嵌入 Parquet。通过 Hugging Face `Image` feature 加载后,两者都会解码为 Pillow 图像,不需要额外下载图片目录。
|
| 256 |
+
|
| 257 |
+
## 数据集规模
|
| 258 |
+
|
| 259 |
+
| Split | 样本 | 对象 / segments | 关系 |
|
| 260 |
+
| --- | ---: | ---: | ---: |
|
| 261 |
+
| `train` | 46,563 | 513,243 | 261,666 |
|
| 262 |
+
| `validation` | 2,186 | 24,910 | 13,705 |
|
| 263 |
+
| **总计** | **48,749** | **538,153** | **275,371** |
|
| 264 |
+
|
| 265 |
+
`validation` 对应完整 PSG 发布版中的官方 test split。完整发布版带有 test ground truth,因此这里保留其对象、mask 和关系标注,并改名为 Hugging Face 常用的 `validation`。部分样本没有关系,其关系数组为空。
|
| 266 |
+
|
| 267 |
+
PSG 中有少量不同样本引用同一张 COCO 图片;`id` 是 PSG 样本 ID,不应使用图片文件名替代。
|
| 268 |
+
|
| 269 |
+
## 加载
|
| 270 |
+
|
| 271 |
+
```python
|
| 272 |
+
from datasets import load_dataset
|
| 273 |
+
|
| 274 |
+
dataset = load_dataset("wliafe/PSG")
|
| 275 |
+
sample = dataset["train"][0]
|
| 276 |
+
|
| 277 |
+
image = sample["image"] # PIL.Image.Image
|
| 278 |
+
panoptic_mask = sample["panoptic_mask"] # PIL.Image.Image
|
| 279 |
+
print(sample["id"], image.size, panoptic_mask.size)
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
## 字段
|
| 283 |
+
|
| 284 |
+
| 字段 | 类型 | 说明 |
|
| 285 |
+
| --- | --- | --- |
|
| 286 |
+
| `id` | `string` | PSG 样本 ID |
|
| 287 |
+
| `image` | `Image` | 嵌入式 RGB 图片;源文件主要是 JPEG,少量 `.jpg` 实际为 PNG |
|
| 288 |
+
| `panoptic_mask` | `Image` | 嵌入式 RGB 编码 panoptic PNG |
|
| 289 |
+
| `width` / `height` | `int32` | 解码后 RGB 图片的实际像素尺寸 |
|
| 290 |
+
| `boxes` | `List[[float32; 4]]` | 与 segments 平行的 `[x1, y1, x2, y2]` 边界框 |
|
| 291 |
+
| `labels` | `List[ClassLabel]` | 与 segments 平行的对象类别 |
|
| 292 |
+
| `segments.id` | `List[int64]` | panoptic mask 中的 segment ID |
|
| 293 |
+
| `segments.area` | `List[int64]` | segment 的标注面积 |
|
| 294 |
+
| `segments.iscrowd` | `List[bool]` | COCO crowd 标记 |
|
| 295 |
+
| `segments.isthing` | `List[bool]` | thing/stuff 标记 |
|
| 296 |
+
| `relations.subject_index` | `List[int64]` | 主语在当前 segment 数组中的零基索引 |
|
| 297 |
+
| `relations.object_index` | `List[int64]` | 宾语在当前 segment 数组中的零基索引 |
|
| 298 |
+
| `relations.predicate` | `List[ClassLabel]` | 有向关系的谓词类别 |
|
| 299 |
+
|
| 300 |
+
`boxes`、`labels` 和四个 `segments` 数组长度相同。同一位置表示同一个场景图节点。三个 `relations` 数组长度也相同,同一位置共同表示一条有向关系。
|
| 301 |
+
|
| 302 |
+
## Panoptic mask
|
| 303 |
+
|
| 304 |
+
panoptic PNG 使用 RGB 三通道编码整数 segment ID:
|
| 305 |
+
|
| 306 |
+
```python
|
| 307 |
+
import numpy as np
|
| 308 |
+
|
| 309 |
+
rgb = np.asarray(sample["panoptic_mask"].convert("RGB"), dtype=np.int64)
|
| 310 |
+
segment_id_map = (
|
| 311 |
+
rgb[..., 0]
|
| 312 |
+
+ 256 * rgb[..., 1]
|
| 313 |
+
+ 256 * 256 * rgb[..., 2]
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
first_segment_id = sample["segments"]["id"][0]
|
| 317 |
+
first_segment_mask = segment_id_map == first_segment_id
|
| 318 |
+
print(first_segment_mask.sum())
|
| 319 |
+
```
|
| 320 |
+
|
| 321 |
+
mask 中的非零 segment ID 与 `segments.id` 对应。背景像素的 ID 为 0,这与 taxonomy 中保留的 `__background__` 类别编号是两个不同概念。
|
| 322 |
+
|
| 323 |
+
## 类别与关系
|
| 324 |
+
|
| 325 |
+
对象和谓词 taxonomy 都在索引 `0` 保留 `__background__`:
|
| 326 |
+
|
| 327 |
+
- 对象前景类别编号为 `1`–`133`,依次对应 80 个 thing 类和 53 个 stuff 类。
|
| 328 |
+
- 谓词前景类别编号为 `1`–`56`。
|
| 329 |
+
- `subject_index` 和 `object_index` 是样本内部 segment 数组的位置,不是类别 ID。
|
| 330 |
+
|
| 331 |
+
```python
|
| 332 |
+
features = dataset["train"].features
|
| 333 |
+
object_names = features["labels"].feature.names
|
| 334 |
+
predicate_names = features["relations"]["predicate"].feature.names
|
| 335 |
+
|
| 336 |
+
for subject, object_, predicate in zip(
|
| 337 |
+
sample["relations"]["subject_index"],
|
| 338 |
+
sample["relations"]["object_index"],
|
| 339 |
+
sample["relations"]["predicate"],
|
| 340 |
+
):
|
| 341 |
+
print(
|
| 342 |
+
object_names[sample["labels"][subject]],
|
| 343 |
+
predicate_names[predicate],
|
| 344 |
+
object_names[sample["labels"][object_]],
|
| 345 |
+
)
|
| 346 |
+
```
|
| 347 |
+
|
| 348 |
+
## 坐标约定
|
| 349 |
+
|
| 350 |
+
`boxes` 使用实际图片像素坐标下的 `[x1, y1, x2, y2]` 格式,并位于图片边界内。`width` 和 `height` 与解码后的 RGB 图片及 panoptic mask 尺寸一致。
|
| 351 |
+
|
| 352 |
+
## 使用限制
|
| 353 |
+
|
| 354 |
+
- 类别和谓词呈长尾分布,评估结果可能受高频类别主导。
|
| 355 |
+
- 场景图和分割标注可能包含遗漏、歧义或类别噪声。
|
| 356 |
+
- 本仓库不重新授予原始 COCO 图片版权;使用者应遵守 COCO 与 PSG 的许可和使用要求。
|
| 357 |
+
- 比较模型结果时,应确认采用相同 split、taxonomy 和 background 编号。
|
| 358 |
+
|
| 359 |
+
## 引用
|
| 360 |
+
|
| 361 |
+
```bibtex
|
| 362 |
+
@inproceedings{yang2022panoptic,
|
| 363 |
+
title={Panoptic Scene Graph Generation},
|
| 364 |
+
author={Yang, Jingkang and Ang, Yi Zhe and Guo, Zujin and Zhou, Kaiyang
|
| 365 |
+
and Zhang, Wayne and Liu, Ziwei},
|
| 366 |
+
booktitle={European Conference on Computer Vision},
|
| 367 |
+
year={2022}
|
| 368 |
+
}
|
| 369 |
+
```
|