STAR / README.md
wliafe's picture
Add background class at index 0
dae4d0c verified
|
Raw
History Blame Contribute Delete
8.03 kB
---
pretty_name: STAR Relationship
tags:
- scene-graph-generation
- remote-sensing
- polygon-annotation
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
- split: validation
path: data/validation-*
- split: test
path: data/test-*
dataset_info:
features:
- name: id
dtype: string
- name: image
dtype: string
- name: width
dtype: int32
- name: height
dtype: int32
- name: polygons
list:
list:
list: float32
length: 2
- name: labels
list:
class_label:
names:
'0': __background__
'1': airplane
'2': apron
'3': arch_dam
'4': baseball_diamond
'5': basketball_court
'6': boarding_bridge
'7': boat
'8': breakwater
'9': bridge
'10': car
'11': car_parking
'12': cement_concrete_pavement
'13': chimney
'14': coal_yard
'15': containment_vessel
'16': cooling_tower
'17': crane
'18': dock
'19': engineering_vehicle
'20': flood_dam
'21': foundation_pit
'22': gas_station
'23': genset
'24': goods_yard
'25': gravity_dam
'26': ground_track_field
'27': intersection
'28': lattice_tower
'29': roundabout
'30': runway
'31': ship
'32': ship_lock
'33': smoke
'34': soccer_ball_field
'35': stadium
'36': storehouse
'37': substation
'38': tank
'39': taxiway
'40': tennis_court
'41': terminal
'42': toll_gate
'43': tower_crane
'44': truck
'45': truck_parking
'46': unfinished_building
'47': vapor
'48': wind_mill
- name: relations
struct:
- name: subject_index
list: int64
- name: object_index
list: int64
- name: predicate
list:
class_label:
names:
'0': __background__
'1': adjacent
'2': approach
'3': around
'4': away from
'5': co-storage with
'6': connect
'7': converge
'8': directly connected to
'9': directly transmit electricity to
'10': docked alongside with
'11': docking at the different dock with
'12': docking at the same breakwater with
'13': docking at the same dock with
'14': drive off
'15': drive toward
'16': driving alongside with
'17': driving in the different lane with
'18': driving in the opposite direction with
'19': driving in the same direction with
'20': driving in the same lane with
'21': exhaust to
'22': in the different parking with
'23': in the same parking with
'24': incorrectly parked on
'25': indirectly connected to
'26': indirectly transmit electricity to
'27': intersect
'28': isolatedly docked at
'29': isolatedly parked on
'30': not co-storage with
'31': not docked alongside with
'32': not parked alongside with
'33': not run along
'34': not working on
'35': over
'36': parallelly docked at
'37': parallelly parked on
'38': parked alongside with
'39': parking in the different apron with
'40': parking in the same apron with
'41': pass across
'42': pass through
'43': pass under
'44': randomly docked at
'45': randomly parked on
'46': run along
'47': running along the different runway with
'48': running along the different taxiway with
'49': running along the same taxiway with
'50': slightly emit
'51': supply to
'52': through
'53': violently emit
'54': within danger distance of
'55': within different line of
'56': within safe distance of
'57': within same line of
'58': working on
splits:
- name: train
num_bytes: 10717079
num_examples: 771
- name: validation
num_bytes: 4288100
num_examples: 238
- name: test
num_bytes: 15840
num_examples: 264
download_size: 14671494
dataset_size: 15021019
---
# STAR Relationship
STAR Relationship 是一个遥感场景图生成(Scene Graph Generation,SGG)数据集。仓库将原始大尺寸图片与结构化标注分开保存:
- 图片以普通文件形式位于 `images/`
- train、validation 和 test 的结构化标注以 Parquet 保存。
- Dataset 中的 `image` 字段是图片相对于仓库根目录的路径,不包含图片字节,也不会自动解码为 PIL 对象。
完整仓库约为 127 GB。使用 `snapshot_download()` 下载完整仓库前,请确认本地有足够的磁盘空间。
## 仓库结构
```text
wliafe/star
├── README.md
├── images
│ ├── train
│ │ └── 0000.png
│ ├── validation
│ │ └── 0002.png
│ └── test
│ └── 0004.png
└── data
├── train-*.parquet
├── validation-*.parquet
└── test-*.parquet
```
本地源数据中的 `val` 在 Hugging Face Dataset 中命名为 `validation`
## 数据字段
每行表示一张图片及其场景图标注:
- `id`:图片文件名去除扩展名后的样本 ID。
- `image`:仓库相对路径,例如 `images/train/0000.png`
- `width``height`:原图宽高。
- `polygons`:对象 polygon 列表;每个点为 `[x, y]`,保留原始坐标和顶点顺序。
- `labels`:与 `polygons` 一一对应的对象类别。
- `relations.subject_index`:关系主语在对象数组中的索引。
- `relations.object_index`:关系宾语在对象数组中的索引。
- `relations.predicate`:关系类别。
test split 只有图片,`polygons``labels` 和三个关系数组均为空。
## 下载并读取
`repo_type="dataset"``snapshot_download()` 的参数;`load_dataset()` 直接使用仓库 ID,不需要传入 `repo_type`
```python
from pathlib import Path
from datasets import load_dataset
from huggingface_hub import snapshot_download
repo_dir = Path(
snapshot_download(
repo_id="wliafe/star",
repo_type="dataset",
)
)
dataset = load_dataset("wliafe/star")
sample = dataset["train"][0]
image_path = repo_dir / sample["image"]
print(sample["id"])
print(sample["image"])
print(image_path)
assert image_path.is_file()
```
`snapshot_download()` 返回仓库快照根目录,因此将它与 `sample["image"]` 拼接即可得到本地图片路径。不要直接把相对路径解释为当前工作目录下的文件。
### 使用 Pillow
```python
from PIL import Image
with Image.open(image_path) as image:
image.load()
print(image.size)
```
### 使用 OpenCV
```python
import cv2
image = cv2.imread(str(image_path), cv2.IMREAD_UNCHANGED)
if image is None:
raise RuntimeError(f"无法读取图片:{image_path}")
print(image.shape)
```
## 固定数据版本
如果训练或评测需要可复现的数据版本,请为下载和 Dataset 加载指定同一个完整 commit revision:
```python
from pathlib import Path
from datasets import load_dataset
from huggingface_hub import snapshot_download
revision = "<full-commit-sha>"
repo_dir = Path(
snapshot_download(
repo_id="wliafe/star",
repo_type="dataset",
revision=revision,
)
)
dataset = load_dataset("wliafe/star", revision=revision)
image_path = repo_dir / dataset["train"][0]["image"]
```
这样 Parquet 标注与原始图片始终来自同一个仓库版本。