Home

Awesome

Dense Matching

A general dense matching library based on PyTorch.

For any questions, issues or recommendations, please contact Prune at prune.truong@vision.ee.ethz.ch

<br />

If you're interested in training a probabilistic correspondence network unsupervised (mix of PDCNet and WarpC), check out our recent work Refign, with code. It is also integrated in this code base as UAWarpC.

Updates

06/03/2022: We found that significantly better performance and reduced training time are obtained when initializing with bilinear interpolation weights the weights of the transposed convolutions used to upsample the predicted flow fields between the different pyramid levels. We have integrated this initialization as the default. We might provide updated pre-trained weights as well. Alternatively, one can directly simply use bilinear interpolation for upsampling with similar (maybe a bit better) performance, which is also now an option proposed.

Highlights

Libraries for implementing, training and evaluating dense matching networks. It includes

<br />

Dense Matching Networks

The repo contains the implementation of the following matching models. We provide pre-trained model weights, data preparation, evaluation commands, and results for each dataset and method. If you find this library useful, please consider citing the relevant following research papers.

[6] PWarpC: Probabilistic Warp Consistency for Weakly-Supervised Semantic Correspondences. (CVPR 2022)

Authors: Prune Truong, Martin Danelljan, Fisher Yu, Luc Van Gool<br />

[Paper] [Website] [Poster] [Video] [Citation]

<details>

alt text

We propose Probabilistic Warp Consistency, a weakly-supervised learning objective for semantic matching. Our approach directly supervises the dense matching scores predicted by the network, encoded as a conditional probability distribution. We first construct an image triplet by applying a known warp to one of the images in a pair depicting different instances of the same object class. Our probabilistic learning objectives are then derived using the constraints arising from the resulting image triplet. We further account for occlusion and background clutter present in real image pairs by extending our probabilistic output space with a learnable unmatched state. To supervise it, we design an objective between image pairs depicting different object classes. We validate our method by applying it to four recent semantic matching architectures. Our weakly-supervised approach sets a new state-of-the-art on four challenging semantic matching benchmarks. Lastly, we demonstrate that our objective also brings substantial improvements in the strongly-supervised regime, when combined with keypoint annotations.

</details>

[5] PDC-Net+: Enhanced Probabilistic Dense Correspondence Network. (TPAMI 2023)

Authors: Prune Truong, Martin Danelljan, Radu Timofte, Luc Van Gool <br />

[Paper] [Website] [Citation]

[4] WarpC: Warp Consistency for Unsupervised Learning of Dense Correspondences. (ICCV 2021 - ORAL)

Authors: Prune Truong, Martin Danelljan, Fisher Yu, Luc Van Gool<br />

[Paper] [Website] [Poster] [Slides] [Video] [Citation]

<details>
Warp Consistency GraphResults
alt text

The key challenge in learning dense correspondences lies in the lack of ground-truth matches for real image pairs. While photometric consistency losses provide unsupervised alternatives, they struggle with large appearance changes, which are ubiquitous in geometric and semantic matching tasks. Moreover, methods relying on synthetic training pairs often suffer from poor generalisation to real data. We propose Warp Consistency, an unsupervised learning objective for dense correspondence regression. Our objective is effective even in settings with large appearance and view-point changes. Given a pair of real images, we first construct an image triplet by applying a randomly sampled warp to one of the original images. We derive and analyze all flow-consistency constraints arising between the triplet. From our observations and empirical results, we design a general unsupervised objective employing two of the derived constraints. We validate our warp consistency loss by training three recent dense correspondence networks for the geometric and semantic matching tasks. Our approach sets a new state-of-the-art on several challenging benchmarks, including MegaDepth, RobotCar and TSS.

</details>

[3] PDC-Net: Learning Accurate Correspondences and When to Trust Them. (CVPR 2021 - ORAL)

Authors: Prune Truong, Martin Danelljan, Luc Van Gool, Radu Timofte<br />

[Paper] [Website] [Poster] [Slides] [Video] [Citation]

<details>

alt text

Dense flow estimation is often inaccurate in the case of large displacements or homogeneous regions. For most applications and down-stream tasks, such as pose estimation, image manipulation, or 3D reconstruction, it is crucial to know when and where to trust the estimated matches. In this work, we aim to estimate a dense flow field relating two images, coupled with a robust pixel-wise confidence map indicating the reliability and accuracy of the prediction. We develop a flexible probabilistic approach that jointly learns the flow prediction and its uncertainty. In particular, we parametrize the predictive distribution as a constrained mixture model, ensuring better modelling of both accurate flow predictions and outliers. Moreover, we develop an architecture and training strategy tailored for robust and generalizable uncertainty prediction in the context of self-supervised training.

</details>

[2] GOCor: Bringing Globally Optimized Correspondence Volumes into Your Neural Network. (NeurIPS 2020)

Authors: Prune Truong *, Martin Danelljan *, Luc Van Gool, Radu Timofte<br />

[Paper] [Website] [Video] [Citation]

<details>

The feature correlation layer serves as a key neural network module in numerous computer vision problems that involve dense correspondences between image pairs. It predicts a correspondence volume by evaluating dense scalar products between feature vectors extracted from pairs of locations in two images. However, this point-to-point feature comparison is insufficient when disambiguating multiple similar regions in an image, severely affecting the performance of the end task. This work proposes GOCor, a fully differentiable dense matching module, acting as a direct replacement to the feature correlation layer. The correspondence volume generated by our module is the result of an internal optimization procedure that explicitly accounts for similar regions in the scene. Moreover, our approach is capable of effectively learning spatial matching priors to resolve further matching ambiguities.

alt text

</details>

[1] GLU-Net: Global-Local Universal Network for dense flow and correspondences (CVPR 2020 - ORAL).

Authors: Prune Truong, Martin Danelljan and Radu Timofte <br /> [Paper] [Website] [Poster] [Oral Video] [Teaser Video] [Citation]

<details>

alt text

</details> <br /> <br />

Pre-trained weights

The pre-trained models can be found in the model zoo

<br />

Table of Content

  1. Installation
  2. Test on your own image pairs!
    1. Test on image pairs
    2. Various demos
  3. Overview
  4. Benchmarks and results
    1. Correspondence evaluation
      1. MegaDepth
      2. RobotCar
      3. ETH3D
      4. HPatches
      5. KITTI
      6. Sintel
      7. TSS
      8. PF-Pascal
      9. PF-Willow
      10. Spair-71k
      11. Caltech-101
    2. Pose estimation
      1. YFCC100M
      2. ScanNet
    3. Sparse evaluation on HPatches
  5. Training
  6. Acknowledgement
  7. Changelog
<br />

1. Installation <a name="installation"></a>

Inference runs for torch version >= 1.0

conda create -n dense_matching_env python=3.7
conda activate dense_matching_env
pip install numpy opencv-python torch torchvision matplotlib imageio jpeg4py scipy pandas tqdm gdown pycocotools timm

Note: CUDA is required to run the code. Indeed, the correlation layer is implemented in CUDA using CuPy, which is why CuPy is a required dependency. It can be installed using pip install cupy or alternatively using one of the provided binary packages as outlined in the CuPy repository. The code was developed using Python 3.7 & PyTorch 1.0 & CUDA 9.0, which is why I installed cupy for cuda90. For another CUDA version, change accordingly.

pip install cupy-cuda90 --no-cache-dir 
git submodule update --init --recursive
git submodule update --recursive --remote
python -c "from admin.environment import create_default_local_file; create_default_local_file()"
<br />

2. Test on your own image pairs! <a name="test"></a>

Possible model choices are :

Possible pre-trained model choices are: static, dynamic, chairs_things, chairs_things_ft_sintel, megadepth, megadepth_stage1, pfpascal, spair

<br /> <details> <summary><b>Note on PDCNet and PDC-Net+ inference options</b></summary>

PDC-Net and PDC-Net+ have multiple inference alternative options. if model is PDC-Net, add options:

Use direct ('D') when image pairs only show limited view-point changes (for example consecutive images of a video, like in the optical flow task). For larger view-point changes, use homography ('H') or multi-scale ('MS').

For example, to run PDC-Net or PDC-Net+ with homography, add at the end of the command

PDCNet --multi_stage_type H --mask_type proba_interval_1_above_10
</details>

Test on a specific image pair <a name="test1"></a>

You can test the networks on a pair of images using test_models.py and the provided trained model weights. You must first choose the model and pre-trained weights to use. The inputs are the paths to the query and reference images. The images are then passed to the network which outputs the corresponding flow field relating the reference to the query image. The query is then warped according to the estimated flow, and a figure is saved.

<br />

For this pair of MegaDepth images (provided to check that the code is working properly) and using PDCNet (MS) trained on the megadepth dataset, the output is:

python test_models.py --model PDCNet --pre_trained_model megadepth --path_query_image images/piazza_san_marco_0.jpg --path_reference_image images/piazza_san_marco_1.jpg --save_dir evaluation/ PDCNet --multi_stage_type MS --mask_type proba_interval_1_above_10

additional optional arguments: --path_to_pre_trained_models (default is pre_trained_models/) alt text

<br />

Using GLU-Net-GOCor trained on the dynamic dataset, the output for this image pair of eth3d is:

python test_models.py --model GLUNet_GOCor --pre_trained_model dynamic --path_query_image images/eth3d_query.png --path_reference_image images/eth3d_reference.png --save_dir evaluation/

alt text

<br />

For baseline GLU-Net, the output is instead:

python test_models.py --model GLUNet --pre_trained_model dynamic --path_query_image images/eth3d_query.png --path_reference_image images/eth3d_reference.png --save_dir evaluation/

alt text

<br />

And for PWC-Net-GOCor and baseline PWC-Net:

python test_models.py --model PWCNet_GOCor --pre_trained_model chairs_things --path_query_image images/kitti2015_query.png --path_reference_image images/kitti2015_reference.png --save_dir evaluation/

alt text

<br />
python test_models.py --model PWCNet --pre_trained_model chairs_things --path_query_image images/kitti2015_query.png --path_reference_image images/kitti2015_reference.png --save_dir evaluation/

alt text

<br />

Demos with videos <a name="test2"></a>

alt text

We modify the utils code from SuperGlue, so you need to adhere to their license in order to use that. Then run:

bash demo/run_demo_confident_matches.sh

alt text

We modify the utils code from SuperGlue, so you need to adhere to their license in order to use that. Then run:

bash demo/run_demo_warping_videos.sh

3. Overview <a name="overview"></a>

The framework consists of the following sub-modules.

4. Benchmark and results <a name="results"></a>

All paths to the datasets must be provided in file admin/local.py. We provide an example admin/local_example.py where all datasets are stored in data/. You need to update the paths of admin/local.py before running the evaluation.

<details> <summary><b>Note on PDCNet and PDCNet+ inference options</b></summary>

PDC-Net and PDC-Net+ has multiple inference alternative options. if model if PDC-Net, add options:

For example, to run PDC-Net or PDC-Net+ with homography, add at the end of the command

PDCNet --multi_stage_type H --mask_type proba_interval_1_above_10
</details> <details> <summary><b>Note on reproducibility</b></summary>

Results using PDC-Net with multi-stage (homography_from_quarter_resolution_uncertainty, H) or multi-scale (multiscale_homo_from_quarter_resolution_uncertainty, MS) employ RANSAC internally. Therefore results may vary a bit but should remain within 1-2 %. For pose estimation, we also compute the pose with RANSAC, which leads to some variability in the results.

</details>

4.1. Correspondence evaluation <a name="correspondence_eval"></a>

Metrics are computed with,

python -u eval_matching.py --dataset dataset_name --model model_name --pre_trained_models pre_trained_model_name --optim_iter optim_step  --local_optim_iter local_optim_iter --save_dir path_to_save_dir 

Optional argument: --path_to_pre_trained_models:

<details> <summary><b>MegaDepth</b><a name="megadepth"></a></summary>

Data preparation: We use the test set provided in RANSAC-Flow. It is composed of 1600 pairs and also includes a csv file ('test1600Pairs.csv') containing the name of image pairs to evaluate and the corresponding ground-truth correspondences. Download everything with

bash assets/download_megadepth_test.sh

The resulting file structure is the following

megadepth_test_set/
└── MegaDepth/
    └── Test/
        └── test1600Pairs/  
        └── test1600Pairs.csv

<br /><br /> Evaluation: After updating the path of 'megadepth' and 'megadepth_csv' in admin/local.py, evaluation is run with

python eval_matching.py --dataset megadepth --model PDCNet --pre_trained_models megadepth --optim_iter 3 --local_optim_iter 7 --save_dir path_to_save_dir PDCNet --multi_stage_type MS

Similar results should be obtained:

ModelPre-trained model typePCK-1 (%)PCK-3 (%)PCK-5 (%)
GLU-Net (this repo)static (CityScape-DPED-ADE)29.5150.6756.12
GLU-Net (this repo)dynamic21.5952.2761.91
GLU-Net (paper)dynamic21.5852.1861.78
GLU-Net-GOCor (this repo)static (CitySCape-DPED-ADE)32.2452.5158.90
GLU-Net-GOCor (this repo)dynamic37.2361.2568.17
GLU-Net-GOCor (paper)dynamic37.2861.1868.08
------------------------------------------------------------------
GLU-Net-GOCor* (paper)megadepth57.7778.6182.24
PDC-Net (D) (this repo)megadepth68.9784.0385.68
PDC-Net (H) (paper)megadepth70.7586.5188.00
PDC-Net (MS) (paper)megadepth71.8189.3691.18
PDC-Net+ (D) (paper)megadepth72.4186.7088.13
PDC-Net+ (H) (paper)megadepth73.9289.2190.48
PDC-Net+ (MS) (paper)megadepth74.5190.6992.10
------------------------------------------------------------------
GLU-Net* (paper)megadepth38.5054.6659.60
GLU-Net* (this repo)megadepth38.6254.7059.76
WarpC-GLU-Net (paper)megadepth50.6173.8078.61
WarpC-GLU-Net (this repo)megadepth50.7773.9178.73
</details> <details> <summary><b>RobotCar <a name="robotcar"></b></a></summary>

Data preparation: Images can be downloaded from the Visual Localization Challenge (at the bottom of the site), or more precisely here. The CSV file with the ground-truth correspondences can be downloaded from here. The file structure should be the following:

RobotCar
├── img/
└── test6511.csv

<br /><br /> Evaluation: After updating the path of 'robotcar' and 'robotcar_csv' in admin/local.py, evaluation is run with

python eval_matching.py --dataset robotcar --model PDCNet --pre_trained_models megadepth --optim_iter 3 --local_optim_iter 7 --save_dir path_to_save_dir PDCNet --multi_stage_type MS

Similar results should be obtained:

ModelPre-trained model typePCK-1 (%)PCK-3 (%)PCK-5 (%)
GLU-Net (paper)static (CityScape-DPED-ADE)2.3017.1533.87
GLU-Net-GOCor (paper)static2.3117.6235.18
GLU-Net-GOCor (paper)dynamic2.1016.0731.66
------------------------------------------------------------------
GLU-Net-GOCor* (paper)megadepth2.3317.2133.67
PDC-Net (H) (paper)megadepth2.5418.9736.37
PDC-Net (MS) (paper)megadepth2.5818.8736.19
PDC-Net+ (D) (paper)megadepth2.5719.1236.71
PDC-Net+ (H) (paper)megadepth2.5619.0036.56
PDC-Net+ (MS) (paper)megadepth2.6319.0136.57
------------------------------------------------------------------
GLU-Net* (paper)megadepth2.3617.1833.28
WarpC-GLU-Net (paper)megadepth2.5118.5935.92
</details> <details> <summary><b>ETH3D <a name="eth3d"></a></b></summary>

Data preparation: execute 'bash assets/download_ETH3D.sh' from our GLU-Net repo. It does the following:

As illustration, your root ETH3D directory should be organised as follows:

<pre> /ETH3D/ multiview_testing/ lakeside/ sand_box/ storage_room/ storage_room_2/ tunnel/ multiview_training/ delivery_area/ electro/ forest/ playground/ terrains/ info_ETH3D_files/ </pre>

The organisation of your directories is important, since the bundle files contain the relative paths to the images, from the ETH3D root folder.

<br /><br /> Evaluation: for each interval rate (3,5,7,9,11,13,15), we compute the metrics for each of the sub-datasets (lakeside, delivery area and so on). The final metrics are the average over all datasets for each rate. After updating the path of 'eth3d' in admin/local.py, evaluation is run with

python eval_matching.py --dataset robotcar --model PDCNet --pre_trained_models megadepth --optim_iter 3 --local_optim_iter 7 --save_dir path_to_save_dir PDCNet --multi_stage_type D
<br /> AEPE for different rates of intervals between image pairs.
MethodPre-trained model typerate=3rate=5rate=7rate=9rate=11rate=13rate=15
LiteFlowNetchairs-things1.662.586.0512.9529.6752.4174.96
PWC-Netchairs-things1.752.103.215.5914.3527.4943.41
PWC-Net-GOCorchairs-things1.701.982.584.2210.3221.0738.12
--------------------------------------------------------------------------------------------------
DGC-Net2.493.284.185.356.789.0212.23
GLU-Netstatic1.982.543.494.245.617.5510.78
GLU-Netdynamic2.012.462.983.514.306.119.08
GLU-Net-GOCordynamic1.932.282.643.013.624.797.80
--------------------------------------------------------------------------------------------------
GLU-Net-GOCor*megadepth1.681.922.182.432.893.314.27
PDC-Net (D) (paper)megadepth1.601.792.032.262.582.923.69
PDC-Net (H)megadepth1.581.771.982.242.562.913.73
PDC-Net (MS)megadepth1.601.792.002.262.572.903.56
PDC-Net+ (H) (paper)megadepth1.561.741.962.182.482.733.24
PDC-Net+ (MS) (paper)megadepth1.581.761.962.162.492.733.24

PCK-1 for different rates of intervals between image pairs:

Note that the PCKs are computed per image, and then averaged per sequence. The final metrics is the average over all sequences. It corresponds to the results '_per_image' in the outputted metric file. Note that this is not the metrics used in the PDC-Net paper, where the PCKs are c omputed per sequence instead, using the PDC-Net direct approach (corresponds to results '-per-rate' in outputted metric file).

MethodPre-trained model typerate=3rate=5rate=7rate=9rate=11rate=13rate=15
LiteFlowNetchairs-things61.6356.5549.8342.0033.1426.4621.22
PWC-Netchairs-things58.5052.0244.8637.4130.3624.7519.89
PWC-Net-GOCorchairs-things58.9353.1046.9140.9334.5829.2524.59
--------------------------------------------------------------------------------------------------
DGC-Net
GLU-Netstatic50.5543.0836.9832.4528.4525.0621.89
GLU-Netdynamic46.2739.2834.0530.1126.6923.7320.85
GLU-Net-GOCordynamic47.9741.7936.8133.0329.8026.9323.99
--------------------------------------------------------------------------------------------------
GLU-Net-GOCor*megadepth59.4055.1551.1847.8644.4641.7838.91
PDC-Net (D)megadepth61.8258.4155.0252.4049.6147.4345.01
PDC-Net (H)megadepth62.6359.2956.0953.3150.6948.4646.17
PDC-Net (MS)megadepth62.2959.1455.8753.2350.5948.4546.17
PDC-Net+ (H)megadepth63.1259.9356.8154.1251.5949.5547.32
PDC-Net+ (MS)megadepth62.9559.7656.6454.0251.5049.3847.24

PCK-5 for different rates of intervals between image pairs:

MethodPre-trained model typerate=3rate=5rate=7rate=9rate=11rate=13rate=15
LiteFlowNetchairs-things92.7990.7086.2978.5066.0755.0546.29
PWC-Netchairs-things92.6490.8287.3281.8072.9564.0755.47
PWC-Net-GOCorchairs-things92.8191.4588.9685.5379.4472.0664.92
--------------------------------------------------------------------------------------------------
DGC-Net88.5083.2578.3273.7469.2364.2858.66
GLU-Netstatic91.2287.9184.2380.7476.8472.3567.77
GLU-Netdynamic91.4588.5785.6483.1080.1276.6673.02
GLU-Net-GOCordynamic92.0889.8787.7785.8883.6981.1277.90
--------------------------------------------------------------------------------------------------
GLU-Net-GOCor*megadepth93.0392.1391.0490.1988.9887.8185.93
PDC-Net (D) (paper)megadepth93.4792.7291.8491.1590.2389.4588.10
PDC-Net (H)megadepth93.5092.7191.9391.1690.3589.5288.32
PDC-Net (MS)megadepth93.4792.6991.8591.1590.3389.5588.43
PDC-Net+ (H)megadepth93.5492.7892.0491.3090.6089.989.03
PDC-Net+ (MS)megadepth93.5092.7992.0491.3590.6089.9788.97
</details> <details> <summary><b>HPatches <a name="hpatches"></a></b></summary>

Data preparation: Download the data with

bash assets/download_hpatches.sh

The corresponding csv files for each viewpoint ID with the path to the images and the homography parameters relating the pairs are listed in assets/.

<br /><br /> Evaluation: After updating the path of 'hp' in admin/local.py, evaluation is run with

python eval_matching.py --dataset hp --model GLUNet_GOCor --pre_trained_models static --optim_iter 3 --local_optim_iter 7 --save_dir path_to_save_dir

Similar results should be obtained:

Pre-trained model typeAEPEPCK-1 (%)PCK-3 (%)PCK-5 (%)
DGC-Net [Melekhov2019]33.2612.0058.06
GLU-Net (this repo)static25.0539.5771.4578.60
GLU-Net (paper)static25.0539.55-78.54
GLU-Net-GOCor (this repo)static20.1641.4974.1281.46
GLU-Net-GOCor (paper)static20.1641.55-81.43
-----------------------------------------------------------------------
PDCNet (D) (this repo)megadepth19.4043.9478.5185.81
PDCNet (H) (this repo)megadepth17.5148.6982.7189.44
</details> <details> <summary><b>KITTI<a name="kitti"></a></b></summary>

Data preparation: Both KITTI-2012 and 2015 datasets are available here

<br />

Evaluation: After updating the path of 'kitti2012' and 'kitti2015' in admin/local.py, evaluation is run with

python eval_matching.py --dataset kitti2015 --model PDCNet --pre_trained_models megadepth --optim_iter 3 --local_optim_iter 7 PDCNet --multi_stage_type direct

Similar results should be obtained:

KITTI-2012KITTI-2015
ModelsPre-trained model typeAEPEF1 (%)AEPEF1 (%)
PWC-Net-GOCor (this repo)chairs-things4.1219.5810.3331.23
PWC-Net-GOCor (paper)chairs-things4.1219.3110.3330.53
PWC-Net-GOCor (this repo)chairs-things ft sintel2.609.697.6421.36
PWC-Net-GOCor (paper)chairs-things ft sintel2.609.677.6420.93
-----------------------------------------------------------------------------------------
GLU-Net (this repo)static3.3318.919.7937.77
GLU-Net (this repo)dynamic3.1219.737.5933.92
GLU-Net (paper)dynamic3.1419.767.4933.83
GLU-Net-GOCor (this repo)dynamic2.6215.176.6327.58
GLU-Net-GOCor (paper)dynamic2.6815.436.6827.57
-----------------------------------------------------------------------------------------
GLU-Net-GOCor* (paper)megadepth2.269.895.5318.27
PDC-Net (D) (paper and this repo)megadepth2.087.985.2215.13
PDC-Net (H) (this repo)megadepth2.168.195.3115.23
PDC-Net (MS) (this repo)megadepth2.168.135.4015.33
PDC-Net+ (D) (paper)megadepth1.766.604.5312.62
</details> <details> <summary><b>Sintel <a name="sintel"></a></b></summary>

Data preparation: Download the data with

bash assets/download_sintel.sh

Evaluation: After updating the path of 'sintel' in admin/local.py, evaluation is run with

python eval_matching.py --dataset sintel --model PDCNet --pre_trained_models megadepth --optim_iter 3 --local_optim_iter 7 --save_dir path_to_save_dir PDCNet --multi_stage_type direct

Similar results should be obtained:

Pre-trained model typeAEPEPCK-1 / dataset (%)PCK-5 / dataset (%)AEPEPCK-1 / dataset (%)PCK-5 / dataset (%)
PWC-Net-GOCor (this repo)chairs-things2.3882.1894.143.7077.3691.20
PWC-Net-GOCor (paper)chairs-things2.3882.1794.133.7077.3491.20
PWC-Net-GOCor (paper)chairs-things ft sintel(1.74)(87.93)(95.54)(2.28)(84.15)(93.71)
---------------------------------------------------------------------------------------------------------
GLU-Net (this repo)dynamic4.2462.2188.475.4958.1085.16
GLU-Net (paper)dynamic4.2562.0888.405.5057.8585.10
GLU-Net-GOCor (this repo)dynamic3.7767.1190.474.8563.3687.76
GLU-Net-GOCor (paper)dynamic3.8067.1290.414.9063.3887.69
------------------------------------------------------------------------------------------------------
GLU-Net-GOCor* (paper)megadepth3.1280.0092.684.4673.1088.94
PDC-Net (D) (this repo)megadepth3.3085.0693.384.4878.0790.07
PDC-Net (H) (this repo)megadepth3.3884.9593.354.5077.6290.07
PDC-Net (MS) (this repo)megadepth3.4084.8593.334.5477.4190.06
</details> <details> <summary><b>TSS <a name="tss"></a></b></summary>

Data preparation: To download the images, run:

bash assets/download_tss.sh
<br />

Evaluation: After updating the path of 'tss' in admin/local.py, evaluation is run with

python eval_matching.py --dataset TSS --model GLUNet_GOCor --pre_trained_models static --optim_iter 3 --local_optim_iter 7 --flipping_condition True --save_dir path_to_save_dir

Similar results should be obtained:

ModelPre-trained model typeFGD3CarJODSPASCALAll
Semantic-GLU-Net [1]Static94.475.578.382.8
GLU-Net (our repo)Static93.273.6971.179.33
GLU-Net (paper)Static93.273.371.179.2
GLU-Net-GOCor (our repo, GOCor iter=3, 3)Static94.677.977.783.4
GLU-Net-GOCor (our repo, GOCor iter=3, 7)Static94.677.677.183.1
GLU-Net-GOCor (paper)Static94.677.977.783.4
Semantic-GLU-Net [4]pfpascal95.382.278.2
WarpC-SemanticGLU-Netpfpascal97.184.779.787.2
</details> <details> <summary><b>PF-Pascal <a name="pfpascal"></a></b></summary>

Data preparation: To download the images, run:

bash assets/download_pf_pascal.sh
<br />

Evaluation: After updating the path of 'PFPascal' in admin/local.py, evaluation is run with

python eval_matching.py --dataset PFPascal --model WarpCSemanticGLUNet --pre_trained_models pfpascal --flipping_condition False --save_dir path_to_save_dir

Similar results should be obtained:

ModelPre-trained model typealpha=0.05alpha=0.1
Semantic-GLU-Net [1]static (paper)46.070.6
Semantic-GLU-Net [1]static (this repo)45.370.3
Semantic-GLU-Net [4] (this repo)pfpascal48.472.4
WarpC-SemanticGLU-Net [4] (paper)pfpascal62.181.7
WarpC-SemanticGLU-Net [4] (this repo)pfpascal62.781.7
</details> <details> <summary><b>PF-Willow <a name="pfwillow"></a></b></summary>

Data preparation: To download the images, run:

bash assets/download_pf_willow.sh
<br />

Evaluation: After updating the path of 'PFWillow' in admin/local.py, evaluation is run with

python eval_matching.py --dataset PFWillow --model WarpCSemanticGLUNet --pre_trained_models pfpascal --flipping_condition False --save_dir path_to_save_dir

Similar results should be obtained:

ModelPre-trained model typealpha=0.05alpha=0.1
Semantic-GLU-Net [1] (paper)static36.463.8
Semantic-GLU-Net [1] (this repo)static36.263.7
Semantic-GLU-Net [4]pfpascal39.767.6
WarpC-SemanticGLU-Net [4] (paper)pfpascal49.075.1
WarpC-SemanticGLU-Net [4] (this repo)pfpascal48.975.2
</details> <details> <summary><b>Spair-71k <a name="spair"></a></b></summary>

Data preparation: To download the images, run:

bash assets/download_spair.sh
<br />

Evaluation: After updating the path of 'spair' in admin/local.py, evaluation is run with

python eval_matching.py --dataset spair --model WarpCSemanticGLUNet --pre_trained_models pfpascal  --flipping_condition False --save_dir path_to_save_dir

Similar results should be obtained:

ModelPre-trained model typealpha=0.1
Semantic-GLU-Net [1]static15.1
Semantic-GLU-Net [4]pfpascal16.5
WarpC-SemanticGLU-Netspair23.5
WarpC-SemanticGLU-Net [4]pfpascal23.8
</details> <details> <summary><b>Caltech-101 <a name="caltech"></a></b></summary>

Data preparation: To download the images, run:

bash assets/download_caltech.sh
<br />

Evaluation: After updating the path of 'spair' in admin/local.py, evaluation is run with

python eval_matching.py --dataset caltech --model WarpCSemanticGLUNet --pre_trained_models pfpascal  --flipping_condition False --save_dir path_to_save_dir
</details>

4.2 Pose estimation <a name="pose_estimation"></a>

Metrics are computed with

python -u eval_pose_estimation.py --dataset dataset_name --model model_name --pre_trained_models pre_trained_model_name --optim_iter optim_step  --local_optim_iter local_optim_iter --estimate_at_quarter_reso True --mask_type_for_pose_estimation proba_interval_1_above_10 --save_dir path_to_save_dir 
<details> <summary><b>YFCC100M <a name="yfcc"></a></b></summary>

Data preparation: The groundtruth for YFCC is provided the file assets/yfcc_test_pairs_with_gt_original.txt (from SuperGlue repo). Images can be downloaded from the OANet repo and moved to the desired location

bash assets/download_yfcc.sh

File structure should be

YFCC
└──  images/
       ├── buckingham_palace/
       ├── notre_dame_front_facade/
       ├── reichstag/
       └── sacre_coeur/

<br /><br /> Evaluation: After updating the path 'yfcc' in admin/local.py, compute metrics on YFCC100M with PDC-Net homography (H) using the command:

python -u eval_pose_estimation.py --dataset YFCC --model PDCNet --pre_trained_models megadepth --optim_iter 3  --local_optim_iter 7 --estimate_at_quarter_reso True --mask_type_for_pose_estimation proba_interval_1_above_10 --save_dir path_to_save_dir PDCNet --multi_stage_type H --mask_type proba_interval_1_above_10 

You should get similar metrics (not exactly the same because of RANSAC):

mAP @5mAP @10mAP @20Run-time (s)
PDC-Net (D)60.5270.9180.300.
PDC-Net (H)63.9073.0081.220.74
PDC-Net (MS)65.1874.2182.422.55
PDC-Net+ (D)63.9373.8182.74
PDC-Net+ (H)67.3576.5684.560.74
</details> <details> <summary><b>ScanNet <a name="scanNet"></a></b></summary>

Data preparation: The images of the ScanNet test set (100 scenes, scene0707_00 to scene0806_00) are provided here. They were extracted from ScanNet github repo and processed. We use the groundtruth provided by in the SuperGlue repo provided here in the file assets/scannet_test_pairs_with_gt.txt.

<br /><br /> Evaluation: After updating the path 'scannet_test' in admin/local.py, compute metrics on ScanNet with PDC-Net homography (H) using the command:

python -u eval_pose_estimation.py --dataset scannet --model PDCNet --pre_trained_models megadepth --optim_iter 3  --local_optim_iter 7 --estimate_at_quarter_reso True --mask_type_for_pose_estimation proba_interval_1_above_10 --save_dir path_to_save_dir PDCNet --multi_stage_type H --mask_type proba_interval_1_above_10 

You should get similar metrics (not exactly the same because of RANSAC):

mAP @5mAP @10mAP @20
PDC-Net (D)39.9350.1760.87
PDC-Net (H)42.8753.0763.25
PDC-Net (MS)42.4052.8363.13
PDC-Net+ (D)42.9353.1363.95
PDC-Net+ (H)45.6656.6767.07
</details>

4.3 Sparse evaluation on HPatches <a name="sparse_hp"></a>

We provide the link to the cache results here for the sparse evaluation on HPatches. Check PDC-Net+ for more details.

5. Training <a name="training"></a>

Quick Start

The installation should have generated a local configuration file "admin/local.py". In case the file was not generated, run python -c "from admin.environment import create_default_local_file; create_default_local_file()"to generate it. Next, set the paths to the training workspace, i.e. the directory where the model weights and checkpoints will be saved. Also set the paths to the datasets you want to use (and which should be downloaded beforehand, see below). If all the dependencies have been correctly installed, you can train a network using the run_training.py script in the correct conda environment.

conda activate dense_matching_env
python run_training.py train_module train_name

Here, train_module is the sub-module inside train_settings and train_name is the name of the train setting file to be used.

For example, you can train using the included default train_PDCNet_stage1 settings by running:

python run_training.py PDCNet train_PDCNet_stage1

Training datasets downloading <a name="scanNet"></a>

<details> <summary><b>DPED-CityScape-ADE </b></summary>

This is the same image pairs used in GLU-Net repo. For the training, we use a combination of the DPED, CityScapes and ADE-20K datasets. The DPED training dataset is composed of only approximately 5000 sets of images taken by four different cameras. We use the images from two cameras, resulting in around 10,000 images. CityScapes additionally adds about 23,000 images. We complement with a random sample of ADE-20K images with a minimum resolution of 750 x 750. It results in 40.000 original images, used to create pairs of training images by applying geometric transformations to them. The path to the original images as well as the geometric transformation parameters are given in the csv files 'assets/csv_files/homo_aff_tps_train_DPED_CityScape_ADE.csv' and 'assets/csv_files/homo_aff_tps_test_DPED_CityScape_ADE.csv'.

  1. Download the original images

Put all the datasets in the same directory. As illustration, your root training directory should be organised as follows:

training_datasets/
    ├── original_images/
    ├── CityScape/
    ├── CityScape_extra/
    └── ADE20K_2016_07_26/
  1. Save the synthetic image pairs and flows to disk
    During training, from this set of original images, the pairs of synthetic images could be created on the fly at each epoch. However, this dataset generation takes time and since no augmentation is applied at each epoch, one can also create the dataset in advance and save it to disk. During training, the image pairs composing the training datasets are then just loaded from the disk before passing through the network, which is a lot faster. To generate the training dataset and save it to disk:
python assets/save_training_dataset_to_disk.py --image_data_path /directory/to/original/training_datasets/ 
--csv_path assets/homo_aff_tps_train_DPED_CityScape_ADE.csv --save_dir /path/to/save_dir --plot True

It will create the images pairs and corresponding flow fields in save_dir/images and save_dir/flow respectively.

  1. Add the paths in admin/local.py as 'training_cad_520' and 'validation_cad_520'
</details> <details> <summary><b>COCO </b></summary>

This is useful for adding moving objects. Download the images along with annotations from here. The root folder should be organized as follows. The add the paths in admin/local.py as 'coco'.

coco_root
    └── annotations
        └── instances_train2014.json
    └──images
        └── train2014
</details> <details> <summary><b> MegaDepth </b></summary>

We use the reconstructions provided in the D2-Net repo. You can download the undistorted reconstructions and aggregated scene information folder directly here - Google Drive.

File structure should be the following:

MegaDepth
├── Undistorted_Sfm
└── scene_info

Them add the paths in admin/local.py as 'megadepth_training'.

</details>

Training scripts

The framework currently contains the training code for the following matching networks. The setting files can be used train the networks, or to know the exact training details.

<details> <summary><b>UAWarpC <a name="uawarpc"></a></b></summary>

This is adapted from our recent work Refign, with code. It allows training a probabilistic correspondence network unsupervised (mix of PDCNet and WarpC). It uses a simplifided version of PDCNet, without GOCor and which is predicting a uni-modal Gaussian probability distribution at every pixel instead of a Mixture of Laplacians.

</details> <details> <summary><b>Probabilistic Warp Consistency (PWarpC) <a name="pwarpc"></a></b></summary> </details> <details> <summary><b>Warp Consistency (WarpC) <a name="warpc"></a></b></summary> </details> <details> <summary><b>PDC-Net and PDC-Net+<a name="pdcnet"></a></b></summary> </details> <details> <summary><b>Example training with randomly generated data <a name="glunet"></a></b></summary> </details> <details> <summary><b>GLU-Net <a name="glunet"></a></b></summary> </details>

Training your own networks

To train a custom network using the toolkit, the following components need to be specified in the train settings. For reference, see train_GLUNet_static.py.

6. Acknowledgement <a name="acknowledgement"></a>

We borrow code from public projects, such as pytracking, GLU-Net, DGC-Net, PWC-Net, NC-Net, Flow-Net-Pytorch, RAFT, CATs...

7. ChangeLog <a name="changelog"></a>