Image-to-image translation aims at learning a mapping of images between different domains, and many successful tasks relied on aligned image pairs. However, it’s not easy to generate paired data for general tasks. Besides, it’s known that generative adversarial networks (GANs) has excellent performance in image generation and image editing. Therefore, we design a system, built on existed Cycle-GAN model, to translate black-and-white film into colorized one automatically.
- Create a dataset folder in "datasets", ex: micky
- Put some training data in "trainA" and "trainB", ex: Gray scale in A and RGB in B
- Put some testing data in "testA" and "testB", ex: Gray scale in A and RGB in B
[Note]
(1). CycleGAN can transfer something from domain A to domain B and from domain B to domain A
(2). In "trainA" and "trainB", I only put some image as example.
- Run main.py to training our Improved-CycleGAN
- Command line:
CUDA_VISIBLE_DEVICES=0 python main.py --dataset_dir=micky --phase=train
- Run main.py to testing our Improved-CycleGAN
- Command line:
CUDA_VISIBLE_DEVICES=0 python main.py --dataset_dir=micky --phase=test --which_direction=AtoB
- AtoB means transfer image from A to B, ex: from Gray scale to RGB
1. Flow Chart
- We improved cycleGAN model with "Improved-WGAN", which is based on "WGAN".
2. Some Results
- Training Set
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
- Testing Set
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
3. Training Visualization
- Discriminator da_loss means the loss of discriminator on domain A and db_loss means the loss of discriminator on domain B. d_loss is equal to (da_loss + db_loss) meaning discriminator loss.
- Generator g_loss_a2b means the loss of generator for changing domain A to domain B and g_loss_b2a means the loss of generator for changing domain B to domain A. g_loss is equal to (g_loss_a2b + g_loss_b2a) meant generator loss.
- TensorFlow
- numpy, scipy, pillow
- I reference a lot from CycleGAN, WGAN and Improved-WGAN
- I also reference a lot code from CycleGAN