Git Product home page Git Product logo

dsnet's Introduction

DSNet

Dynamic Selection Network for Image Inpainting

Requirements

scipy==1.1.0

numpy==1.16.2

torch==1.1.0

torchvision==0.3.0

imageio==2.9.0

Pillow==8.0.1

This is the environment for our experiments. Later versions of these packages might need a few modifications of the code.

Running the program

To perform training, fine-tune or testing, use

sh train.sh

sh finetune.sh

sh test.sh 

There are several arguments that can be used, which are

--data_root +str #where to get the images for training/testing
--mask_root +str #where to get the masks for training/testing
--model_save_path +str #where to save the model during training
--result_save_path +str #where to save the inpainting results during testing
--model_path +str #the pretrained generator to use during training/testing
--target_size +int #the size of images and masks
--mask_mode +int #which kind of mask to be used, 0 for external masks with random order, 1 for randomly generated masks, 2 for external masks with fixed order 
 (It will be better to use mask_mode 2 during testing for fairness)
--batch_size +int #the size of mini-batch for training
--n_threads +int
--gpu_id +int #which gpu to use
--finetune #to finetune the model during training
--test #test the model

For example, to train the network using gpu 1, with pretrained models

python run.py --data_root data --mask_root mask --model_path checkpoints/g_10000.pth --batch_size 6 --gpu 1

to test the network

python run.py --data_root data/images --mask_root data/masks --model_path checkpoints/g_10000.pth --test --mask_mode 2

To fully exploit the performance of the network, we suggest to use the following training procedure, in specific

  1. Train the network, i.e. use the command
python run.py
  1. Finetune the network, i.e. use the command
python run.py --finetune --model_path path-to-trained-generator
  1. Test the model
python run.py --test

How long to train the model for

All the descriptions below are under the assumption that the size of mini-batch is 6

For Paris Street View Dataset, train the model for 400,000 iterations and finetune for 200,000 iterations. (600,000 in total)

For CelebA Dataset, train the model for 350,000 iterations and finetune for 150,000 iterations. (500,000 in total)

For Places2 Dataset, train the model for 2,000,000 iterations and finetune for 1,000,000 iterations. (3,000,000 in total)

We strongly encourage the users to retrain the models if they are used for academic purpose, to ensure fair comparisons (which has been always desired). Achieving a good performance using the current version of code should not be difficult.

Citation

If you find the article or code useful for your project, please refer to

@article{wang2021dynamic,
  title={Dynamic Selection Network for Image Inpainting},
  author={Wang, Ning and Zhang, Yipeng and Zhang, Lefei},
  journal={IEEE Transactions on Image Processing},
  volume={30},
  pages={1784--1798},
  year={2021},
  publisher={IEEE},
  doi={10.1109/TIP.2020.3048629}
}

Paper

See the Paper folder

dsnet's People

Contributors

wangning-001 avatar

Stargazers

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

Watchers

 avatar

dsnet's Issues

为什么模型训练一段时间之后 损失值为NAN

Iteration:6800, l1_loss:0.0195, time_taken:34.68
Iteration:6850, l1_loss:0.0186, time_taken:34.54
Iteration:6900, l1_loss:0.0211, time_taken:34.56
Iteration:6950, l1_loss:0.0197, time_taken:34.67
Iteration:7000, l1_loss:0.0199, time_taken:34.17
Iteration:7050, l1_loss:0.0182, time_taken:34.50
Iteration:7100, l1_loss:nan, time_taken:34.08
Iteration:7150, l1_loss:nan, time_taken:34.11
Iteration:7200, l1_loss:nan, time_taken:33.50
Iteration:7250, l1_loss:nan, time_taken:33.02
Iteration:7300, l1_loss:nan, time_taken:33.36

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.