apple2373 / pytorch-small-dataset-image-generation

27 stars 15 forks source link

Small dataset image generation with PyTorch

pytorch re-implementation of Image Generation from Small Datasets via Batch Statistics Adaptation

Requirements

pytorch 1.0
python 3.6

see env.yml for the exact environment I used.

You will also need ImageNet pretrained 128 x 128 BigGAN weights from the BigGAN author's repository.

Download it from here: https://drive.google.com/open?id=1nAle7FCVFZdix2--ks0r5JBkFnKw8ctW

Unzip it, and put G_ema.pth to ./data/

training

python train.py --dataset anime --gpu 0 --pretrained ./data/G_ema.pth

Thanks to ak9250, we also have notebook to run on Google Colaboratory. See SmallGan.ipynb

Sample Reconstruction Results

Anime Face

reconstruction

random

interpolation

Real Face

reconstruction

random

interpolation

Comments

I found it's important to tune hyper-parameters correctly. Basically there are five types of layers that are tuned. You can set learning rate for each of them individually.

Dataset

I parepared random 50 images for face and anime. See ./data directory.

If you want to add your own dataset, check dataloaders/setup_dataloader_smallgan.py and add it.

Disclaimer

I just check the results visually and don't check the evaluation scores (KMMD and Mean Variance). If you need complete reproduction, you should use author's one. Honestly, the visual quality looks worse than the originally reported ones. Anther difference is that this repository uses BigGAN for 128x128 but author uses BigGAN for 256x256 and SNGAN for 128x128.

Acknowledgement

I'd like to Thank Atsuhiro Noguchi for the help via personal email as well as the open sourced code, Minjun Li for helpful discussion and anime dataset preparation.