pytorch implementation of "Efficiently Reconstructing Dynamic Scenes One π― D4RT at a Time"
74
stars
3
commits
Python
primary language
Jun 15, 2026
updated
PyTorch implementation of D4RT, a feedforward transformer for 4D scene reconstruction from video.
(u, v, t_src, t_tgt, t_cam) - pixel coordinates and temporal indices# Clone repository
git clone https://github.com/jiangyurong609/d4rt-pytorch.git
cd d4rt
# Install dependencies
pip install -r requirements.txt
# Optional: Install pytorch3d for optimized Umeyama alignment
pip install pytorch3d
import torch
from models import D4RT
# Initialize model
model = D4RT(
encoder_variant='base',
img_size=256,
temporal_size=24,
decoder_depth=8
)
# Input video: (B, T, H, W, C)
video = torch.randn(1, 24, 256, 256, 3)
# Query points
coords = torch.rand(1, 100, 2) # (u, v) in [0, 1]
t_src = torch.zeros(1, 100, dtype=torch.long)
t_tgt = torch.ones(1, 100, dtype=torch.long) * 10
t_cam = torch.zeros(1, 100, dtype=torch.long)
# Forward pass
outputs = model(video, coords, t_src, t_tgt, t_cam)
# Outputs: pos_3d, pos_2d, visibility, displacement, normal, confidence
print(outputs['pos_3d'].shape) # (1, 100, 3)
See DATA.md for dataset download instructions.
Recommended for training: PointOdyssey (~170GB with full ground truth)
# Quick start with sample set (3.1GB)
pip install huggingface_hub
huggingface-cli download aharley/pointodyssey sample.tar.gz --repo-type dataset --local-dir ./data/pointodyssey
# Train on PointOdyssey
python train.py \
--config configs/d4rt_base.yaml \
--data.train_root ./data/pointodyssey \
--data.train_split train
# Distributed training
torchrun --nproc_per_node=4 train.py \
--config configs/d4rt_base.yaml
# Evaluate depth estimation
python evaluate.py \
--config configs/d4rt_base.yaml \
--checkpoint checkpoints/d4rt_base.pth \
--task depth \
--data_root ./data/sintel
# Evaluate point tracking
python evaluate.py \
--task tracking \
--data_root ./data/pointodyssey
D4RT
βββ Encoder (ViT-based)
β βββ 3D Patch Embedding (t=2, h=8, w=8)
β βββ Positional Embedding (spatial + temporal)
β βββ Transformer Blocks (interleaved local/global attention)
β
βββ Decoder (Cross-attention)
βββ Query Embedding
β βββ Fourier (u, v coordinates)
β βββ Timestep (t_src, t_tgt, t_cam)
β βββ Patch (local RGB context)
βββ Cross-Attention Blocks
βββ Output Heads (3D pos, 2D pos, visibility, etc.)
| Task | Query | Output |
|---|---|---|
| Depth | (u, v, t, t, t) | 3D position in camera frame |
| Tracking | (u, v, t_src, t_tgt, t_src) | 2D position at t_tgt |
| 3D Tracking | (u, v, t_src, t_tgt, t_cam) | 3D position at t_tgt in t_cam frame |
| Point Cloud | Grid queries at all frames | Dense 3D reconstruction |
d4rt/
βββ models/
β βββ d4rt.py # Main model
β βββ encoder.py # ViT encoder with timm support
β βββ decoder.py # Cross-attention decoder
β βββ embeddings.py # Fourier, timestep, patch embeddings
βββ losses/
β βββ losses.py # Multi-task loss functions
βββ data/
β βββ dataset.py # Base dataset and query sampler
β βββ video_dataset.py # Dataset implementations
βββ utils/
β βββ camera.py # Umeyama alignment, pose estimation
β βββ metrics.py # Evaluation metrics
β βββ visualization.py # Visualization utilities
βββ configs/
β βββ d4rt_base.yaml
β βββ d4rt_large.yaml
βββ train.py
βββ evaluate.py
βββ inference.py
βββ DATA.md # Dataset guide
βββ requirements.txt
@article{d4rt2024,
title={D4RT: Dynamic 4D Reconstruction Transformer},
author={...},
journal={...},
year={2024}
}
MIT License
3 commits
Python
87.4%
Shell
12.6%
pytorch implementation of "Efficiently Reconstructing Dynamic Scenes One π― D4RT at a Time"
74
stars
3
commits
Python
primary language
Jun 15, 2026
updated
PyTorch implementation of D4RT, a feedforward transformer for 4D scene reconstruction from video.
(u, v, t_src, t_tgt, t_cam) - pixel coordinates and temporal indices# Clone repository
git clone https://github.com/jiangyurong609/d4rt-pytorch.git
cd d4rt
# Install dependencies
pip install -r requirements.txt
# Optional: Install pytorch3d for optimized Umeyama alignment
pip install pytorch3d
import torch
from models import D4RT
# Initialize model
model = D4RT(
encoder_variant='base',
img_size=256,
temporal_size=24,
decoder_depth=8
)
# Input video: (B, T, H, W, C)
video = torch.randn(1, 24, 256, 256, 3)
# Query points
coords = torch.rand(1, 100, 2) # (u, v) in [0, 1]
t_src = torch.zeros(1, 100, dtype=torch.long)
t_tgt = torch.ones(1, 100, dtype=torch.long) * 10
t_cam = torch.zeros(1, 100, dtype=torch.long)
# Forward pass
outputs = model(video, coords, t_src, t_tgt, t_cam)
# Outputs: pos_3d, pos_2d, visibility, displacement, normal, confidence
print(outputs['pos_3d'].shape) # (1, 100, 3)
See DATA.md for dataset download instructions.
Recommended for training: PointOdyssey (~170GB with full ground truth)
# Quick start with sample set (3.1GB)
pip install huggingface_hub
huggingface-cli download aharley/pointodyssey sample.tar.gz --repo-type dataset --local-dir ./data/pointodyssey
# Train on PointOdyssey
python train.py \
--config configs/d4rt_base.yaml \
--data.train_root ./data/pointodyssey \
--data.train_split train
# Distributed training
torchrun --nproc_per_node=4 train.py \
--config configs/d4rt_base.yaml
# Evaluate depth estimation
python evaluate.py \
--config configs/d4rt_base.yaml \
--checkpoint checkpoints/d4rt_base.pth \
--task depth \
--data_root ./data/sintel
# Evaluate point tracking
python evaluate.py \
--task tracking \
--data_root ./data/pointodyssey
D4RT
βββ Encoder (ViT-based)
β βββ 3D Patch Embedding (t=2, h=8, w=8)
β βββ Positional Embedding (spatial + temporal)
β βββ Transformer Blocks (interleaved local/global attention)
β
βββ Decoder (Cross-attention)
βββ Query Embedding
β βββ Fourier (u, v coordinates)
β βββ Timestep (t_src, t_tgt, t_cam)
β βββ Patch (local RGB context)
βββ Cross-Attention Blocks
βββ Output Heads (3D pos, 2D pos, visibility, etc.)
| Task | Query | Output |
|---|---|---|
| Depth | (u, v, t, t, t) | 3D position in camera frame |
| Tracking | (u, v, t_src, t_tgt, t_src) | 2D position at t_tgt |
| 3D Tracking | (u, v, t_src, t_tgt, t_cam) | 3D position at t_tgt in t_cam frame |
| Point Cloud | Grid queries at all frames | Dense 3D reconstruction |
d4rt/
βββ models/
β βββ d4rt.py # Main model
β βββ encoder.py # ViT encoder with timm support
β βββ decoder.py # Cross-attention decoder
β βββ embeddings.py # Fourier, timestep, patch embeddings
βββ losses/
β βββ losses.py # Multi-task loss functions
βββ data/
β βββ dataset.py # Base dataset and query sampler
β βββ video_dataset.py # Dataset implementations
βββ utils/
β βββ camera.py # Umeyama alignment, pose estimation
β βββ metrics.py # Evaluation metrics
β βββ visualization.py # Visualization utilities
βββ configs/
β βββ d4rt_base.yaml
β βββ d4rt_large.yaml
βββ train.py
βββ evaluate.py
βββ inference.py
βββ DATA.md # Dataset guide
βββ requirements.txt
@article{d4rt2024,
title={D4RT: Dynamic 4D Reconstruction Transformer},
author={...},
journal={...},
year={2024}
}
MIT License
3 commits
Python
87.4%
Shell
12.6%