Add STAR dataset card
Browse files
README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: STAR Relationship
|
| 3 |
+
tags:
|
| 4 |
+
- scene-graph-generation
|
| 5 |
+
- remote-sensing
|
| 6 |
+
- polygon-annotation
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# STAR Relationship
|
| 10 |
+
|
| 11 |
+
STAR Relationship 是一个遥感场景图生成(Scene Graph Generation,SGG)数据集。仓库将原始大尺寸图片与结构化标注分开保存:
|
| 12 |
+
|
| 13 |
+
- 图片以普通文件形式位于 `images/`。
|
| 14 |
+
- train、validation 和 test 的结构化标注以 Parquet 保存。
|
| 15 |
+
- Dataset 中的 `image` 字段是图片相对于仓库根目录的路径,不包含图片字节,也不会自动解码为 PIL 对象。
|
| 16 |
+
|
| 17 |
+
完整仓库约为 127 GB。使用 `snapshot_download()` 下载完整仓库前,请确认本地有足够的磁盘空间。
|
| 18 |
+
|
| 19 |
+
## 仓库结构
|
| 20 |
+
|
| 21 |
+
```text
|
| 22 |
+
wliafe/star
|
| 23 |
+
├── README.md
|
| 24 |
+
├── images
|
| 25 |
+
│ ├── train
|
| 26 |
+
│ │ └── 0000.png
|
| 27 |
+
│ ├── validation
|
| 28 |
+
│ │ └── 0002.png
|
| 29 |
+
│ └── test
|
| 30 |
+
│ └── 0004.png
|
| 31 |
+
└── data
|
| 32 |
+
├── train-*.parquet
|
| 33 |
+
├── validation-*.parquet
|
| 34 |
+
└── test-*.parquet
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
本地源数据中的 `val` 在 Hugging Face Dataset 中命名为 `validation`。
|
| 38 |
+
|
| 39 |
+
## 数据字段
|
| 40 |
+
|
| 41 |
+
每行表示一张图片及其场景图标注:
|
| 42 |
+
|
| 43 |
+
- `id`:图片文件名去除扩展名后的样本 ID。
|
| 44 |
+
- `image`:仓库相对路径,例如 `images/train/0000.png`。
|
| 45 |
+
- `width`、`height`:原图宽高。
|
| 46 |
+
- `polygons`:对象 polygon 列表;每个点为 `[x, y]`,保留原始坐标和顶点顺序。
|
| 47 |
+
- `labels`:与 `polygons` 一一对应的对象类别。
|
| 48 |
+
- `relations.subject_index`:关系主语在对象数组中的索引。
|
| 49 |
+
- `relations.object_index`:关系宾语在对象数组中的索引。
|
| 50 |
+
- `relations.predicate`:关系类别。
|
| 51 |
+
|
| 52 |
+
test split 只有图片,`polygons`、`labels` 和三个关系数组均为空。
|
| 53 |
+
|
| 54 |
+
## 下载并读取
|
| 55 |
+
|
| 56 |
+
`repo_type="dataset"` 是 `snapshot_download()` 的参数;`load_dataset()` 直接使用仓库 ID,不需要传入 `repo_type`。
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
from pathlib import Path
|
| 60 |
+
|
| 61 |
+
from datasets import load_dataset
|
| 62 |
+
from huggingface_hub import snapshot_download
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
repo_dir = Path(
|
| 66 |
+
snapshot_download(
|
| 67 |
+
repo_id="wliafe/star",
|
| 68 |
+
repo_type="dataset",
|
| 69 |
+
)
|
| 70 |
+
)
|
| 71 |
+
dataset = load_dataset("wliafe/star")
|
| 72 |
+
|
| 73 |
+
sample = dataset["train"][0]
|
| 74 |
+
image_path = repo_dir / sample["image"]
|
| 75 |
+
|
| 76 |
+
print(sample["id"])
|
| 77 |
+
print(sample["image"])
|
| 78 |
+
print(image_path)
|
| 79 |
+
assert image_path.is_file()
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
`snapshot_download()` 返回仓库快照根目录,因此将它与 `sample["image"]` 拼接即可得到本地图片路径。不要直接把相对路径解释为当前工作目录下的文件。
|
| 83 |
+
|
| 84 |
+
### 使用 Pillow
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
from PIL import Image
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
with Image.open(image_path) as image:
|
| 91 |
+
image.load()
|
| 92 |
+
print(image.size)
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
### 使用 OpenCV
|
| 96 |
+
|
| 97 |
+
```python
|
| 98 |
+
import cv2
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
image = cv2.imread(str(image_path), cv2.IMREAD_UNCHANGED)
|
| 102 |
+
if image is None:
|
| 103 |
+
raise RuntimeError(f"无法读取图片:{image_path}")
|
| 104 |
+
print(image.shape)
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## 固定数据版本
|
| 108 |
+
|
| 109 |
+
如果训练或评测需要可复现的数据版本,请为下载和 Dataset 加载指定同一个完整 commit revision:
|
| 110 |
+
|
| 111 |
+
```python
|
| 112 |
+
from pathlib import Path
|
| 113 |
+
|
| 114 |
+
from datasets import load_dataset
|
| 115 |
+
from huggingface_hub import snapshot_download
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
revision = "<full-commit-sha>"
|
| 119 |
+
repo_dir = Path(
|
| 120 |
+
snapshot_download(
|
| 121 |
+
repo_id="wliafe/star",
|
| 122 |
+
repo_type="dataset",
|
| 123 |
+
revision=revision,
|
| 124 |
+
)
|
| 125 |
+
)
|
| 126 |
+
dataset = load_dataset("wliafe/star", revision=revision)
|
| 127 |
+
|
| 128 |
+
image_path = repo_dir / dataset["train"][0]["image"]
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
这样 Parquet 标注与原始图片始终来自同一个仓库版本。
|