Giter Club home page Giter Club logo

kd-mvs's Introduction

KD-MVS: Knowledge Distillation Based Self-supervised Learning for Multi-view Stereo

Code for paper KD-MVS: Knowledge Distillation Based Self-supervised Learning for Multi-view Stereo

Tips: If you meet any problems when reproduce our results, please contact Yikang Ding ([email protected]). We are happy to help you solve the problems and share our experience.

Change log

  • 12.2022: Update code and README (e.g., more instruction of training and testing, update the fuse code and the pretrained model).
  • 09.2022: Update code (e.g., for cross view check and prob encoding, training scripts).

Installation

Clone this repo:

git clone https://github.com/megvii-research/KD-MVS.git
cd KD-MVS

We recommend using Anaconda to manage python environment:

conda create -n kdmvs python=3.6
conda activate kdmvs
pip install -r requirements.txt

We also recommend using apex, you can install apex from the official repo.

Data preparation

Training data

Download the preprocessed DTU training data (from Original MVSNet), and unzip it to construct a dataset folder like:

dtu_training
 ├── Cameras
 └── Rectified

Testing data

Download our processed DTU testing data and unzip it as the test data folder, which should contain one cams folder, one images folder and one pair.txt file.

Training

Unsupervised training

Set the configuration in scripts/run_train_unsup.sh as:

  • Set DATASET_DIR as the path of DTU training set.
  • Set LOG_DIR as the path to save the checkpoints.
  • Set NGPUS and BATCH_SIZE according to your machine.
  • (Optional) Modify other hyper-parameters according to the argparse in train_unsup.py, such as summary_freq, save_freq, and so on.

To train your model, run:

bash scripts/run_train_unsup.sh

KD training

Note:

  • We use the apex and sync_bn by default, to use these modules, make sure you have installed the apex according to the official repo.
  • We use the gipuma fusion method by default, please make sure you have compiled and installed it correctly. To do so, you need clone the modified version from Yao Yao. Modify the line-10 in CMakeLists.txt to suit your GPUs. Then install it by cmake . and make, which will generate the executable at FUSIBILE_EXE_PATH.
  • The number and type of GPUs (as well as batchsize) used in training phase might affect the final results. Using sync_bn could help with this problem.

To reproduce the results, please note:

  • The checkpoint of the last epoch isn't always the best one. In supervised mode, we can easily pick the best model with the help of validation set. However, in self-supervised mode, we need to pick models manually based on experience.
  • The performance of different epochs varies greatly, using apex and sync_bn could be helpful (but still can't handle this problem completely).
  • The exprimental results reported in our paper are obtained by using different thresholds in different rounds. However, we also repoduce the results by using the latest code and the same thresholds in different rounds.

Before start training, set the configuration in scripts/run_train_kd.sh as:

  • Set DATASET_DIR as the path of DTU training set.
  • Set LOG_DIR as the path to save the checkpoints.
  • Set CHECKED_DEPTH_DIR as the path to our pseudo label folder.
  • Set NGPUS and BATCH_SIZE according to your machine.
  • (Optional) Modify other hyper-parameters according to the argparse, such as summary_freq, save_freq, and so on.

run:

bash scripts/run_train_kd.sh

Testing

For easy testing, you can download our pretrained models and put them in ckpt folder, or use your own models and follow the instruction below.

Make sure:

Set the configuration in scripts/run_test_dtu.sh:

  • Set TESTPATH as the path of DTU testing set.
  • Set CKPT_FILE as the path of the model weights.
  • Set OUTDIR as the path to save results.
  • Set FUSIBILE_EXE as the path to gipuma fusible file.

Run:

bash scripts/run_test_dtu.sh

The reconstructed point cloud results would be stored in outputs/test_dtu/gipuma_pcd, you can also download our fused point cloud results of KD-trained model from here.

To get quantitative results of the fused point clouds from the official MATLAB evaluation tools, you can refer to TransMVSNet.

By using the latest code, pretrained model and default parameters, you can get the final results like:

Model Acc. Comp. Overall
unsup 0.4166 0.4335 0.4251
KD 0.3674 0.2847 0.3260

Citation

@inproceedings{ding2022kdmvs,
  title={KD-MVS: Knowledge Distillation Based Self-supervised Learning for Multi-view Stereo},
  author={Ding, Yikang and Zhu, Qingtian and Liu, Xiangyue and Yuan, Wentao and Zhang, Haotian  and Zhang, Chi},
  booktitle={European Conference on Computer Vision},
  year={2022},
  organization={Springer}
}

Acknowledgments

We borrow some code from CasMVSNet and U-MVS. We thank the authors for releasing the source code.

kd-mvs's People

Contributors

dingyikang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kd-mvs's Issues

About the performance of the teacher model (i.e. ,Self-supervised Teacher Training)

Amazing Work!
After reading your paper, I have a little question. Table 5 shows the performance of your self-supervised teacher training when
using MVSNet as the backbone, would you like to tell me the performance on DTU using CasMVSNet when only carrying out the self-supervised teacher training.
Thanks, looking forward for your kind reply!

gt mu and sigma

Hello,

Thank you for sharing your work!

How did you generate mu and sigma for pseudo probability distribution(P) for calculating loss with predicted probability distribution?

Does Pseudo mu, sigma go through the same process as 'get_mu_sigma' in module.py ?

Thank you

Too many parameters

Use your pre training model of 18M, but the final result of your training model is more than 1G。

nan error occur!!

when I train train_kd.py,I occured this :

NaN or Inf found in input tensor.
NaN or Inf found in input tensor.
NaN or Inf found in input tensor.
NaN or Inf found in input tensor.
Epoch 0/16, Iter 380/6774, lr 0.000841, train loss = 329.206, depth loss = 7.302, kl loss = 1578.294, approx_kl = 13.548, time = 4.007
Epoch 0/16, Iter 390/6774, lr 0.000855, train loss = 4807.599, depth loss = 22.143, kl loss = 23964.273, approx_kl = 14.745, time = 4.021
Epoch 0/16, Iter 400/6774, lr 0.000868, train loss = 265.932, depth loss = 6.916, kl loss = 1266.214, approx_kl = 12.690, time = 4.017
Epoch 0/16, Iter 410/6774, lr 0.000881, train loss = 699.619, depth loss = 8.129, kl loss = 3435.879, approx_kl = 12.443, time = 3.994
Epoch 0/16, Iter 420/6774, lr 0.000895, train loss = 1849.536, depth loss = 11.716, kl loss = 9175.318, approx_kl = 14.472, time = 3.993
Epoch 0/16, Iter 430/6774, lr 0.000908, train loss = 283.722, depth loss = 8.125, kl loss = 1353.582, approx_kl = 13.006, time = 4.012
Epoch 0/16, Iter 440/6774, lr 0.000921, train loss = 396.045, depth loss = 5.413, kl loss = 1915.851, approx_kl = 12.875, time = 4.017
Epoch 0/16, Iter 450/6774, lr 0.000935, train loss = 1381.491, depth loss = 12.813, kl loss = 6833.853, approx_kl = 14.720, time = 4.025
Epoch 0/16, Iter 460/6774, lr 0.000948, train loss = 899.482, depth loss = 14.196, kl loss = 4421.479, approx_kl = 15.187, time = 4.023
Epoch 0/16, Iter 470/6774, lr 0.000961, train loss = 1201.927, depth loss = 14.667, kl loss = 5935.046, approx_kl = 14.918, time = 4.002
Epoch 0/16, Iter 480/6774, lr 0.000975, train loss = 666.221, depth loss = 7.502, kl loss = 3266.265, approx_kl = 12.968, time = 4.020
Epoch 0/16, Iter 490/6774, lr 0.000988, train loss = 526.644, depth loss = 8.771, kl loss = 2569.961, approx_kl = 12.651, time = 4.046
Epoch 0/16, Iter 500/6774, lr 0.001000, train loss = 1123.106, depth loss = 13.588, kl loss = 5545.175, approx_kl = 14.071, time = 4.021
nan error occur!!
nan error occur!!
nan error occur!!
nan error occur!!

The models in train_unsup.py and infer.py are different

train_unsup.py used CascadeMVSNet_uncertainty()
while infer.py used CascadeMVSNet?
Specifically,
After I trained the unsupervised mvs, I followed the steps of kd-mvs-train to perform the first step of infer.py, but found that the initialization model built during inference was not consistent with the unsupervised teacher model I trained.
image

A problem while reproducing the result on DTU

Great job!
I downloaded the pretrained model, and executed the test(both normal and gipuma) and MATLAB evaluation,finally got the overall 0.3397(normal,0.3409 for gipuma),which is 0.327 in your paper. I wonder if there is something wrong about my impletment. I would appreciate it if you can offer some guidance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.