AGT / code /README.md
MRBSTUDIO's picture
Update the inference and evaluation code
2ad60ce verified
|
Raw History Blame Contribute Delete
10.8 kB
<div align="center">
# AGT: Amodal 4D Reconstruction from Obstructed Driving Videos
[![arXiv](https://img.shields.io/badge/arXiv-coming%20soon-b31b1b.svg)](#citation)
[![Project Page](https://img.shields.io/badge/Project-Page-2ea44f.svg)](https://agt4d.github.io/)
[![Weights](https://img.shields.io/badge/%F0%9F%A4%97%20Weights-MRBSTUDIO%2FAGT-ffcc4d.svg)](https://huggingface.co/MRBSTUDIO/AGT)
[![Dataset](https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-AmodalDrive-ffcc4d.svg)](https://huggingface.co/datasets/MRBSTUDIO/AmodalDrive)
[Bodong Bi](https://bodongbi.pages.dev/)<sup>1*</sup>,
[Nuo Chen](https://nuochen1203.github.io/)<sup>2*</sup>,
[Hongyu Xu](https://hyxu2006.github.io/)<sup>3</sup>,
[Xiaoqiang Kong](https://scholar.google.com/citations?user=9w1tWaUAAAAJ)<sup>2</sup>,
[Baoru Huang](https://baoru.netlify.app/)<sup>4</sup>,
[Anh Nguyen](https://www.csc.liv.ac.uk/~anguyen/)<sup>4</sup>,
[Yang Zhou](https://yangzhou.engr.tamu.edu/)<sup>2</sup>,
[Zhiwen Fan](https://zhiwenfan.github.io/)<sup>2&dagger;</sup>
<sup>1</sup>University of Michigan &nbsp; <sup>2</sup>Texas A&M University &nbsp; <sup>3</sup>General Motors &nbsp; <sup>4</sup>University of Liverpool
<sup>*</sup>Equal contribution &nbsp; <sup>&dagger;</sup>Corresponding author
<img src="assets/teaser.webp" width="96%" alt="AGT reconstructs a complete 4D scene from an obstructed driving video">
</div>
## Overview
AGT reconstructs a complete 4D Gaussian scene from a driving video whose every frame is partly hidden by the hood,
the dashboard, windshield reflections or watermarks.
- **Amodal geometry recovery.** The occluder mask masks the occluder tokens in the global attention layers, so that the
feed-forward model recovers cameras, depth and motion from the obstructed frames in a single pass.
- **Observed appearance reconstruction.** The observability of every pixel is computed from this geometry, and
appearance is reconstructed only in the observed regions.
- **Generative completion.** The unobserved regions are filled by an image diffusion model and optimized into the
Gaussian scene.
- **AmodalDrive.** The model is trained on AmodalDrive, a paired dataset that composites occluder layers separated
from in-the-wild dashcam videos onto clean driving scenes.
<div align="center">
<img src="assets/pipeline.webp" width="96%" alt="AGT pipeline">
</div>
## Installation
```bash
git clone https://github.com/phai-lab/AGT.git
cd AGT
```
**Main environment** (reconstruction, scene optimization, evaluation):
```bash
conda create -n agt python=3.10 -y
conda activate agt
pip install torch==2.4.1 torchvision==0.19.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
pip install --no-build-isolation --no-binary gsplat gsplat==1.5.3
pip install --no-build-isolation third_party/dggt/third_party/pointops2
```
**Completion environment** (generative completion):
```bash
conda create -n agt-completion python=3.12 -y
conda activate agt-completion
pip install torch==2.9.1 --index-url https://download.pytorch.org/whl/cu128
pip install -r requirements-completion.txt
```
<details>
<summary>Optional environments</summary>
- **Mask generation for your own clips**: SAM 3 and the Qwen3.5 verifier each run in their own environment. Install
SAM 3 by following its repository, and install `requirements-masks.txt` for the verifier. The verifier runs
`Qwen/Qwen3.5-35B-A3B` locally with vLLM.
- **Benchmark rebuild**: `requirements-rebuild.txt` and a static build of ffmpeg 7.0.2.
</details>
## Checkpoints
The AGT weights are hosted at [MRBSTUDIO/AGT](https://huggingface.co/MRBSTUDIO/AGT).
```bash
hf download MRBSTUDIO/AGT agt_reconstruction.safetensors agt_completion_lora.safetensors --local-dir checkpoints/
hf download zbww/tapip3d tapip3d_final.pth --local-dir checkpoints/
mv checkpoints/tapip3d_final.pth checkpoints/motion_head.pth
```
| File | Content | Size |
|---|---|---|
| `agt_reconstruction.safetensors` | feed-forward reconstruction model | 4.9 GB |
| `agt_completion_lora.safetensors` | LoRA of FLUX.1 Fill used in the generative completion | 0.7 GB |
FLUX.1-Fill-dev and SegFormer are loaded from the Hugging Face Hub, or from local copies given with `--flux` and
`--segformer`.
## Demo
The example clips of the project page are part of the dataset repository. Run the commands from the repository root.
```bash
hf download MRBSTUDIO/AmodalDrive --repo-type dataset --include "examples/*" --local-dir AmodalDrive
python inference.py \
--case AmodalDrive/examples/real-a \
--out outputs/real-a \
--completion-python "$(conda run -n agt-completion which python)"
```
Add `--reconstruction-only` to run AGT without generative completion; this needs only the main environment.
Outputs are rendered at 518x294.
## Inference on your own video
Cut a clip from the video:
```bash
python tools/prepare_clip.py --video drive.mp4 --start 12 --out work/export
```
Generate its occluder mask. SAM 3 proposes regions in the SAM 3 environment, Qwen3.5 verifies them in the verifier
environment, and the frames vote in the main environment:
```bash
python tools/make_masks.py --export work/export --out work/masks --stage propose
python tools/make_masks.py --export work/export --out work/masks --stage verify
python tools/make_masks.py --export work/export --out work/masks --stage finish
```
Run AGT:
```bash
python inference.py --export work/export --mask-dir work/masks --out outputs/my_clip \
--completion-python "$(conda run -n agt-completion which python)"
```
The output directory holds the rendered frames and depth of every clip.
## Evaluation
Build the benchmark first, see [Dataset](#dataset). Both commands use the precomputed occluder masks of AmodalDrive.
**AGT without completion**:
```bash
python -m agt.recon.reconstruct render --inputs AmodalDrive/exports/test --out outputs/test_feedforward \
--masks dataset --data-root AmodalDrive
python eval/score.py --config configs/eval/test_waymo.json --data-root AmodalDrive \
--export AmodalDrive/exports/test --method outputs/test_feedforward --out scores/test_feedforward
```
**AGT** (the method directory is `<out>/final`):
```bash
python inference.py --export AmodalDrive/exports/test --masks dataset --data-root AmodalDrive \
--out outputs/test_full --completion-python "$(conda run -n agt-completion which python)"
python eval/score.py --config configs/eval/test_waymo.json --data-root AmodalDrive \
--export AmodalDrive/exports/test --method outputs/test_full/final --out scores/test_full
```
`--clips ID ...` restricts `inference.py` to a subset of the export. `configs/eval/val_waymo.json` scores the
validation export.
## Dataset
[AmodalDrive](https://huggingface.co/datasets/MRBSTUDIO/AmodalDrive) provides the occluder layers, the pairing
tables, the splits, the occluder masks and the example clips.
```bash
hf download MRBSTUDIO/AmodalDrive --repo-type dataset --local-dir AmodalDrive
```
Download the [Waymo Open Dataset](https://waymo.com/open/) v2.0.1, then run the scripts below to build the composed
validation and test data. They preprocess the scenes, compute the labels used by the scorer, and compose and export
the clips.
```bash
python tools/build_waymo_scenes.py --data-root AmodalDrive --waymo-root WAYMO --split val --split test \
--ffmpeg /path/to/ffmpeg --ffprobe /path/to/ffprobe
python tools/make_labels.py depth --data-root AmodalDrive --waymo-root WAYMO --split val --split test
python tools/make_labels.py sky --data-root AmodalDrive --waymo-root WAYMO --split val --split test
python tools/make_labels.py visibility --data-root AmodalDrive --dggt-checkpoint checkpoints/model_latest_waymo.pt \
--split val --split test
python tools/export_clips.py --data-root AmodalDrive --split val --out AmodalDrive/exports/val
python tools/export_clips.py --data-root AmodalDrive --split test --protocol full --out AmodalDrive/exports/test
```
`WAYMO` is the parquet download (`<split>/<component>/<segment>.parquet`, splits `validation`, `testing` and
`testing_location`). The visibility label uses the depth of the released DGGT Waymo checkpoint, downloaded from
[xiaomi-research/dggt](https://huggingface.co/xiaomi-research/dggt/resolve/main/model_latest_waymo.pt).
## Code Structure
```text
AGT/
β”œβ”€β”€ inference.py runs AGT on an example case, a new clip or a benchmark export
β”œβ”€β”€ agt/
β”‚ β”œβ”€β”€ masks/ occluder mask generation with a pluggable verifier
β”‚ β”œβ”€β”€ prepare/ clip export from a video
β”‚ β”œβ”€β”€ model/ model construction, masked attention and observability
β”‚ β”œβ”€β”€ recon/ feed-forward reconstruction and rendering
β”‚ β”œβ”€β”€ completion/ render completion
β”‚ β”œβ”€β”€ refine/ scene optimization
β”‚ β”œβ”€β”€ data/ AmodalDrive reader with on-the-fly composition
β”‚ β”œβ”€β”€ dataset/ scene preprocessing and label generation
β”‚ └── eval/ scorer
β”œβ”€β”€ eval/score.py scoring entry
β”œβ”€β”€ tools/ clip preparation, mask generation, benchmark rebuild
β”œβ”€β”€ configs/ model, completion, scene optimization, mask, dataset and evaluation settings
└── third_party/dggt/ the DGGT files used by this code
```
## Citation
```bibtex
@misc{bi2026agt,
title = {AGT: Amodal 4D Reconstruction from Obstructed Driving Videos},
author = {Bi, Bodong and Chen, Nuo and Xu, Hongyu and Kong, Xiaoqiang and Huang, Baoru and Nguyen, Anh and Zhou, Yang and Fan, Zhiwen},
year = {2026},
note = {arXiv preprint, coming soon}
}
```
## Acknowledgements
This code builds on the following projects. We thank their authors.
- [DGGT](https://xiaomi-research.github.io/dggt/): the feed-forward 4D Gaussian model AGT is fine-tuned from.
- [VGGT](https://github.com/facebookresearch/vggt): the geometry backbone of DGGT.
- [gsplat](https://github.com/nerfstudio-project/gsplat): Gaussian rasterization.
- [FLUX.1-Fill](https://huggingface.co/black-forest-labs/FLUX.1-Fill-dev): the image completion model.
- [TAPIP3D](https://github.com/zbw001/TAPIP3D) and [CoTracker](https://github.com/facebookresearch/co-tracker): the motion head.
- [SAM 3](https://github.com/facebookresearch/sam3) and [Qwen3.5](https://huggingface.co/Qwen/Qwen3.5-35B-A3B): occluder mask generation.
- [Waymo Open Dataset](https://waymo.com/open/), [nuScenes](https://www.nuscenes.org/), [Argoverse 2](https://www.argoverse.org/av2.html), [BDD100K](https://www.vis.xyz/bdd100k/) and [MM-AU](https://github.com/jeffreychou777/LOTVS-MM-AU): data sources.
## License
- **Code**: Apache License 2.0, see `LICENSE`. Vendored third-party code keeps its own license, see `NOTICE`.
- **Weights and dataset**: CC BY-NC 4.0.