All Projects → otenim → Glcic Pytorch

otenim / Glcic Pytorch

Licence: mit
A High-Quality PyTorch Implementation of "Globally and Locally Consistent Image Completion".

Programming Languages

python
139335 projects - #7 most used programming language
python36
32 projects

Projects that are alternatives of or similar to Glcic Pytorch

Pytorch Lesson Zh
pytorch 包教不包会
Stars: ✭ 279 (+97.87%)
Mutual labels:  neural-networks, gan
Deep Learning Resources
由淺入深的深度學習資源 Collection of deep learning materials for everyone
Stars: ✭ 422 (+199.29%)
Mutual labels:  neural-networks, gan
Nn
🧑‍🏫 50! Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠
Stars: ✭ 5,720 (+3956.74%)
Mutual labels:  neural-networks, gan
Machine Learning
머신러닝 입문자 혹은 스터디를 준비하시는 분들에게 도움이 되고자 만든 repository입니다. (This repository is intented for helping whom are interested in machine learning study)
Stars: ✭ 705 (+400%)
Mutual labels:  neural-networks, gan
Qualia2.0
Qualia is a deep learning framework deeply integrated with automatic differentiation and dynamic graphing with CUDA acceleration. Qualia was built from scratch.
Stars: ✭ 41 (-70.92%)
Mutual labels:  neural-networks, gan
Cyclegan Qp
Official PyTorch implementation of "Artist Style Transfer Via Quadratic Potential"
Stars: ✭ 59 (-58.16%)
Mutual labels:  neural-networks, gan
Simgan
Implementation of Apple's Learning from Simulated and Unsupervised Images through Adversarial Training
Stars: ✭ 406 (+187.94%)
Mutual labels:  neural-networks, gan
Deep learning projects
Stars: ✭ 28 (-80.14%)
Mutual labels:  neural-networks, gan
Artificialintelligenceengines
Computer code collated for use with Artificial Intelligence Engines book by JV Stone
Stars: ✭ 35 (-75.18%)
Mutual labels:  neural-networks, gan
Keras Gan
Keras implementations of Generative Adversarial Networks.
Stars: ✭ 8,494 (+5924.11%)
Mutual labels:  neural-networks, gan
Deep Learning With Python
Example projects I completed to understand Deep Learning techniques with Tensorflow. Please note that I do no longer maintain this repository.
Stars: ✭ 134 (-4.96%)
Mutual labels:  neural-networks, gan
Brain Bits
A P300 online spelling mechanism for Emotiv headsets. It's completely written in Node.js, and the GUI is based on Electron and Vue.
Stars: ✭ 138 (-2.13%)
Mutual labels:  neural-networks
Ncrfpp
NCRF++, a Neural Sequence Labeling Toolkit. Easy use to any sequence labeling tasks (e.g. NER, POS, Segmentation). It includes character LSTM/CNN, word LSTM/CNN and softmax/CRF components.
Stars: ✭ 1,767 (+1153.19%)
Mutual labels:  neural-networks
Pytorch 101 Tutorial Series
PyTorch 101 series covering everything from the basic building blocks all the way to building custom architectures.
Stars: ✭ 136 (-3.55%)
Mutual labels:  neural-networks
Infogan Pytorch
implement infoGAN using pytorch
Stars: ✭ 135 (-4.26%)
Mutual labels:  gan
Bender
Easily craft fast Neural Networks on iOS! Use TensorFlow models. Metal under the hood.
Stars: ✭ 1,728 (+1125.53%)
Mutual labels:  neural-networks
Unetgan
Official Implementation of the paper "A U-Net Based Discriminator for Generative Adversarial Networks" (CVPR 2020)
Stars: ✭ 139 (-1.42%)
Mutual labels:  gan
Ml Agents
Unity Machine Learning Agents Toolkit
Stars: ✭ 12,134 (+8505.67%)
Mutual labels:  neural-networks
Oneshottranslation
Pytorch implementation of "One-Shot Unsupervised Cross Domain Translation" NIPS 2018
Stars: ✭ 135 (-4.26%)
Mutual labels:  gan
Chainer Cifar10
Various CNN models for CIFAR10 with Chainer
Stars: ✭ 134 (-4.96%)
Mutual labels:  neural-networks

GLCIC-PyTorch

This repository provides a pytorch-based implementation of GLCIC introduced by Iizuka et. al.

glcic
result_1 result_2 result_3

Requirements

Our scripts were tested in the following environment.

  • Python: 3.7.6
  • torch: 1.6.0 (cuda 10.1)
  • torchvision: 0.7.0
  • tqdm: 4.50.2
  • Pillow: 8.0.0
  • opencv-python: 4.4.0.44
  • numpy: 1.19.2
  • GPU: Geforce GTX 1080Ti (12GB RAM) X 4

You can install all the requirements by executing below.

# in <path-to-this-repo>/
pip install -r requirements.txt

DEMO (Inference)

1. Download pretrained generator model and training config file.

Both the generator and discriminator were trained on the CelebA dataset. Note that you don't need to have dicriminator when performing image completion (discriminator is needed only during training).

2. Inference

# in <path-to-this-repo>/
python predict.py model_cn config.json images/test_2.jpg test_2_out.jpg

Left: raw input image
Center: masked input image
Right: inpainted output image

DEMO (Training)

This section introduces how to train a glcic model using CelebA dataset.

1. Download the dataset

Download the dataset from this official link.

Then, execute the following commands.

# unzip dataset
unzip img_align_celeba.zip
# move dataset
mv img_align_celeba/ <path-to-this-repo>/datasets/
# move into datasets/ directory
cd <path-to-this-repo>/datasets/
# make dataset
python make_dataset.py img_align_celeba/

The last command splits the dataset into training dataset (80%) and test dataset (20%) randomly.

2. Training

Run the following command.

# in <path-to-this-repo>
python train.py datasets/img_align_celeba results/demo/

Training results (model snapshots & test inpainted outputs) are to be saved in results/demo/.

The training procedure consists of the following three phases.

  • Phase 1: trains only generator.
  • Phase 2: trains only discriminator, while generator is frozen.
  • Phase 3: both generator and discriminator are jointly trained.

Default settings of train.py are based on the original paper except for batch size. If you need to reproduce the paper result, add --data_parallel --bsize 96 when executing training.

How to train with custom dataset ?

1. Prepare dataset

You have to prepare a dataset in the following format.

dataset/ # any name is OK
    |____train/ # used for training
    |       |____XXXX.jpg # .png format is also acceptable.
    |       |____OOOO.jpg
    |       |____....
    |____test/  # used for test
            |____oooo.jpg
            |____xxxx.jpg  
            |____....

Both dataset/train and dataset/test are required.

2. Training

# in <path-to-this-repo>/
# move dataset
mv dataset/ datasets/
# execute training
python train.py datasets/dataset/ results/result/ [--data_parallel (store true)] [--cn_input_size (int)] [--ld_input_size (int)] [--init_model_cn (str)] [--init_model_cd (str)] [--steps_1 (int)] [--steps_2 (int)] [--steps_3 (int)] [--snaperiod_1 (int)] [--snaperiod_2 (int)] [--snaperiod_3 (int)] [--bsize (int)] [--bdivs (int)]

Arguments

  • <dataset> (required): path to the dataset directory.
  • <result> (required): path to the result directory.
  • [--data_parallel (store true)]: when this flag is enabled, models are trained in data-parallel way. If N gpus are available, N gpus are used during training (default: disabled).
  • [--cn_input_size (int)]: input size of generator (completion network). All input images are rescalled so that the minimum side is equal to cn_input_size then randomly cropped into cn_input_size x cn_input_size (default: 160).
  • [--ld_input_size (int)]: input size of local discriminator (default: 96). Input size of global discriminator is the same as [--cn_input_size].
  • [--init_model_cn (str)]: path to a pretrained generator, used as its initial weights (default: None).
  • [--init_model_cd (str)]: path to a pretrained discriminator, used as its initial weights (default: None).
  • [--steps_1 (int)]: training steps during phase 1 (default: 90,000).
  • [--steps_2 (int)]: training steps during phase 2 (default: 10,000).
  • [--steps_3 (int)]: training steps during phase 3 (default: 400,000).
  • [--snaperiod_1 (int)]: snapshot period during phase 1 (default: 10,000).
  • [--snaperiod_2 (int)]: snapshot period during phase 2 (default: 2,000).
  • [--snaperiod_3 (int)]: snapshot period during phase 3 (default: 10,000).
  • [--max_holes (int)]: maximum number of holes randomly generated and applied to each input image (default: 1).
  • [--hole_min_w (int)]: minimum width of a hole (default: 48).
  • [--hole_max_w (int)]: maximum width of a hole (default: 96).
  • [--hole_min_h (int)]: minimum height of a hole (default: 48).
  • [--hole_max_h (int)]: maximum height of a hole (default: 96).
  • [--bsize (int)]: batch size (default: 16). bsize >= 96 is strongly recommended.
  • [--bdivs (int)]: divide a single training step of batch size = bsize into bdivs steps of batch size = bsize/bdivs, which produces the same training results as when bdivs = 1 but uses smaller gpu memory space at the cost of speed. This option can be used together with data_parallel (default: 1).

Example: If you train a model with batch size 24 with data_parallel option and leave the other settings as default, run the following command.

# in <path-to-this-repo>/
python train.py datasets/dataset results/result --data_parallel --bsize 24

How to perform infenrece with custom dataset ?

Assume you've finished training and result directory is <path-to-this-repo>/results/result.

# in <path-to-this-repo>/
python predict.py results/result/phase_3/model_cn_step<step-number> results/result/config.json <input_img> <output_img> [--max_holes (int)] [--img_size (int)] [--hole_min_w (int)] [--hole_max_w (int)] [--hole_min_h (int)] [--hole_max_h (int)]

Arguments

  • <input_img> (required): path to an input image.
  • <output_img> (required): path to an output image.
  • [--img_size (int)]: input size of generator. Input images are rescalled so that the minimum side = img_size then randomly cropped into img_size x img_size (default: 160).
  • [--max_holes (int)]: maximum number of holes to be randomly generated (default: 5).
  • [--hole_min_w (int)]: minimum width of a hole (default: 24).
  • [--hole_max_w (int)]: maximum width of a hole (default: 48).
  • [--hole_min_h (int)]: minimum height of a hole (default: 24).
  • [--hole_max_h (int)]: maximum height of a hole (default: 48).

Example: If you make an inference with an input image <path-to-this-repo>/input.jpg and save output image as <path-to-this-repo>/output.jpg, run the following command.

# in <path-to-this-repo>/
python predict.py results/result/phase_3/model_cn_step{step_number} results/result/config.json input.jpg output.jpg
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].