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.
- Python3
- tqdm
- numpy
- matplotlib
- seaborn
- opencv-python
- torch
- torchvision
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
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
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
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:
- Second, I review the fake and real images at some steps.
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
Very thanks to authors who have implementations of CycleGAN: