Skip to content

hcwiley/CycleGAN-Tensorflow-2

 
 

Repository files navigation

News

  • We re-implement CycleGAN by Tensorflow 2! The old versions are here: v1, v0.


CycleGAN - Tensorflow 2

Tensorflow 2 implementation of CycleGAN.

Paper: Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks

Author: Jun-Yan Zhu et al.

Exemplar results

summer2winter

row 1: summer -> winter -> reconstructed summer, row 2: winter -> summer -> reconstructed winter

horse2zebra

row 1: horse -> zebra -> reconstructed horse, row 2: zebra -> horse -> reconstructed zebra

apple2orange

row 1: apple -> orange -> reconstructed apple, row 2: orange -> apple -> reconstructed orange

Usage

Setup

conda create -n cyclegan python=3.10

conda activate cyclegan

sh ./setup-macos-conda.sh
  • Environment

    • Python 3.10

    • TensorFlow 2.9, TensorFlow Addons 0.17.1

    • OpenCV, scikit-image, tqdm, oyaml

    • we recommend Anaconda or Miniconda, then you can create the TensorFlow 2.9 environment with commands below

      conda create -n cyclegan python=3.10
      
      conda activate cyclegan
      
      conda install -c apple scikit-image tqdm tensorflow=2.9
      
      conda install -c conda-forge oyaml
      
      pip install tensorflow-addons==0.17.1 tensorflow-macos==2.9.0 tensorflow-metal==0.5.0
    • NOTICE: if you create a new conda environment, remember to activate it before any other command

      source activate cyclegan
  • Dataset

    • download the summer2winter dataset

      sh ./download_dataset.sh summer2winter_yosemite
    • download the horse2zebra dataset

      sh ./download_dataset.sh horse2zebra
    • see download_dataset.sh for more datasets

  • Example of training

    CUDA_VISIBLE_DEVICES=0 python train.py --dataset summer2winter_yosemite
    • tensorboard for loss visualization

      tensorboard --logdir ./output/summer2winter_yosemite/summaries --port 6006
  • Example of testing

    CUDA_VISIBLE_DEVICES=0 python test.py --experiment_dir ./output/summer2winter_yosemite

saving a model

The test.py file also provides the ability to save a model for re-running on different machines and through the run.py script

 python test.py --save 1 --model_dir /Users/hcwiley/ml-models/hcwiley/$model_name --experiment_dir ./output/$model_name

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.2%
  • Shell 1.8%