资源算法DiscoGAN-pytorch

DiscoGAN-pytorch

2019-09-27 | |  108 |   0 |   0

DiscoGAN in PyTorch

PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks.

model.png

* All samples in README.md are genearted by neural network except the first image for each row.
* Network structure is slightly diffferent (here) from the author's code.

Requirements

Usage

First download datasets (from pix2pix) with:

$ bash ./data/download_dataset.sh dataset_name

or you can use your own dataset by placing images like:

data
├── YOUR_DATASET_NAME
│   ├── A
│   |   ├── xxx.jpg (name doesn't matter)
│   |   ├── yyy.jpg
│   |   └── ...
│   └── B
│       ├── zzz.jpg
│       ├── www.jpg
│       └── ...
└── download_dataset.sh

All images in each dataset should have same size like using imagemagick:

# for Ubuntu
$ sudo apt-get install imagemagick
$ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/A/*.jpg
$ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/B/*.jpg

# for Mac
$ brew install imagemagick
$ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/A/*.jpg
$ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/B/*.jpg

# for scale and center crop
$ mogrify -resize 256x256^ -gravity center -crop 256x256+0+0 -quality 100 -path ../A/*.jpg

To train a model:

$ python main.py --dataset=edges2shoes --num_gpu=1
$ python main.py --dataset=YOUR_DATASET_NAME --num_gpu=4

To test a model (use your load_path):

$ python main.py --dataset=edges2handbags --load_path=logs/edges2handbags_2017-03-18_10-55-37 --num_gpu=0 --is_train=False

Results

1. Toy dataset

Result of samples from 2-dimensional Gaussian mixture models. IPython notebook

# iteration: 0:

toy_before.png

# iteration: 10000:

toy_after.png

2. Shoes2handbags dataset

# iteration: 11200:

x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (shoe -> handbag -> shoe)

 shoes2handbags_valid_x_B.pngshoes2handbags_x_BA_11200.pngshoes2handbags_x_BAB_11200.png

x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (handbag -> shoe -> handbag)

shoes2handbags_valid_x_A.pngshoes2handbags_x_AB_11200.pngshoes2handbags_x_ABA_11200.png

x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) -> G_AB(G_BA(G_AB(x_A))) -> G_BA(G_AB(G_BA(G_AB(x_A)))) -> ...

shoes2handbags_repetitive_0_x_A_0.pngshoes2handbags_repetitive_0_x_A_1.pngshoes2handbags_repetitive_0_x_A_2.pngshoes2handbags_repetitive_0_x_A_3.pngshoes2handbags_repetitive_0_x_A_5.pngshoes2handbags_repetitive_0_x_A_5.pngshoes2handbags_repetitive_0_x_A_6.png

3. Edges2shoes dataset

# iteration: 9600:

x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (color -> sketch -> color)

edges2shoes_valid_x_B.pngedges2shoes_x_BA_9600.pngedges2shoes_x_BAB_9600.png


x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (sketch -> color -> sketch)

edges2shoes_valid_x_A.pngedges2shoes_x_AB_9600.pngedges2shoes_x_ABA_9600.png


x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) -> G_AB(G_BA(G_AB(x_A))) -> G_BA(G_AB(G_BA(G_AB(x_A)))) -> ...

edges2shoes_repetitive_0_x_A_0.pngedges2shoes_repetitive_0_x_A_1.pngedges2shoes_repetitive_0_x_A_2.pngedges2shoes_repetitive_0_x_A_3.pngedges2shoes_repetitive_0_x_A_4.pngedges2shoes_repetitive_0_x_A_5.pngedges2shoes_repetitive_0_x_A_6.png


4. Edges2handbags dataset

# iteration: 9500:

x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (color -> sketch -> color)

edges2handbags_valid_x_B.pngedges2handbags_x_BA_9500.pngedges2handbags_x_BAB_9500.png

x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (sketch -> color -> sketch)

edges2handbags_valid_x_A.pngedges2handbags_x_AB_9500.pngedges2handbags_x_ABA_9500.png

x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) -> G_AB(G_BA(G_AB(x_A))) -> G_BA(G_AB(G_BA(G_AB(x_A)))) -> ...

edges2handbags_repetitive_0_x_A_0.pngedges2handbags_repetitive_0_x_A_1.pngedges2handbags_repetitive_0_x_A_2.pngedges2handbags_repetitive_0_x_A_3.pngedges2handbags_repetitive_0_x_A_4.pngedges2handbags_repetitive_0_x_A_5.pngedges2handbags_repetitive_0_x_A_6.png


5. Cityscapes dataset

# iteration: 8350:

x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (image -> segmentation -> image)

cityscapes_valid_x_A.pngcityscapes_x_AB_8350.pngcityscapes_x_ABA_8350.png


x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (segmentation -> image -> segmentation)

cityscapes_valid_x_B.pngcityscapes_x_BA_8350.pngcityscapes_x_BAB_8350.png


6. Map dataset

# iteration: 22200:

x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (image -> segmentation -> image)

maps_valid_x_A.pngmaps_x_AB_22200.pngmaps_x_ABA_22200.png


x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (segmentation -> image -> segmentation)

maps_valid_x_B.pngmaps_x_BA_22200.pngmaps_x_BAB_22200.png


7. Facades dataset

Generation and reconstruction on dense segmentation dataset looks weird which are not included in the paper.
I guess a naive choice of mean square error loss for reconstruction need some change on this dataset.

# iteration: 19450:

x_B -> G_BA(x_B) -> G_AB(G_BA(x_B)) (image -> segmentation -> image)

facades_valid_x_A.pngfacades_x_AB_19450.pngfacades_x_ABA_19450.png


x_A -> G_AB(x_A) -> G_BA(G_AB(x_A)) (segmentation -> image -> segmentation)

facades_valid_x_B.pngfacades_x_BA_19450.pngfacades_x_BAB_19450.png


Related works

Author

Taehoon Kim / @carpedm20


上一篇:pytorch-generative-adversarial-networks

下一篇:AGE

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...