Non-Streaming Teacherμμ Streaming Studentλ‘μ Knowledge Distillationμ ν΅ν
μ€μκ° μ€νΈλ¦¬λ° λΉλμ€ κΉμ΄ μΆμ
π Quick Start β’ π Method β’ π¬ Results β’ π Benchmark
StreamDepthλ λΉλμ€ κΉμ΄ μΆμ (Video Depth Estimation)μ μ€μκ° μ€νΈλ¦¬λ° νκ²½μμ μνν μ μλλ‘ μ€κ³λ νλ μμν¬μ λλ€.
κΈ°μ‘΄μ Video Depth Estimation λͺ¨λΈλ€μ μ 체 λΉλμ€ ν΄λ¦½(batch)μ ν λ²μ μ²λ¦¬ν΄μΌ νλ―λ‘, μ€μκ° μ ν리μΌμ΄μ (μμ¨μ£Όν, AR/VR, λ‘λ΄ λΉμ λ±)μ μ μ©νκΈ° μ΄λ ΅μ΅λλ€. λ³Έ νλ‘μ νΈλ Knowledge Distillation κΈ°λ²μ νμ©νμ¬, Non-streaming Teacher λͺ¨λΈμ μ±λ₯μ μ μ§νλ©΄μλ νλ μ λ¨μ μ€μκ° μΆλ‘ μ΄ κ°λ₯ν Streaming Student λͺ¨λΈμ νμ΅ν©λλ€.
- π΄ Real-time Streaming: νλ μ λ¨μ μμ°¨μ μΆλ‘ μΌλ‘ μ€μκ° μ²λ¦¬ κ°λ₯
- π Knowledge Distillation: Non-streaming Teacherμ μ§μμ Streaming Studentλ‘ ν¨κ³Όμ μΌλ‘ μ μ΄
- π― Temporal Consistency: Causal Attentionκ³Ό Hidden State CachingμΌλ‘ μκ°μ μΌκ΄μ± μ μ§
- β‘ Efficient Inference: μ¬λΌμ΄λ© μλμ° μΊμ κΈ°λ°μ ν¨μ¨μ μΈ λ©λͺ¨λ¦¬ κ΄λ¦¬
| κ΅¬λΆ | Non-Streaming (Teacher) | Streaming (Student) |
|---|---|---|
| μ λ ₯ | μ 체 λΉλμ€ ν΄λ¦½ [B, T, C, H, W] | λ¨μΌ νλ μ [B, 1, C, H, W] |
| Attention | Bidirectional (μλ°©ν₯) | Causal (λ¨λ°©ν₯) |
| μΆλ‘ λ°©μ | Batch μ²λ¦¬ | Frame-by-frame |
| μ€μκ° μ μ© | β λΆκ°λ₯ | β κ°λ₯ |
| λ©λͺ¨λ¦¬ | Tμ λΉλ‘νμ¬ μ¦κ° | κ³ μ (μΊμ μλμ°) |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β StreamDepth Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Input Frame ββββββββββββββββββββ β
β [B,1,3,H,W] βββΆβ DINOv2 Encoder ββββΆ Spatial Features β
β β (ViT-S/L) β [B,1,C,h,w] β
β ββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββ β
β β DPT Temporal β β
β Cached States ββ Head (Causal) βββΆ Depth Map [B,1,H,W] β
β [T-1 frames] β + Motion Module β β
β ββββββββββββββββββββ β
β β β
β βΌ β
β Hidden State Cache β
β (Sliding Window) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
StreamDepthλ 3κ°μ§ ν΅μ¬ μμ€ ν¨μλ₯Ό ν΅ν΄ Teacherμμ Studentλ‘ μ§μμ μ λ¬ν©λλ€:
Teacherμ Studentμ **μ΅μ’ μΆλ ₯(depth map)**μ μ§μ λΉκ΅ν©λλ€:
μ€κ° λ μ΄μ΄μ νΉμ§ ννμ μ ν©νμ¬ Teacherμ ννλ ₯μ μ λ¬ν©λλ€:
Self-Attentionμ Q/K/V κ΄κ³λ₯Ό 보쑴νμ¬ μκ°μ μμ‘΄μ±μ νμ΅ν©λλ€:
# Pseudo-code for training loop
for epoch in range(num_epochs):
for batch in dataloader:
# Teacher: Clip-based inference (frozen)
with torch.no_grad():
teacher_depth = teacher(clip)
# Student: Frame-by-frame streaming
cache = None
for t in range(T):
student_depth, cache = student.stream_step(frame[t], cache)
# Compute losses
loss_depth = depth_loss(student_depth, gt_depth[t])
loss_kd = kd_loss(student_depth, teacher_depth[t])
loss = loss_depth + Ξ»_kd * loss_kd
loss.backward()| Model | Mode | Abs Rel β | RMSE β | Ξ΄β β |
|---|---|---|---|---|
| Video-Depth-Anything | Non-streaming | 0.0XXX | 0.XXX | 0.806 |
| StreamDepth (Ours) | Streaming | 0.0XXX | 0.XXX | 0.837 |
# Clone repository
git clone https://github.com/your-repo/video-stream.git
cd video-stream
# Create conda environment
conda create -n streamdepth python=3.10
conda activate streamdepth
# Install dependencies
pip install -r requirements.txtbash get_weights.sh# Real-time streaming inference on video
python run_streaming.py \
--input_video assets/example_videos/sample.mp4 \
--encoder vits \
--output_dir outputs_streaming# Train with Knowledge Distillation
python train.py \
--pretrained_ckpt checkpoints/video_depth_anything_vits.pth \
--epochs 75 \
--val_dataset_key scannet- KITTI: Outdoor driving scenes
- ScanNet: Indoor scenes
- Sintel: Synthetic sequences
- Bonn: RGB-D dynamic scenes
- NYUv2: Indoor depth benchmark
# Run inference
python benchmark/infer/infer.py \
--infer_path benchmark/output/scannet_stream \
--json_file datasets/scannet/scannet_video_500.json \
--datasets scannet
# Evaluate
bash benchmark/eval/eval_500.sh benchmark/output/scannet_stream benchmark/dataset_extract/datasetvideo-stream/
βββ π train.py # Main training script
βββ π run_streaming.py # Real-time streaming inference
βββ π run_eval_comparison.py # Teacher vs Student evaluation
βββ π config_jh.yaml # Training configuration
β
βββ π video_depth_anything/ # Model implementations
β βββ video_depth.py # Teacher model (Non-streaming)
β βββ video_depth_stream.py # Student model (Streaming)
β βββ dpt_temporal.py # DPT Head with Temporal module
β βββ dinov2.py # DINOv2 backbone
β βββ motion_module/ # Temporal attention modules
β
βββ π utils/
β βββ loss_MiDas.py # Depth loss functions
β βββ loss_kd_aux.py # KD auxiliary losses
β βββ train_helper.py # Training utilities
β
βββ π benchmark/ # Evaluation pipeline
β βββ infer/ # Inference scripts
β βββ eval/ # Evaluation scripts
β βββ dataset_extract/ # Dataset preparation
β
βββ π checkpoints/ # Model weights
βββ π data/ # Data loading utilities
βββ π outputs/ # Training outputs
μ£Όμ νμ΅ μ€μ (config_jh.yaml):
hyper_parameter:
learning_rate: 1.0e-4
batch_size: 4
clip_len: 32 # Frames per training clip
epochs: 75
ratio_ssi: 1.0 # Scale-Shift Invariant loss weight
ratio_tgm: 10.0 # Temporal Gradient Matching loss weight
kd_aux:
enabled: true # Enable Knowledge Distillation
lambda_kd: 0.0001 # KD loss weight
model:
encoder: "vits" # ViT-S (vits) or ViT-L (vitl)
features: 64
num_frames: 32@article{streamdepth2025,
title={StreamDepth: Real-Time Streaming Video Depth Estimation via Knowledge Distillation},
author={Your Name},
journal={arXiv preprint},
year={2025}
}λ³Έ νλ‘μ νΈλ λ€μ μ°κ΅¬λ€μ κΈ°λ°μΌλ‘ ν©λλ€:
- Video-Depth-Anything - Base video depth model
- DINOv2 - Vision encoder
- DistilHuBERT - Feature distillation
- MiniLM - Attention relation distillation
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Made with β€οΈ for Real-time Video Depth Estimation
