zbbhhh commited on
Commit
fd4f414
Β·
verified Β·
1 Parent(s): 2712416

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +420 -1
README.md CHANGED
@@ -1,3 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ <h1>VGGT-Segmentor: Geometry-Enhanced Cross-View Segmentation</h1>
4
+
5
+ <div>
6
+ <a href='https://scholar.google.com/citations?user=s3u33VAAAAAJ&hl=en&oi=ao' target='_blank'>Yulu Gao*</a><sup>1</sup>&emsp;
7
+ <a href='https://github.com/bohaocheung' target='_blank'>Bohang Zhang*</a><sup>2</sup>&emsp;
8
+ <a href='https://scholar.google.com/citations?user=jrgMNxEAAAAJ&hl=en&oi=ao' target='_blank'>Zongheng Tang</a><sup>1</sup>&emsp;
9
+ <a href='https://github.com/nikkukun' target='_blank'>Jitong Liao</a><sup>2</sup>&emsp;
10
+ <a href='https://iai.buaa.edu.cn/info/1013/1093.htm' target='_blank'>Wenjun Wu</a><sup>2</sup>&emsp;
11
+ <a href='https://scholar.google.com/citations?user=-QtVtNEAAAAJ&hl=en&oi=ao' target='_blank'>Si Liu†</a><sup>2</sup>
12
+ </div>
13
+ <div>
14
+ <sup>1</sup>Hangzhou International Innovation Institute of Beihang University 1&emsp;
15
+ <sup>2</sup>Beihang University 2
16
+ </div>
17
+
18
+ <div>
19
+ <strong>CVPR 2026 Oral πŸŽ‰</strong>
20
+ </div>
21
+
22
+ <div>
23
+ <h4 align="center">
24
+ <a href="https://bohaocheung.github.io/VGGT-S-project-page" target='_blank'>
25
+ <img src="https://img.shields.io/badge/Project-Page-green">
26
+ </a>
27
+ <a href="https://arxiv.org/abs/2604.13596" target='_blank'>
28
+ <img src="https://img.shields.io/badge/arXiv-2604.13596-b31b1b.svg">
29
+ </a>
30
+ <a href="https://scholar.googleusercontent.com/scholar.bib?q=info:jq38NPHn4IQJ:scholar.google.com/&output=citation&scisdr=ClgBRwZHEN-wr8OW2eU:AFyMTJUAAAAAagaQweUMI9W3d4bE2S1_35XpMEM&scisig=AFyMTJUAAAAAagaQwVDNP28VXvXE-Xq1pW_q-jU&scisf=4&ct=citation&cd=0&hl=en" target='_blank'>
31
+ <img src="https://img.shields.io/badge/Cite-BibTeX-blue">
32
+ </a>
33
+ <a href="https://huggingface.co/zbbhhh/VGGT-S">
34
+ <img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Checkpoint-yellow'>
35
+ </a>
36
+ <a href="https://www.youtube.com/watch?v=56TSdPqQtgA">
37
+ <img src='https://img.shields.io/badge/YouTube-Video-red?logo=youtube'>
38
+ </a>
39
+ </h4>
40
+ </div>
41
+
42
+ <strong>VGGT-S is a geometry-grounded segmentation framework built upon [VGGT](https://github.com/facebookresearch/vggt) for instance-level object segmentation across egocentric and exocentric views under large viewpoint, scale, and occlusion variations.</strong>
43
+
44
+ <div align="center">
45
+ <img src="https://raw.githubusercontent.com/bohaocheung/VGGT-S-project-page/main/static/images/compressed-repo-demo.gif" width="100%">
46
+ </div>
47
+
48
+ </div>
49
+
50
+ ## πŸ“’ News
51
+
52
+ * **[2026-05-15]** πŸš€ Code and checkpoint are open-sourced.
53
+ * **[2026-04-15]** πŸ”₯ VGGT-Segmentor paper is released on arxiv.
54
+
55
+
56
+ ## πŸ’‘ Highlights
57
+
58
+ * **Union Segmentation Head**. We design this head to effectively translate VGGT’s high-level feature alignment into precise segmentation masks.
59
+ * **Single-Image Self-Supervised Training Strategy**. This strategy eliminates the need for paired annotations in correspondence tasks by deforming a single image to simulate different viewpoints.
60
+ * **New SOTA Results**. Our proposed VGGT-Segmentor achieves state-of-the-art results on EgoExo4d dataset.
61
+
62
+
63
+ ## πŸ› οΈ Usage
64
+ ### Installation
65
+
66
+ #### Clone Repository
67
+
68
+ * Clone [VGGT-S](https://github.com/buaa-colalab/VGGT-S)
69
+
70
+ ```bash
71
+ git clone https://github.com/buaa-colalab/VGGT-S.git
72
+ cd VGGT-S
73
+ ```
74
+
75
+ #### Create Environment
76
+
77
+ ```bash
78
+ conda create -n vggts python=3.10
79
+ conda activate vggts
80
+ ```
81
+
82
+ #### Install VGGT Dependency
83
+
84
+ This project is built upon [VGGT](https://github.com/facebookresearch/vggt), proposed in the CVPR 2025 Best Paper:
85
+
86
+ > Wang et al., β€œVGGT: Visual Geometry Grounded Transformer”, CVPR 2025.
87
+
88
+ Please clone the official VGGT repository under `third_party`:
89
+
90
+ ```bash
91
+ mkdir -p third_party && cd third_party
92
+ git clone https://github.com/facebookresearch/vggt.git vggt_main
93
+ cd vggt_main
94
+ pip install -r requirements.txt # This is for VGGT
95
+ pip install -e .
96
+
97
+ # Last, download the VGGT Checkpoint, name it model.pt and place it under vggt_main folder.
98
+ ```
99
+
100
+ The directory structure should look like:
101
+
102
+ ```text
103
+ VGGT-S/
104
+ β”œβ”€β”€ src/
105
+ β”œβ”€β”€ data/
106
+ β”œβ”€β”€ third_party/
107
+ β”‚ └── vggt_main/
108
+ β”‚ └── model.pt
109
+ └── requirements.txt
110
+ ```
111
+
112
+ #### Install Requirements
113
+
114
+ ```bash
115
+ cd VGGT-S
116
+ pip install -r requirements.txt # This is for VGGT-S
117
+ hf download zbbhhh/VGGT-S main_exp.pth --local-dir official_ckpts # Download checkpoint
118
+ ```
119
+
120
  ---
121
+
122
+ ### Modify VGGT Track Head
123
+
124
+ To extract VGGT encoder feature maps for downstream correspondence learning, please modify the `forward` function in:
125
+
126
+ ```text
127
+ third_party/vggt_main/vggt/heads/track_head.py
128
+ ```
129
+
130
+ Replace the original `forward` function (around Line 72) with the following implementation:
131
+
132
+ ```python
133
+ def forward(self, aggregated_tokens_list, images, patch_start_idx, query_points=None, iters=None, feat=False):
134
+ """
135
+ Forward pass of the TrackHead.
136
+
137
+ Args:
138
+ aggregated_tokens_list (list): List of aggregated tokens from the backbone.
139
+ images (torch.Tensor): Input images of shape (B, S, C, H, W), where:
140
+ B = batch size,
141
+ S = sequence length.
142
+ patch_start_idx (int): Starting index for patch tokens.
143
+ query_points (torch.Tensor, optional): Initial query points to track.
144
+ If None, points are initialized automatically.
145
+ iters (int, optional): Number of refinement iterations.
146
+ If None, uses self.iters.
147
+ feat (bool, optional): Whether to additionally return feature maps.
148
+
149
+ Returns:
150
+ tuple:
151
+ - coord_preds (torch.Tensor): Predicted coordinates.
152
+ - vis_scores (torch.Tensor): Visibility scores.
153
+ - conf_scores (torch.Tensor): Confidence scores.
154
+ - feature_maps (torch.Tensor, optional): Extracted VGGT feature maps.
155
+ """
156
+
157
+ B, S, _, H, W = images.shape
158
+
159
+ # Extract feature maps from VGGT tokens
160
+ # Shape: (B, S, C, H//2, W//2)
161
+ feature_maps = self.feature_extractor(
162
+ aggregated_tokens_list,
163
+ images,
164
+ patch_start_idx
165
+ )
166
+
167
+ # Use default iterations if not specified
168
+ if iters is None:
169
+ iters = self.iters
170
+
171
+ # Tracking
172
+ coord_preds, vis_scores, conf_scores = self.tracker(
173
+ query_points=query_points,
174
+ fmaps=feature_maps,
175
+ iters=iters
176
+ )
177
+
178
+ if feat:
179
+ return coord_preds, vis_scores, conf_scores, feature_maps
180
+
181
+ return coord_preds, vis_scores, conf_scores
182
+ ```
183
+
184
  ---
185
+
186
+ ### Dataset Preparation
187
+
188
+ #### Download Ego-Exo4D
189
+
190
+ Please follow the official [SegSwap Ego-Exo4D correspondence pipeline](https://github.com/EGO4D/ego-exo4d-relation/tree/main/correspondence/SegSwap) to:
191
+
192
+ 1. Download the Ego-Exo4D dataset
193
+ 2. Extract video frames into images
194
+ 3. Generate correspondence pairs
195
+
196
+ After preprocessing, the dataset should be organized as:
197
+
198
+ ```text
199
+ data_root/
200
+ β”œβ”€β”€ take_id_01/
201
+ β”‚ β”œβ”€β”€ ego_cam/
202
+ β”‚ β”‚ β”œβ”€β”€ 0.jpg
203
+ β”‚ β”‚ β”œβ”€β”€ ...
204
+ β”‚ β”‚ └── n.jpg
205
+ β”‚ β”œβ”€β”€ exo_cam/
206
+ β”‚ β”‚ β”œβ”€β”€ 0.jpg
207
+ β”‚ β”‚ β”œβ”€β”€ ...
208
+ β”‚ β”‚ └── n.jpg
209
+ β”‚ └── annotation.json
210
+ β”œβ”€β”€ ...
211
+ β”œβ”€β”€ take_id_n/
212
+ └── split.json
213
+ ```
214
+
215
+ Then run the official SegSwap pair-generation script:
216
+
217
+ [create_pairs.py](https://github.com/EGO4D/ego-exo4d-relation/blob/main/correspondence/SegSwap/data/create_pairs.py)
218
+
219
+ This will generate:
220
+
221
+ ```text
222
+ train_egoexo_pairs.json
223
+ train_exoego_pairs.json
224
+ val_egoexo_pairs.json
225
+ val_exoego_pairs.json
226
+ ```
227
+
228
+ ---
229
+
230
+ #### Configure Dataset Path
231
+
232
+ If the Ego-Exo4D dataset has already been downloaded, modify:
233
+
234
+ ```text
235
+ src/dataloader.py
236
+ ```
237
+
238
+ and set:
239
+
240
+ ```python
241
+ EGOEXO4D_ROOT = "your/data/path"
242
+ ```
243
+
244
+ ---
245
+
246
+ ### Data Preprocessing
247
+ > We provide all intermediate result files generated from the following preprocessing steps. Therefore, if you have already downloaded the Ego-Exo4D dataset, you can directly use the provided files without rerunning the preprocessing pipeline. Nevertheless, we still release the complete data preprocessing code to support further community research and help readers better understand our pipeline and methodology.
248
+
249
+ #### Generate Scene JSON
250
+ This step reorganizes the dataset structure and converts the pair_json to the following hierarchical JSON format:
251
+
252
+ ```text
253
+ scene
254
+ └── [obj_info]
255
+ β”œβ”€β”€ ego_info
256
+ β”‚ β”œβ”€β”€ ego_rgb
257
+ β”‚ └── ego_mask
258
+ └── exo_info
259
+ β”œβ”€β”€ exo_rfb
260
+ └── exo_mask
261
+ ```
262
+
263
+ where each `scene` contains multiple object annotations (`obj_info`), and each object stores the corresponding ego-view and exo-view information, including RGB frames (`*_rgb`) and segmentation masks (`*_mask`). Meanwhile, only objects that simultaneously appear in both ego and exo views are retained.
264
+
265
+
266
+ ```bash
267
+ cd data
268
+ python gen_scenes.py
269
+
270
+ # Or, downloading from huggingface
271
+ huggingface-cli download zbbhhh/VGGT-S train_scenes.json --local-dir data
272
+ ```
273
+
274
+ Outputs:
275
+
276
+ ```text
277
+ train_scenes.json
278
+ val_scenes.json
279
+ ```
280
+
281
+ ---
282
+
283
+ #### Generate Single-Object JSON
284
+ This step converts `train_scenes.json` and `val_scenes.json` into a sample-based format, where each individual object instance is treated as a training sample for convenient dataloader indexing and loading.
285
+
286
+ Each sample follows the format:
287
+
288
+ ```text
289
+ scene_id//ego_cam//exo_cam//object//frame_id
290
+ ```
291
+
292
+ For example:
293
+
294
+ ```text
295
+ c9e0bbae-4092-4ab1-95cd-16b905709a0e//aria01_214-1//gp01//white spatula_0//002160
296
+ ```
297
+
298
+ which represents:
299
+
300
+ * `scene_id`: `c9e0bbae-4092-4ab1-95cd-16b905709a0e`
301
+ * `ego_cam`: `aria01_214-1`
302
+ * `exo_cam`: `gp01`
303
+ * `object`: `white spatula_0`
304
+ * `frame_id`: `002160`
305
+
306
+ ```bash
307
+ python gen_one_object.py
308
+
309
+ # Or, downloading from huggingface
310
+ huggingface-cli download zbbhhh/VGGT-S train_obj.json --local-dir data
311
+ ```
312
+
313
+ Outputs:
314
+
315
+ ```text
316
+ train_obj.json
317
+ val_obj.json
318
+ ```
319
+
320
+ ---
321
+
322
+ #### Generate VGGT Projected Points
323
+ This step precomputes the VGGT projected points as the first-stage mapping points and saves them offline. By caching these mappings in advance, the training and inference stages can directly perform the second-stage mapping without rerunning the initial VGGT projection process, significantly reducing computation time.
324
+
325
+ Optionally, the first-stage mapping can also be performed online if needed.
326
+
327
+ ##### Ego β†’ Exo
328
+
329
+ ```bash
330
+ python extract_point_g2x.py
331
+ ```
332
+
333
+ Outputs:
334
+
335
+ ```text
336
+ train_obj_wp_g2x.json
337
+ val_obj_wp_g2x.json
338
+ ```
339
+
340
+ ##### Exo β†’ Ego
341
+
342
+ ```bash
343
+ python extract_point_x2g.py
344
+ ```
345
+
346
+ Outputs:
347
+
348
+ ```text
349
+ train_obj_wp_x2g.json
350
+ val_obj_wp_x2g.json
351
+ ```
352
+
353
+ ---
354
+
355
+ #### Merge Point Annotations
356
+ This step merges the projected points generated in the previous step and produces the final data annotation JSON file used for training and inference.
357
+
358
+ ```bash
359
+ python merge_point.py
360
+
361
+ # Or, downloading from huggingface
362
+ huggingface-cli download zbbhhh/VGGT-S train_obj_wp.json --local-dir data
363
+ ```
364
+
365
+ Final outputs:
366
+
367
+ ```text
368
+ train_obj_wp.json
369
+ val_obj_wp.json
370
+ ```
371
+
372
+ ---
373
+
374
+ ### Training & Validation
375
+
376
+ Navigate to the experiment directory:
377
+
378
+ ```bash
379
+ cd src/main_exp
380
+ ```
381
+
382
+ Launch distributed training:
383
+
384
+ ```bash
385
+ CUDA_VISIBLE_DEVICES=0,1 \
386
+ python -m torch.distributed.run \
387
+ --nproc_per_node=2 \
388
+ --master_port=29600 \
389
+ hybrid.py \
390
+ --config hybrid.yaml
391
+ ```
392
+
393
+ > Training and validation only require modifying the parameters in `hybrid.yaml`, where all configuration parameters are carefully explained.
394
+ ---
395
+
396
+
397
+ ## πŸ“ Citation
398
+
399
+ If you find this work useful, please consider citing our paper:
400
+
401
+ ```bibtex
402
+ @article{gao2026vggt,
403
+ title={VGGT-Segmentor: Geometry-Enhanced Cross-View Segmentation},
404
+ author={Gao, Yulu and Zhang, Bohao and Tang, Zongheng and Liao, Jitong and Wu, Wenjun and Liu, Si},
405
+ journal={arXiv preprint arXiv:2604.13596},
406
+ year={2026}
407
+ }
408
+ ```
409
+
410
+ ## πŸ“„ License
411
+
412
+ This project is licensed under the Apache-2.0 License. See [LICENSE](LICENSE.txt) for more information.
413
+
414
+ ## πŸ™ Acknowledgement
415
+
416
+ This project is built upon several excellent open-source projects:
417
+
418
+ * [VGGT](https://github.com/facebookresearch/vggt)
419
+ * [EgoExo4d](https://github.com/EGO4D/ego-exo4d-relation)
420
+ * [SAM2](https://github.com/facebookresearch/sam2)
421
+
422
+ We thank the authors for releasing their code and models to the community.