Image translation by CNNs trained on unpaired data
Branch: master
Clone or download
Latest commit d29df23 Jan 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial commit Jan 7, 2019
README.md initial Jan 7, 2019
arguments.py
consts.py initial Jan 7, 2019
convert.py initial Jan 7, 2019
dataset_jpg.py initial Jan 7, 2019
instance_normalization.py initial Jan 7, 2019
losses.py initial Jan 7, 2019
net.py initial Jan 7, 2019
train.py initial Jan 7, 2019
trainAE.py initial Jan 7, 2019
updater.py initial Jan 7, 2019
updaterAE.py initial Jan 7, 2019
visualization.py initial Jan 7, 2019

README.md

Image translation by CNNs trained on unpaired data

Requirements

  • chainer >= 5.0.0
  • pip install cupy,chainer,chainerui,chainercv

Training

  • Training data preparation: Under the directory named images, place four directories "trainA","trainB","testA","testB"
  • We train two neural networks G and F (generators) together with two auxiliary networks (discriminators).
  • G takes images in domain A (placed under "trainA") and converts them to images in domain B. F goes in the opposite way.
  • Images under "testA" and "testB" are used for validation
  • A typical training is done by
python train.py -cw 256 -ch 256 -R images -t jpg -o results -gc 64 128 256

The jpg files under "images/trainA" and "images/trainB" are cropped in the middle to 256x256 and fed in to neural networks. You will obtain learnt model files "gen_g??.npz" and "gen_f??.npz" under the directory "results". Also, it occasionally produces image files under "results/vis" containing rows with A G(A) F(G(A)) and B F(B) G(F(B)).

  • A brief description of other command-line arguments is give by
python train.py -h

Conversion

python convert.py -a results/args -t jpg -R input_dir -o output_dir -b 10 -m gen_g50.npz

searches for jpg files recursively under input_dir and outputs converted images by the generator G to output_dir. If you specify -m gen_f50.npz instead, you get converted images by the generator F.

Another version

A version based on a shared latent space model is also included. A typical training goes similarly with

python trainAE.py -lreg 0.1 --noise 0.01 --noise_z 0.01 -lz 1