Skip to content
/ dot Public
forked from 16lemoing/dot

Dense Optical Tracking: Connecting the Dots

License

Notifications You must be signed in to change notification settings

jun297/dot

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dense Optical Tracking: Connecting the Dots

Guillaume Le Moing, Jean Ponce, Cordelia Schmid

DOT unifies point tracking and optical flow techniques:

  • It tracks all pixels in a frame simultaneously.
  • It retains the robustness to occlusions and the accuracy of point tracking techniques.
  • It enjoys the spatial consistency and runs at a comparable speed to optical flow techniques.

News πŸ“£

  • [March 1st, 2024] We now support TAPIR and BootsTAPIR: new SOTA on DAVIS!
  • [February 26th, 2024] DOT has been accepted to CVPR 2024!
  • [January 1st, 2024] We now support CoTracker2: DOT is up to 2x faster!

Installation

Set Up Environment

Clone the repository.

git clone https://github.com/16lemoing/dot
cd dot
Install dependencies.

[Optional] Create a conda environment.

conda create -n dot python=3.9
conda activate dot

Install the PyTorch and TorchVision versions which are compatible with your CUDA configuration.

pip install torch==2.0.1 torchvision==0.15.2

Install inference dependencies.

pip install tqdm matplotlib einops einshape scipy timm lmdb av mediapy

[Optional] Install training dependencies.

pip install tensorboard

[Optional] Set up custom modules from PyTorch3D to increase speed and reduce memory consumption of interpolation operations.

cd dot/utils/torch3d/ && python setup.py install && cd ../../..

Model Zoo

Optical flow estimation

β†’ find motion boundaries

Model Data Download
RAFT Kubric-CVO Checkpoint Config

Point tracking initialization

β†’ track sparse queries, half at motion boundaries, half randomly

Model Data Download
CoTracker Kubric-MOViF Checkpoint Config
CoTracker2 Kubric-MOViF Checkpoint Config
TAPIR Kubric-Panning-MOViE Checkpoint Config
BootsTAPIR Kubric-Panning-MOViE + Real data Checkpoint Config

Optical flow refinement

β†’ get dense motion from sparse point tracks

Model Input Data Download
RAFT CoTracker Kubric-MOViF Checkpoint Config
Command line to download all checkpoints.
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/cvo_raft_patch_8.pth
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/movi_f_raft_patch_4_alpha.pth
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/movi_f_cotracker_patch_4_wind_8.pth
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/movi_f_cotracker2_patch_4_wind_8.pth
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/panning_movi_e_tapir.pth
wget -P checkpoints https://huggingface.co/16lemoing/dot/resolve/main/panning_movi_e_plus_bootstapir.pth

Demo

Download demo data.

wget -P datasets https://huggingface.co/16lemoing/dot/resolve/main/demo.zip
unzip datasets/demo.zip -d datasets/

Spaghetti 🍝

Spaghetti with last frame (static).

Produce videos from the teaser figure.

python demo.py --visualization_modes spaghetti_last_static --video_path orange.mp4
python demo.py --visualization_modes spaghetti_last_static --video_path treadmill.mp4
umbrella.mp4
python demo.py --visualization_modes spaghetti_last_static --video_path umbrella.mp4
Spaghetti from a mask on the first frame with first frame (static), and last frame.
skateboard.mp4
python demo.py --visualization_modes spaghetti_first_last_mask --video_path skateboard.mp4 --mask_path skateboard.png

Overlay 🌈

Overlay with tracks from all the pixels in the first frame.
cartwheel.mp4
python demo.py --visualization_modeovis overlay --video_path cartwheel.mp4
Overlay with tracks reinitialized every 20 frames.
cartwheel_reinit.mp4
python demo.py --visualization_modes overlay --video_path cartwheel.mp4 --inference_mode tracks_from_every_cell_in_every_frame --cell_time_steps 20
Overlay with tracks from a mask on the first frame with occluded regions marked as white stripes.
varanus.mp4
python demo.py --visualization_modes overlay_stripes_mask --video_path varanus.mp4 --mask_path varanus.png

Evaluation

Data Preprocessing

Download Kubric-CVO test data.
wget -P datasets/kubric/cvo https://huggingface.co/datasets/16lemoing/cvo/resolve/main/cvo_test.lmdb
wget -P datasets/kubric/cvo https://huggingface.co/datasets/16lemoing/cvo/resolve/main/cvo_test_extended.lmdb
Download TAP test data.
wget -P datasets/tap https://storage.googleapis.com/dm-tapnet/tapvid_davis.zip
wget -P datasets/tap https://storage.googleapis.com/dm-tapnet/tapvid_kinetics.zip
wget -P datasets/tap https://storage.googleapis.com/dm-tapnet/tapvid_rgb_stacking.zip
unzip "datasets/tap/*.zip" -d datasets/tap/

Compute Evaluation Metrics

python test_cvo.py --split {clean|final|extended}
python test_tap.py --split {davis|kinetics|rgb_stacking}

Benchmarking

Kubric-CVO

Detailed metrics.

We compute the dense motion between the first and last frames of videos, and report:

  • the end point error (EPE) of flows
  • the intersection over union (IoU) of occluded regions
  • the average inference time per video (in seconds) on a NVIDIA V100 GPU
Command line for each method.
python test_cvo.py --split {final|extended} --model pt --tracker_config configs/tapir.json --tracker_path checkpoints/panning_movi_e_tapir.pth
python test_cvo.py --split {final|extended} --model pt --tracker_config configs/bootstapir.json --tracker_path checkpoints/panning_movi_e_plus_bootstapir.pth
python test_cvo.py --split {final|extended} --model pt --tracker_config configs/cotracker_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker_patch_4_wind_8.pth
python test_cvo.py --split {final|extended} --model pt --tracker_config configs/cotracker2_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker2_patch_4_wind_8.pth
python test_cvo.py --split {final|extended} --model dot --tracker_config configs/cotracker_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker_patch_4_wind_8.pth
python test_cvo.py --split {final|extended} --model dot --tracker_config configs/cotracker2_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker2_patch_4_wind_8.pth
Comments. We run DOT using N=2048 initial tracks, other speed / performance trade-offs are possible by using different values for N.

CVO.
Method Final Extended
EPE ↓ IoU ↑ Time ↓ EPE ↓ IoU ↑ Time ↓
TAPIR 4.59 73.8 129 22.6 68.6 811
BootsTAPIR 4.17 74.9 142 25.3 68.1 892
CoTracker 1.45 75.0 177 5.10 70.3 1289
CoTracker2 1.47 77.9 80.2 5.45 69.2 865
DOT (CoTracker + RAFT) 1.38 80.2 1.57 4.97 71.2 10.3
DOT (CoTracker2 + RAFT) 1.37 80.3 0.82 5.11 71.1 7.02

TAP

Detailed metrics.

We compute the dense motion between the query frames (query first mode) and every other frame of videos, and report for ground truth trajectories:

  • the average jaccard (AJ)
  • the average proportion of points within a threshold (<Ξ΄)
  • the occlusion accuracy (OA)
  • the average inference time per video (in seconds) on a NVIDIA V100 GPU
Command line for each method.
python test_tap.py --split {davis|rgb_stacking} --query_mode {first|strided} --model dot --tracker_config configs/cotracker_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker_patch_4_wind_8.pth
python test_tap.py --split {davis|rgb_stacking} --query_mode {first|strided} --model dot --tracker_config configs/cotracker2_patch_4_wind_8.json --tracker_path checkpoints/movi_f_cotracker2_patch_4_wind_8.pth
python test_tap.py --split {davis|rgb_stacking} --query_mode {first|strided} --model dot --tracker_config configs/tapir.json --tracker_path checkpoints/panning_movi_e_tapir.pth
python test_tap.py --split {davis|rgb_stacking} --query_mode {first|strided} --model dot --tracker_config configs/bootstapir.json --tracker_path checkpoints/panning_movi_e_plus_bootstapir.pth
Comments. We run DOT using N=8192 initial tracks, other speed / performance trade-offs are possible by using different values for N. Here, TAPIR and BootsTAPIR are faster than CoTracker and CoTracker2 since they operate directly at 256x256 resolution while the latter resize videos to a higher resolution.

DAVIS.
Method First Strided
AJ ↑ OA ↑ <Ξ΄ ↑ Time ↓ AJ ↑ OA ↑ <Ξ΄ ↑ Time ↓
Published results
OmniMotion - - - - 51.7 85.3 67.5 ~32400
DinoTracker - - - - 62.3 87.5 78.2 ~5760
This repo's results
DOT (CoTracker + RAFT) 61.2 88.8 74.9 85.7 66.1 90.0 79.4 131
DOT (CoTracker2 + RAFT) 61.2 89.7 75.3 99.1 67.7 91.2 80.6 141
DOT (TAPIR + RAFT) 61.6 89.5 75.4 39.5 67.3 91.0 79.9 88.9
DOT (BootsTAPIR + RAFT) 62.8 90.2 76.8 42.3 68.5 91.7 81.3 90.6
RGB-Stacking.
Method First Strided
AJ ↑ OA ↑ <Ξ΄ ↑ Time ↓ AJ ↑ OA ↑ <Ξ΄ ↑ Time ↓
Published results
OmniMotion - - - - 77.5 93.5 87.0 ~32400
DinoTracker - - - - - - - -
This repo's results
DOT (CoTracker + RAFT) 77.2 93.3 87.7 270 83.5 95.7 91.4 1014
DOT (CoTracker2 + RAFT) 77.2 92.6 87.1 330 83.2 95.3 91.0 1074
DOT (TAPIR + RAFT) 65.7 89.1 81.9 105 74.6 93.4 86.4 843
DOT (BootsTAPIR + RAFT) 71.0 90.7 85.2 112 79.7 94.7 89.6 852

Training

Data Preprocessing

Download preprocessed data.

Download Kubric-MoviF train data.

wget -P datasets/kubric/movi_f https://huggingface.co/datasets/16lemoing/movi_f/resolve/main/video_part.zip
wget -P datasets/kubric/movi_f https://huggingface.co/datasets/16lemoing/movi_f/resolve/main/video_part.z01
wget -P datasets/kubric/movi_f https://huggingface.co/datasets/16lemoing/movi_f/resolve/main/ground_truth.zip
wget -P datasets/kubric/movi_f https://huggingface.co/datasets/16lemoing/movi_f/resolve/main/cotracker.zip

Unzip data.

zip -F datasets/kubric/movi_f/video_part.zip --out datasets/kubric/movi_f/video.zip
unzip datasets/kubric/movi_f/video.zip -d datasets/kubric/movi_f/
unzip datasets/kubric/movi_f/ground_truth.zip -d datasets/kubric/movi_f/
unzip datasets/kubric/movi_f/cotracker.zip -d datasets/kubric/movi_f/
Or run preprocessing steps yourself.

Install additional dependencies.

pip install joblib tensorflow tensorflow_datasets tensorflow-graphics

Download Kubric-MoviF train data.

python preprocess.py --extract_movi_f

[Requires a GPU] Save tracks from CoTracker for Kubric-MoviF train data.

python preprocess.py --save_tracks

Optimization

python train.py

License

Most of our code is licensed under the MIT License. However, some parts of the code are adapted from external sources and conserve their original license: CoTracker is licensed under CC-BY-NC, RAFT uses the BSD 3-Clause License, Kubric and TAP use the Apache 2.0 License, and PyTorch3D is licensed under a BSD License.

Contributing

We actively encourage contributions. Want to feature a cool application which builds upon DOT, or add support to another point tracker / optical flow model? Don't hesitate to open an issue to discuss about it.

Acknowledgments

We want to thank RAFT, AccFlow, TAP, CoTracker, DinoTracker, OmniMotion and Kubric for publicly releasing their code, models and data.

Citation

Please note that any use of the code in a publication must explicitly refer to:

@inproceedings{lemoing2024dense,
  title = {Dense Optical Tracking: Connecting the Dots},
  author = {Le Moing, Guillaume and Ponce, Jean and Schmid, Cordelia},
  year = {2024},
  booktitle = {CVPR}
}

About

Dense Optical Tracking: Connecting the Dots

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 73.8%
  • Cuda 16.8%
  • C++ 8.6%
  • C 0.8%