Pytorch implementation of "SinGAN: Learning a Generative Model from a Single Natural Image"
Pytorch implementation of "SinGAN: Learning a Generative Model from a Single Natural Image" (arxiv)
Official repository : SinGAN Official Pytorch implementation
This implementation is based on these repos.
This repository is not official implementation. The official one is here : SinGAN Official Pytorch implementation.
We introduce SinGAN, an unconditional generative model that can be learned from a single natural image. Our model is trained to capture the internal distribution of patches within the image, and is then able to generate high quality, diverse samples that carry the same visual content as the image. SinGAN contains a pyramid of fully convolu- tional GANs, each responsible for learning the patch distri- bution at a different scale of the image. This allows generat- ing new samples of arbitrary size and aspect ratio, that have significant variability, yet maintain both the global struc- ture and the fine textures of the training image. In contrast to previous single image GAN schemes, our approach is not limited to texture images, and is not conditional (i.e. it gen- erates samples from noise). User studies confirm that the generated samples are commonly confused to be real im- ages. We illustrate the utility of SinGAN in a wide range of image manipulation tasks.
Download "monet2photo" dataset from https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/
Extract and rename "trainB" and "testB" to "trainPhoto" and "testPhoto", respectively. Then, place "trainPhoto" and "testPhoto" in "SinGANdata" folder
Example directory hierarchy :
Project
|--- data
| |--- SinGANdata
| |--- trainPhoto
| |--- testPhoto
|--- SinGAN
|--- code
|--- models
| |--- generator.py
| |--- ...
|--- main.py
|--- train.py
| ...
SinGAN uses only one image to train and test. Therefore multi-gpus mode is not supported.
python main.py --gpu 0 --gantype zerogp --img_size_max 1025
python main.py --gpu 0 --img_to_use 0 --img_size_max 1025 --gantype wgangp
python main.py --gpu 0 --img_to_use 0 --img_size_max 1025 --gantype zerogp --validation --load_model $(dir)
Thunder image is from : Google
Original / Reconstructed / Generated (33, 59, 105, 187 px)
More generation results