Pytorch implementation of Paper "RANSAC-Flow: generic two-stageimage alignment"
[PDF] [Project webpage] [Demo]
If our project is helpful for your research, please consider citing :
@inproceedings{shen2020ransac,
title={RANSAC-Flow: generic two-stage image alignment},
author={Shen, Xi and Darmon, Francois and Efros, Alexei A and Aubry, Mathieu},
booktitle={Arxiv},
year={2020}
}
1.1. Aligning Artworks (More results can be found in our project webpage)
Input | Our Fine Alignment | ||
---|---|---|---|
Animation | Avg | Animation | Avg |
1.2. 3D recontruction 2-view geometry estimation (More results can be found in our project webpage)
Source | Target | 3D Reconstruction |
---|---|---|
Source | Target | Texture Transfer |
---|---|---|
Other results (such as: aligning duplicated artworks, optical flow, localization etc.) can be seen in our paper.
Install Pytorch adapted to your CUDA version :
Other dependencies (tqdm, visdom, pandas, kornia, opencv-python) :
bash requirement.sh
Quick download :
cd model/pretrained
bash download_model.sh
For more details of the pre-trained models, see here
Download the results of ArtMiner :
cd data/
bash Brueghel_detail.sh # Brueghel detail dataset (208M) : visual results, aligning groups of details
Download our training data here (~9G). It includes the validation and test data as well.
A quick start guide of how to use our code is available in demo.ipynb
To run the training, we need pairs that are coarsely aligned. We provide a notebook to show how to generate the training pairs. Note that, we also provide our training pairs in here.
The training data need to be downloaded from here and saved into ./data
. The file structure is :
./RANSAC-Flow/data/MegaDepth
├── MegaDepth_Train/
├── MegaDepth_Train_Org/
├── Val/
└── Test/
As mentioned in the paper, the model trained on MegaDepth contains the following 3 different stages of training:
- Stage 1 : we only trained the reconstruction loss. You can find the hyper-parameters in train/stage1.sh. You can run the training of this stage by :
cd train/
bash stage1.sh
- Stage 2 : in this stage, we train jointly: reconstruction loss + cycle consistency of the flow. We started from the model trained in the stage 1. The hyper-parameters are in train/stage2.sh. You need to change the argument --resumePth to your model path. Once it is done, run:
cd train/
bash stage2.sh
- Stage 3 : finally, we trained all the three losses together: reconstruction loss + cycle consistency of the flow + matchability loss. We started from the model trained in the stage 2. The hyper-parameters are in train/stage3.sh. You need to change the argument --resumePth to your model path. Once it is done, run:
cd train/
bash stage3.sh
If you want to conduct fine-tuning on your own dataset. It is recommended to start from our MegaDepth trained model. You can see all the arguments of training by :
cd train/
python train.py --help
If you don't need to predict the matchability, you can set the weight of the matchability loss to 0 (--eta 0 in the train.py), and set your path of images (--trainImgDir). Please refer to train/stage2.sh for other arguments.
In case of predicting matchability, you need to tune the weight of the matchability loss (argument --eta in the train.py) depending on the dataset.
The evaluation of different tasks can be seen in the following files: