Cycle GAN implementation in tensorflow 2.0
- Tensorflow 2.0
- Matplotlib
Dataset for training of CycleGAN can be downloaded with following code. This dataset contain images of Horses and Zebras. Our goal is to generate zebras from horses from image to image translation with unpaired training.
_URL = 'https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/horse2zebra.zip'
path_to_zip = tf.keras.utils.get_file('horse2zebra.zip',
origin=_URL,
extract=True)
PATH = os.path.join(os.path.dirname(path_to_zip), 'dataset/')
├── dataset # Dataset folder
├── trainA # folder contains Horses
│ ├── *.jpg
| |........
| └── *.jpg
├── trainB # folder contains Zebras
│ ├── *.jpg
| |........
| └── *.jpg
├── testA # test folder contains Horses
│ ├── *.jpg
| |........
| └── *.jpg
└── testB # test folder contains Zebras
├── *.jpg
|........
└── *.jpg
Windows
python cyclegan.py
Linux and MAC
CUDA_VISIBLE_DEVICES='GPU_NO' python cyclegan.py
In code change mode in **kwargs
kwargs = {'epochs': 500,
'path': 'dataset',
'mode':'test',
'output_path':'Exp_1',
'batch_size':1,
}
Run same command for testing
python cyclegan.py