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
f4dea28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<div align="center">

<h1>VGGT-Segmentor: Geometry-Enhanced Cross-View Segmentation</h1>

<div>
    <a href='https://scholar.google.com/citations?user=s3u33VAAAAAJ&hl=en&oi=ao' target='_blank'>Yulu Gao*</a><sup>1</sup>&emsp;
    <a href='https://github.com/bohaozhang007' target='_blank'>Bohao Zhang*</a><sup>2</sup>&emsp;
    <a href='https://scholar.google.com/citations?user=jrgMNxEAAAAJ&hl=en&oi=ao' target='_blank'>Zongheng Tang</a><sup>1</sup>&emsp;
    <a href='https://github.com/nikkukun' target='_blank'>Jitong Liao</a><sup>2</sup>&emsp;
    <a href='https://iai.buaa.edu.cn/info/1013/1093.htm' target='_blank'>Wenjun Wu</a><sup>2</sup>&emsp;
    <a href='https://scholar.google.com/citations?user=-QtVtNEAAAAJ&hl=en&oi=ao' target='_blank'>Si Liu†</a><sup>2</sup>
</div>
<div>
    <sup>1</sup>Hangzhou International Innovation Institute of Beihang University 1&emsp;
    <sup>2</sup>Beihang University 2
</div>

<div>
    <strong>CVPR 2026 Oral πŸŽ‰</strong>
</div>

<div>
    <h4 align="center">
        <a href="https://bohaozhang007.github.io/VGGT-S-project-page" target='_blank'>
        <img src="https://img.shields.io/badge/Project-Page-green">
        </a>
        <a href="https://github.com/buaa-colalab/VGGT-S">
        <img src='https://img.shields.io/badge/GitHub-Repository-black?logo=github'>
        </a>
        <a href="https://arxiv.org/abs/2604.13596" target='_blank'>
        <img src="https://img.shields.io/badge/arXiv-2604.13596-b31b1b.svg">
        </a>
        <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'>
        <img src="https://img.shields.io/badge/Cite-BibTeX-blue">
        </a>
        <a href="https://www.youtube.com/watch?v=56TSdPqQtgA">
        <img src='https://img.shields.io/badge/YouTube-Video-red?logo=youtube'>
        </a>
    </h4>
</div>

<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>

<div align="center">
    <img src="https://raw.githubusercontent.com/bohaozhang007/VGGT-S-project-page/main/static/images/compressed-repo-demo.gif" width="100%">
</div>

</div>


## πŸ“’ News

* **[2026-05-15]** πŸš€ Code and checkpoint are open-sourced.
* **[2026-04-15]** πŸ”₯ VGGT-Segmentor paper is released on arxiv.


## πŸ’‘ Highlights

* **Union Segmentation Head**. We design this head to effectively translate VGGT’s high-level feature alignment into precise segmentation masks.
* **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.
* **New SOTA Results**. Our proposed VGGT-Segmentor achieves state-of-the-art results on EgoExo4d dataset.


## πŸ› οΈ Usage
### Installation

#### Clone Repository

* Clone [VGGT-S](https://github.com/buaa-colalab/VGGT-S)

```bash
git clone https://github.com/buaa-colalab/VGGT-S.git
cd VGGT-S
```

#### Create Environment

```bash
conda create -n vggts python=3.10
conda activate vggts
```

#### Install VGGT Dependency

This project is built upon [VGGT](https://github.com/facebookresearch/vggt), proposed in the CVPR 2025 Best Paper:

> Wang et al., β€œVGGT: Visual Geometry Grounded Transformer”, CVPR 2025.

Please clone the official VGGT repository under `third_party`:

```bash
mkdir -p third_party && cd third_party
git clone https://github.com/facebookresearch/vggt.git vggt_main
cd vggt_main
pip install -r requirements.txt # This is for VGGT
pip install -e .

# Last, download the VGGT Checkpoint, name it model.pt and place it under vggt_main folder.
```

The directory structure should look like:

```text
VGGT-S/
β”œβ”€β”€ src/
β”œβ”€β”€ data/
β”œβ”€β”€ third_party/
β”‚   └── vggt_main/
β”‚           └── model.pt
└── requirements.txt
```

#### Install Requirements

```bash
cd VGGT-S
pip install -r requirements.txt # This is for VGGT-S
hf download zbbhhh/VGGT-S main_exp.pth --local-dir official_ckpts # Download checkpoint
```

---

### Modify VGGT Track Head

To extract VGGT encoder feature maps for downstream correspondence learning, please modify the `forward` function in:

```text
third_party/vggt_main/vggt/heads/track_head.py
```

Replace the original `forward` function (around Line 72) with the following implementation:

```python
def forward(self, aggregated_tokens_list, images, patch_start_idx, query_points=None, iters=None, feat=False):
    """
    Forward pass of the TrackHead.

    Args:
        aggregated_tokens_list (list): List of aggregated tokens from the backbone.
        images (torch.Tensor): Input images of shape (B, S, C, H, W), where:
                                B = batch size,
                                S = sequence length.
        patch_start_idx (int): Starting index for patch tokens.
        query_points (torch.Tensor, optional): Initial query points to track.
                                                If None, points are initialized automatically.
        iters (int, optional): Number of refinement iterations.
                                If None, uses self.iters.
        feat (bool, optional): Whether to additionally return feature maps.

    Returns:
        tuple:
            - coord_preds (torch.Tensor): Predicted coordinates.
            - vis_scores (torch.Tensor): Visibility scores.
            - conf_scores (torch.Tensor): Confidence scores.
            - feature_maps (torch.Tensor, optional): Extracted VGGT feature maps.
    """

    B, S, _, H, W = images.shape

    # Extract feature maps from VGGT tokens
    # Shape: (B, S, C, H//2, W//2)
    feature_maps = self.feature_extractor(
        aggregated_tokens_list,
        images,
        patch_start_idx
    )

    # Use default iterations if not specified
    if iters is None:
        iters = self.iters

    # Tracking
    coord_preds, vis_scores, conf_scores = self.tracker(
        query_points=query_points,
        fmaps=feature_maps,
        iters=iters
    )

    if feat:
        return coord_preds, vis_scores, conf_scores, feature_maps

    return coord_preds, vis_scores, conf_scores
```

#### Optional

We observe that VGGT recomputes the 2D positional embeddings during every forward pass, even when the input image resolution remains unchanged. To accelerate both training and inference, we adapt the implementation by precomputing the 2D positional embeddings offline and loading them directly at runtime, thereby avoiding redundant computations.

1. Generate the 2D positional embeddings using `gen_pos_embed.py`:

```bash
python gen_pos_embed.py --img_H 518 --img_W 518
```

We also provide precomputed positional embeddings for various commonly used image resolutions on [Hugging Face](https://huggingface.co/zbbhhh/VGGT-S).

2. Modify the VGGT tracking head to use the precomputed embeddings.

Open:

```text
third_party/vggt_main/vggt/heads/track_modules/base_track_predictor.py
```

Add the following line at the end of the `__init__` method in the `BaseTrackerPredictor` class, around [base_track_predictor.py#L81](https://github.com/facebookresearch/vggt/blob/main/vggt/heads/track_modules/base_track_predictor.py#L81):

```python
self.pos_embed = None
```

This attribute is used to cache the loaded positional embeddings.

Then, replace the following line in [base_track_predictor.py#L149](https://github.com/facebookresearch/vggt/blob/main/vggt/heads/track_modules/base_track_predictor.py#L149):

```python
pos_embed = get_2d_sincos_pos_embed(self.transformer_dim, grid_size=(HH, WW)).to(query_points.device)
```

with:

```python
pos_emb_pt = (
    f"vggt_main/pos_embed/"
    f"pos_embed_{self.transformer_dim}_{HH}_{WW}.pt"
)

assert os.path.exists(pos_emb_pt), (
    f"[BUG] Positional embedding file not found: {pos_emb_pt}"
)

if self.pos_embed is None:
    self.pos_embed = torch.load(pos_emb_pt).to(query_points.device)

pos_embed = self.pos_embed
```

---

### Dataset Preparation

#### Download Ego-Exo4D

Please follow the official [SegSwap Ego-Exo4D correspondence pipeline](https://github.com/EGO4D/ego-exo4d-relation/tree/main/correspondence/SegSwap) to:

1. Download the Ego-Exo4D dataset
2. Extract video frames into images
3. Generate correspondence pairs

After preprocessing, the dataset should be organized as:

```text
data_root/
β”œβ”€β”€ take_id_01/
β”‚   β”œβ”€β”€ ego_cam/
β”‚   β”‚   β”œβ”€β”€ 0.jpg
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── n.jpg
β”‚   β”œβ”€β”€ exo_cam/
β”‚   β”‚   β”œβ”€β”€ 0.jpg
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── n.jpg
β”‚   └── annotation.json
β”œβ”€β”€ ...
β”œβ”€β”€ take_id_n/
└── split.json
```

Then run the official SegSwap pair-generation script:

[create_pairs.py](https://github.com/EGO4D/ego-exo4d-relation/blob/main/correspondence/SegSwap/data/create_pairs.py)

This will generate:

```text
train_egoexo_pairs.json
train_exoego_pairs.json
val_egoexo_pairs.json
val_exoego_pairs.json
```

---

#### Configure Dataset Path

If the Ego-Exo4D dataset has already been downloaded, modify:

```text
src/dataloader.py
```

and set:

```python
EGOEXO4D_ROOT = "your/data/path"
```

---

### Data Preprocessing
> 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.

#### Generate Scene JSON
This step reorganizes the dataset structure and converts the pair_json to the following hierarchical JSON format:

```text
scene
└── [obj_info]
    β”œβ”€β”€ ego_info
    β”‚   β”œβ”€β”€ ego_rgb
    β”‚   └── ego_mask
    └── exo_info
        β”œβ”€β”€ exo_rfb
        └── exo_mask
```

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.


```bash
cd data
python gen_scenes.py

# Or, downloading from huggingface
huggingface-cli download zbbhhh/VGGT-S train_scenes.json --local-dir data
```

Outputs:

```text
train_scenes.json
val_scenes.json
```

---

#### Generate Single-Object JSON
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.

Each sample follows the format:

```text
scene_id//ego_cam//exo_cam//object//frame_id
```

For example:

```text
c9e0bbae-4092-4ab1-95cd-16b905709a0e//aria01_214-1//gp01//white spatula_0//002160
```

which represents:

* `scene_id`: `c9e0bbae-4092-4ab1-95cd-16b905709a0e`
* `ego_cam`: `aria01_214-1`
* `exo_cam`: `gp01`
* `object`: `white spatula_0`
* `frame_id`: `002160`

```bash
python gen_one_object.py

# Or, downloading from huggingface
huggingface-cli download zbbhhh/VGGT-S train_obj.json --local-dir data
```

Outputs:

```text
train_obj.json
val_obj.json
```

---

#### Generate VGGT Projected Points
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.

Optionally, the first-stage mapping can also be performed online if needed.

##### Ego β†’ Exo

```bash
python extract_point_g2x.py
```

Outputs:

```text
train_obj_wp_g2x.json
val_obj_wp_g2x.json
```

##### Exo β†’ Ego

```bash
python extract_point_x2g.py
```

Outputs:

```text
train_obj_wp_x2g.json
val_obj_wp_x2g.json
```

---

#### Merge Point Annotations
This step merges the projected points generated in the previous step and produces the final data annotation JSON file used for training and inference.

```bash
python merge_point.py

# Or, downloading from huggingface
huggingface-cli download zbbhhh/VGGT-S train_obj_wp.json --local-dir data
```

Final outputs:

```text
train_obj_wp.json
val_obj_wp.json
```

---

### Training & Validation

Navigate to the experiment directory:

```bash
cd src/main_exp
```

Launch distributed training:

```bash
CUDA_VISIBLE_DEVICES=0,1 \
python -m torch.distributed.run \
    --nproc_per_node=2 \
    --master_port=29600 \
    hybrid.py \
    --config hybrid.yaml
```

> Training and validation only require modifying the parameters in `hybrid.yaml`, where all configuration parameters are carefully explained.
---


## πŸ“ Citation

If you find this work useful, please consider citing our paper:

```bibtex
@article{gao2026vggt,
  title={VGGT-Segmentor: Geometry-Enhanced Cross-View Segmentation},
  author={Gao, Yulu and Zhang, Bohao and Tang, Zongheng and Liao, Jitong and Wu, Wenjun and Liu, Si},
  journal={arXiv preprint arXiv:2604.13596},
  year={2026}
}
```

## πŸ“„ License

This project is licensed under the Apache-2.0 License. See [LICENSE](LICENSE.txt) for more information.

## πŸ™ Acknowledgement

This project is built upon several excellent open-source projects:

* [VGGT](https://github.com/facebookresearch/vggt)
* [EgoExo4d](https://github.com/EGO4D/ego-exo4d-relation)
* [SAM2](https://github.com/facebookresearch/sam2)

We thank the authors for releasing their code and models to the community.