Skip to content

An implementation of CycleGAN to transform photos into artistic style.

Notifications You must be signed in to change notification settings

HoganHPH/CycleGAN-Photo2Art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CycleGAN-Finphot2Art

UEF_art UEF_photo

First words

In this repository, I build and train a CycleGAN model from scratch, applying it to photos of landscapes from where I live in Joensuu, Finland. The goal is to create some amazing artwork.

Requirements

  • Python3
  • tqdm
  • numpy
  • matplotlib
  • seaborn
  • opencv-python
  • torch
  • torchvision

Install

First, clone the repository.

git clone https://github.com/HoangPham3003/CycleGAN-Finphot2Art.git
cd CycleGAN-Finphot2Art

Second, create and activate the python environment.

python3 -m venv .venv
source .venv/bin/activate

Finally, install requirements.

pip install --upgrade pip
pip install -r requirements.txt

Train

Default parameters
To start training with the default parameters, run:

python train.py

Custom parameters
To customize training, you can adjust the parameters as follows:

python train.py -pt CycleGAN.pt -lr 0.0002 -ep 20 -bs 1 -ds 200 -ts 256 -d cuda -s True 

For a detailed explanation of the training parameters, refer to the train.py

Infer

To generate a new artwork from a photo:

python infer.py -pt CycleGAN.pt -ip img1.jpg -sd inference -d cuda

For a detailed explanation of the inference parameters, refer to the infer.py

Results

In this experiment, I use the vangogh2photo dataset for training. More dataset (cityscapes, horse2zebra, maps, monet2photo,...) can be found at here.The model is trained for 20 epochs with a batch size of 1, resulting in a total of 130,000 steps.

  • First, I examine the generator and discriminator losses:
  • train_log

  • Second, I review the fake and real images at some steps.
  • step_0_fake step_0_real step_60000_fake step_60000_real step_130000_fake step_130000_fake

Methodology

A detailed explanation of the proposed method can be found in the official CycleGAN paper Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks

Acknowledgements

Very thanks to authors who have implementations of CycleGAN:

  1. Official CycleGAN by @junyanz
  2. CycleGAN in pytorch by @aitorzip
  3. GAN specialization tutorial by Coursera

About

An implementation of CycleGAN to transform photos into artistic style.

Topics

Resources

Stars

Watchers

Forks