{"id":15692376,"url":"https://github.com/bryanlimy/tf2-cyclegan","last_synced_at":"2025-05-08T02:39:39.648Z","repository":{"id":50230080,"uuid":"311714368","full_name":"bryanlimy/tf2-cyclegan","owner":"bryanlimy","description":"TensorFlow 2 implementation of CycleGAN with multi-GPU training.","archived":false,"fork":false,"pushed_at":"2021-06-03T06:09:45.000Z","size":16835,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T16:34:56.847Z","etag":null,"topics":["cyclegan","distributed-training","gan","mirroredstrategy","multi-gpus","tensorflow","tensorflow2","tf2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bryanlimy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-10T16:11:32.000Z","updated_at":"2022-11-28T02:48:45.000Z","dependencies_parsed_at":"2022-08-17T22:40:50.116Z","dependency_job_id":null,"html_url":"https://github.com/bryanlimy/tf2-cyclegan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlimy%2Ftf2-cyclegan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlimy%2Ftf2-cyclegan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlimy%2Ftf2-cyclegan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlimy%2Ftf2-cyclegan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bryanlimy","download_url":"https://codeload.github.com/bryanlimy/tf2-cyclegan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252989148,"owners_count":21836655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cyclegan","distributed-training","gan","mirroredstrategy","multi-gpus","tensorflow","tensorflow2","tf2"],"created_at":"2024-10-03T18:32:23.651Z","updated_at":"2025-05-08T02:39:39.616Z","avatar_url":"https://github.com/bryanlimy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CycleGAN with multi-GPUs training in TensorFlow 2\nThis repository provide a concise example on how to use `tf.distribute.MirroredStrategy` with custom training loops in TensorFlow 2. We adapt the CycleGAN ([Zhu et. al. 2017](https://arxiv.org/pdf/1703.10593.pdf)) tutorials from [Keras](https://keras.io/examples/generative/cyclegan) and [TensorFlow](https://www.tensorflow.org/tutorials/generative/cyclegan) and train the model with multiple GPUs. See [towardsdatascience.com/multi-gpus-and-custom-training-loops-in-tensorflow-2-15b4b86b53bd](https://towardsdatascience.com/multi-gpus-and-custom-training-loops-in-tensorflow-2-15b4b86b53bd) for a detailed tutorial.\n\n|  horse → zebra → horse  |  zebra → horse → zebra  |\n| :---------------------: | :---------------------: |\n| ![](images/x_cycle.png) | ![](images/y_cycle.png) |\n\n## 1. Setup\n- create virtual environment for the project\n  ```\n  conda create -n cyclegan python=3.8\n  ```\n- activate virtual environment\n  ```\n  conda activate cyclegan\n  ```\n- install required packages\n  ```\n  sh setup.sh\n  ```\n\n## 2. Run\n- We use the  `horse2zebra` dataset from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/cycle_gan#cycle_ganhorse2zebra) by default.\n- Training logs and checkpoints are stored in `--output_dir`\n- We can use the following command to train the CycleGAN model on 2 GPUs and store the TensorBoard summary and checkpoints to `runs/`:\n  ```\n  CUDA_VISIBLE_DEVICES=0,1 python main.py --output_dir runs/ --epochs 200\n  ``` \n- Use `--help` to see all available flags.\n\n\n## 3. Result\n- Use `TensorBoard` to inspect the training summary and plots\n  ```\n  tensorboard --logdir runs/cyclegan\n  ```\n  ![](images/tensorboard.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanlimy%2Ftf2-cyclegan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbryanlimy%2Ftf2-cyclegan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanlimy%2Ftf2-cyclegan/lists"}