jhelsby commited on
Commit
157b78a
·
verified ·
1 Parent(s): f7672aa

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +200 -3
README.md CHANGED
@@ -1,3 +1,200 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OvDSGG Readme
2
+
3
+ [![arXiv](https://img.shields.io/badge/arXiv-2608.14835-b31b1b.svg)](https://arxiv.org/abs/2608.14835)
4
+
5
+ **Accepted at the ECCV 2026 Contextus Workshop.** _[Read the paper on arXiv](https://arxiv.org/abs/2608.14835)._
6
+
7
+ An open-vocabulary dynamic scene graph generation model (DSGG) that integrates the closed-set DSGG [OED](https://github.com/guanw-pku/OED) with the open-vocabulary scene graph generation model (SGG) [OvSGTR](https://github.com/gpt4vision/OvSGTR/). We use OvSGTR as the spatial feature extractor and feed its outputs into OED's temporal routing module.
8
+
9
+ The open-vocabulary setting was benchmarked against [an open-vocabulary adaptation of OED](https://github.com/jhelsby/oed) and [a version of OvSGTR adapted for DSGG](https://github.com/jhelsby/OvSGTR).
10
+
11
+ ## Contents
12
+ * [Setup](#setup)
13
+ * [Prepare Data](#prepare-data)
14
+ * [Train](#train)
15
+ * [Evaluate](#evaluate)
16
+ * [Checkpoints](#checkpoints)
17
+ * [Open-Vocabulary Data Split](#open-vocabulary-data-split)
18
+ * [Key Losses and Metrics](#key-losses-and-metrics)
19
+
20
+ ## Setup
21
+
22
+ You must use Python 3.9 for this repo to work, due to the dependencies of OvSGTR, which this repo is built upon.
23
+
24
+ ```bash
25
+ conda create -n myenv python=3.9
26
+ conda activate myenv
27
+ ./install.sh
28
+ ```
29
+
30
+ Sometimes GroundingDINO gives a `ModuleNotFoundError` - I think this is because some HexGPU nodes are using different Python versions. You can try rebuilding it with:
31
+ ```bash
32
+ pip install -e ./GroundingDINO --no-build-isolation
33
+ ```
34
+
35
+ ## Prepare Data
36
+
37
+ We use the dataset Action Genome to train and evaluate OvDSGG. Please process the downloaded dataset with the [Toolkit](https://github.com/JingweiJ/ActionGenome) and put the [processed annotation files](https://drive.google.com/drive/folders/1tdfAyYm8GGXtO2okAoH1WgVHVOTl1QYe) with COCO style into annotations folder. The directories of the dataset should look like:
38
+ ```
39
+ |-- action_genome
40
+ |-- annotations # gt annotations
41
+ |-- ag_train_coco_style.json
42
+ |-- ag_test_coco_style.json
43
+ |-- ...
44
+ |-- frames # sampled frames
45
+ |-- videos # original videos
46
+ ```
47
+
48
+ [Zero-Shot Recall (zR@K)](https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch/blob/master/METRICS.md) for Action Genome is calculated using the file [`datasets/ov_zeroshot_triplet.pytorch`](./datasets/ov_zeroshot_triplet.pytorch), in this repo. This file was generated using the following script:
49
+
50
+ ```bash
51
+ python tools/generate_ag_zeroshot.py --ann_file data/action_genome/annotations/ag_train_coco_style.json
52
+ ```
53
+
54
+ ## Train
55
+
56
+ We train the spatial module first, then the temporal module on the best spatial checkpoint.
57
+
58
+ ### Closed-set training
59
+
60
+ To run closed-set training, run these commands in order:
61
+
62
+ **1. Spatial Training**
63
+
64
+ Prior to training, download the [pretrained OvSGTR closed-set SGG Swin-T checkpoint](https://github.com/gpt4vision/OvSGTR/?tab=readme-ov-file#-checkpoints-closed-set-sgg) from [HuggingFace](https://huggingface.co/JosephZ/OvSGTR/blob/main/vg-swint-full.pth) and save it to `./checkpoints/vg-swint-full.pth`.
65
+
66
+ ```bash
67
+ python scripts/train_spatial_sgdet_ovdsgg_closed_set.py
68
+ ```
69
+
70
+ **2. Temporal Training**
71
+ ```bash
72
+ python scripts/train_temporal_sgdet_ovdsgg_closed_set.py
73
+ ```
74
+
75
+ ### Open-vocabulary training
76
+
77
+ To run open-vocabulary training, run these commands in order:
78
+
79
+ **1. Spatial Training**
80
+
81
+ Prior to training, download the [pretrained OvSGTR OvD+R-SGG Swin-T checkpoint](https://github.com/gpt4vision/OvSGTR/?tab=readme-ov-file#-checkpoints-ovdr-sgg) from [HuggingFace](https://huggingface.co/JosephZ/OvSGTR/blob/main/vg-ovdr-swint.pth) and save it to `./checkpoints/vg-ovdr-swint.pth`.
82
+
83
+ ```bash
84
+ python scripts/train_spatial_sgdet_ovdsgg_ovdr.py
85
+ ```
86
+
87
+ **2. Temporal Training**
88
+ ```bash
89
+ python scripts/train_temporal_sgdet_ovdsgg_ovdr.py
90
+ ```
91
+
92
+ ### Ablations
93
+
94
+ Our baseline derives object pair predictions and predicate classifications directly from isolated query representations, without interaction modules. To train the baseline, run these commands:
95
+
96
+ **Closed-set Baseline**
97
+ ```bash
98
+ python scripts/train_ablation_baseline_sgdet_ovdsgg_closed_set.py
99
+ ```
100
+
101
+ **Open-vocabulary Baseline**
102
+ ```bash
103
+ python scripts/train_ablation_baseline_sgdet_ovdsgg_ovdr.py
104
+ ```
105
+
106
+ ## Evaluate
107
+
108
+ ### Closed-set evaluation
109
+
110
+ To evaluate closed-set models, run these commands:
111
+
112
+ **1. Spatial Evaluation**
113
+ ```bash
114
+ python scripts/eval_spatial_sgdet_ovdsgg_closed_set.py
115
+ ```
116
+
117
+ **2. Temporal Evaluation**
118
+ ```bash
119
+ python scripts/eval_temporal_sgdet_ovdsgg_closed_set.py
120
+ ```
121
+
122
+ ### Open-vocabulary evaluation
123
+
124
+ To evaluate open-vocabulary models, run these commands:
125
+
126
+ **1. Spatial Evaluation**
127
+ ```bash
128
+ python scripts/eval_spatial_sgdet_ovdsgg_ovdr.py
129
+ ```
130
+
131
+ **2. Temporal Evaluation**
132
+ ```bash
133
+ python scripts/eval_temporal_sgdet_ovdsgg_ovdr.py
134
+ ```
135
+
136
+ ### Ablation evaluation
137
+
138
+ To evaluate the ablation baseline models, run these commands:
139
+
140
+ **Closed-set Baseline**
141
+ ```bash
142
+ python scripts/eval_ablation_baseline_sgdet_ovdsgg_closed_set.py
143
+ ```
144
+
145
+ **Open-vocabulary Baseline**
146
+ ```bash
147
+ python scripts/eval_ablation_baseline_sgdet_ovdsgg_ovdr.py
148
+ ```
149
+
150
+ ## Checkpoints
151
+
152
+ To run the evaluation scripts using our pre-trained models, download the necessary checkpoint here:
153
+
154
+ * **Download**: [link](https://drive.google.com/drive/folders/1koo9E85QpemNhS7V1teUg8LJDUXM7RNV?usp=drive_link)
155
+
156
+ Once downloaded, place each checkpoint file in its respective experiment directory so the evaluation scripts can find them automatically by default:
157
+ * **Spatial Open-Vocabulary**: `exps/spatial_sgdet_ovdsgg_ovdr/checkpoint.pth`
158
+ * **Temporal Open-Vocabulary**: `exps/temporal_sgdet_ovdsgg_ovdr/checkpoint.pth`
159
+ * **Spatial Closed-Set**: `exps/spatial_sgdet_ovdsgg_closed_set/checkpoint.pth`
160
+ * **Temporal Closed-Set**: `exps/temporal_sgdet_ovdsgg_closed_set/checkpoint.pth`
161
+ * **Ablation Open-Vocabulary**: `exps/ablation_baseline_ovdr/checkpoint.pth`
162
+ * **Ablation Closed-Set**: `exps/ablation_baseline_closed_set/checkpoint.pth`
163
+
164
+
165
+ ## Open-Vocabulary Data Split
166
+
167
+ To test open-vocabulary capabilities of OvDSGG, we train on only 70% of the categories in Action Genome. The rest are only seen during evaluation. To do this, we split the categories into Base (seen during training) and Novel (unseen during training)
168
+
169
+ The open-vocabulary training split is hardcoded in [datasets/ag.py](./datasets/ag.py), and has been chosen such that:
170
+
171
+ * ~70% of objects are in Base (25 out of 36, 69.4%).
172
+ * ~70% of predicates are in Base (18 out of 26, 69.2%).
173
+ * Common and rare categories are balanced across Base and Novel sets.
174
+ * None of the Novel categories were seen by the pretrained open-vocabulary OvSGTR/GroundingDINO checkpoint.
175
+
176
+ See PRs [#12](https://github.com/jhelsby/OvDSGG/pull/12) and [#13](https://github.com/jhelsby/OvDSGG/pull/13) for details. To generate the split yourself, run:
177
+
178
+ ```bash
179
+ python tools/propose_ag_split.py
180
+ ```
181
+
182
+ ## Key Losses and Metrics
183
+
184
+ | Metric / Loss | Type | Description |
185
+ | :--- | :--- | :--- |
186
+ | **`loss`** | **Total Loss** | Weighted sum of all scaled losses minimized by the optimizer. |
187
+ | **`loss_obj_ce`** | Object Loss | Cross Entropy loss for object classification. |
188
+ | **`loss_obj_bbox`** | Object Loss | L1 error for object bounding box center and size. |
189
+ | **`loss_obj_giou`** | Object Loss | Generalized IoU loss for object bounding box overlap. |
190
+ | **`loss_sub_bbox`** | Subject Loss | L1 error for subject bounding box center and size. |
191
+ | **`loss_sub_giou`** | Subject Loss | Generalized IoU loss for subject bounding box overlap. |
192
+ | **`loss_attn_ce`** | Relation Loss | Loss for classifying the "attention" or main interaction. |
193
+ | **`loss_spatial_ce`** | Relation Loss | Loss for classifying spatial relationships (e.g., "in front of"). |
194
+ | **`loss_contacting_ce`** | Relation Loss | Loss for classifying contacting relationships (e.g., "holding"). |
195
+ | **`obj_class_error_unscaled`** | **Key Metric** | The raw percentage of objects misclassified (Error Rate %). |
196
+
197
+ ## References
198
+
199
+ Please note that most of the code in this repository was adapted from [OED](https://github.com/guanw-pku/OED) and [OvSGTR](https://github.com/gpt4vision/OvSGTR/). We thank the authors for their excellent work.
200
+