Align3R: Aligned Monocular Depth Estimation for Dynamic Videos Jiahao Lu*, Tianyu Huang*, Peng Li, Zhiyang Dou, Cheng Lin, Zhiming Cui, Zhen Dong, Sai-Kit Yeung, Wenping Wang, Yuan Liu Arxiv, 2024.
Align3R estimates temporally consistent video depth, dynamic point clouds, and camera poses from monocular videos.
- Clone this repo:
git clone git@github.com:jiah-cloud/Align3R.git
- Install dependencies:
conda create -n align3r python=3.11 cmake=3.14.0
conda activate align3r
conda install pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia # use the correct version of cuda for your system
pip install -r requirements.txt
# Optional: you can also install additional packages to:
# - add support for HEIC images
# - add pyrender, used to render depthmap in some datasets preprocessing
# - add required packages for visloc.py
pip install -r requirements_optional.txt
- Compile the cuda kernels for RoPE (as in CroCo v2):
cd croco/models/curope/
python setup.py build_ext --inplace
cd ../../../
- Install the monocular depth estimation model Depth Pro and Depth Anything V2:
# Depth Pro
cd third_party/ml-depth-pro
pip install -e .
source get_pretrained_models.sh
# Depth Anything V2
pip install transformers==4.41.2
- Download the corresponding model weights:
π₯π₯π₯ We upload our model weights to the Hugging Face, now you can download them via Align3R (Depth Pro) and Align3R (Depth Anything V2).
# DUSt3R
wget https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth
# Align3R
# If you cannot download the weights using the following scripts, please download them locally.
gdown --fuzzy https://drive.google.com/file/d/1-qhRtgH7rcJMYZ5sWRdkrc2_9wsR1BBG/view?usp=sharing
gdown --fuzzy https://drive.google.com/file/d/1PPmpbASVbFdjXnD3iea-MRIHGmKsS8Vh/view?usp=sharing
# Depth Pro
cd third_party/ml-depth-pro
source get_pretrained_models.sh
# Raft
gdown --fuzzy https://drive.google.com/file/d/1KJxQ7KPuGHlSftsBCV1h2aYpeqQv3OI-/view?usp=drive_link -O models/
To train Align3R, you should download the following dataset:
- SceneFlow (Includes FlyingThings3D, Driving & Monkaa)
- VKITTI
- TartanAir
- Spring
- PointOdyssey
Then use the following script to preprocess the training datasets:
bash datasets_preprocess/preprocess_trainingset.sh
After preprocessing, our folder structure is as follows:
βββ data
βββ PointOdyssey_proc
β βββ train
Β Β βΒ Β βββ val
βββ spring_proc
β βββ train
βββ Tartanair_proc
βββ vkitti_2.0.3_proc
βββ SceneFlow
βββ FlyingThings3D_proc
β βββ TRAIN
β β βββ A
β β βββ B
β Β βΒ βββ C
Β Β β βββ TEST
β βββ A
β βββ B
β Β Β βββ C
βββ Driving_proc
β βββ 35mm_focallength
Β Β β βββ 15mm_focallength
Β βββ Monkaa_proc
To evaluate, you should download the following dataset:
- Sintel
- DAVIS
- Bonn
- TUM dynamics (Dynamic Objects: freiburg3)
For Bonn and TUM dynamics, you should use the following script to preprocess them:
bash datasets_preprocess/preprocess_testset.sh
Our folder structure is as follows:
βββ data
βββ bonn
Β Β βΒ Β βββ rgbd_bonn_dataset
βββ davis
β βββ DAVIS
β βββ JPEGImages
β β βββ 480P
β Β βΒ βββ 1080P
β βββ Annotations
β β βββ 480P
β Β βΒ βββ 1080P
β Β Β βββ ImageSets
β βββ 480P
β Β Β βββ 1080P
βββ MPI-Sintel
β βββ MPI-Sintel-training_images
β β βββ training
β β Β βββ final
β βββ MPI-Sintel-depth-training
β βββ training
β Β βββ camdata_left
β βββ depth
βββ tum
To generate monocular depth maps, you should use the following script:
cd third_party/ml-depth-pro
bash infer.sh
Please download the pretrained DUSt3R weight before training.
bash train.sh
You can run the following demo code on any video. The input path can be either a mp4 video or an image folder.
bash demo.sh
bash depth_test.sh
Please change the --dust3r_dynamic_model_path, --output_postfix, --dataset_name, --depth_prior_name.
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthpro --dataset_name=sintel --eval --output_postfix="results/sintel_depth_ours_depthpro"
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthanything --dataset_name=sintel --eval --output_postfix="results/sintel_depth_ours_depthanything"
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthpro --dataset_name=PointOdyssey --eval --output_postfix="results/PointOdyssey_depth_ours_depthpro"
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthanything --dataset_name=PointOdyssey --eval --output_postfix="results/PointOdyssey_depth_ours_depthanything"
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthpro --dataset_name=FlyingThings3D --eval --output_postfix="results/FlyingThings3D_depth_ours_depthpro"
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthanything --dataset_name=FlyingThings3D --eval --output_postfix="results/FlyingThings3D_depth_ours_depthanything"
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthpro --dataset_name=bonn --eval --output_postfix="results/Bonn_depth_ours_depthpro"
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthanything --dataset_name=bonn --eval --output_postfix="results/Bonn_depth_ours_depthanything"
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthpro --dataset_name=tum --eval --output_postfix="results/tum_depth_ours_depthpro"
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/depth_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --align_with_lad --depth_max=70 --depth_prior_name=depthanything --dataset_name=tum --eval --output_postfix="results/tum_depth_ours_depthanything"
We find that the flow loss proposed in MonST3R is crucial for pose estimation, so we have incorporated it into our implementation. We sincerely thank the authors of MonST3R for sharing the code for their outstanding work.
bash pose_test.sh
Please change the --dust3r_dynamic_model_path, --output_postfix, --dataset_name, --depth_prior_name.
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --output_postfix="results/sintel_pose_ours_depthpro" --dataset_name=sintel --depth_prior_name=depthpro --start_frame=0 --interval_frame=3000 --mode=eval_pose --scene_graph_type=swinstride-5-noncyclic
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --output_postfix="results/sintel_pose_ours_depthanything" --dataset_name=sintel --depth_prior_name=depthanything --start_frame=0 --interval_frame=3000 --mode=eval_pose --scene_graph_type=swin-5-noncyclic
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --output_postfix="results/bonn_pose_ours_depthpro" --dataset_name=bonn --depth_prior_name=depthpro --start_frame=0 --interval_frame=30 --mode=eval_pose --scene_graph_type=swin-5-noncyclic
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --output_postfix="results/bonn_pose_ours_depthanything" --dataset_name=bonn --depth_prior_name=depthanything --start_frame=0 --interval_frame=30 --mode=eval_pose --scene_graph_type=swin-5-noncyclic
# Depth Pro
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthpro.pth" --output_postfix="results/tum_pose_ours_depthpro" --dataset_name=tum --depth_prior_name=depthpro --start_frame=0 --interval_frame=30 --mode=eval_pose --scene_graph_type=swin-5-noncyclic
# Depth Anything V2
CUDA_VISIBLE_DEVICES='0' python tool/pose_test.py --dust3r_dynamic_model_path="align3r_depthanything.pth" --output_postfix="results/tum_pose_ours_depthanything" --dataset_name=tum --depth_prior_name=depthanything --start_frame=0 --interval_frame=30 --mode=eval_pose --scene_graph_type=swin-5-noncyclic
Please use the viser
to visualize the point cloud results, you can acquire the code from MonST3R. Thanks for their excellent work!
python viser/visualizer_monst3r.py --data path/dataset/video --init_conf --fg_conf_thre 1.0 --no_mask
If you find our work useful, please cite:
@article{lu2024align3r,
title={Align3R: Aligned Monocular Depth Estimation for Dynamic Videos},
author={Lu, Jiahao and Huang, Tianyu and Li, Peng and Dou, Zhiyang and Lin, Cheng and Cui, Zhiming and Dong, Zhen and Yeung, Sai-Kit and Wang, Wenping and Liu, Yuan},
journal={arXiv preprint arXiv:2412.03079},
year={2024}
}
Our code is based on DUSt3R, MonST3R, Depth Pro, Depth Anything V2 and ControlNet. Our visualization code can acquired from MonST3R. We thank the authors for their excellent work!