Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aitorzip/pytorch-cyclegan
A clean and readable Pytorch implementation of CycleGAN
https://github.com/aitorzip/pytorch-cyclegan
artificial-intelligence computer-graphics computer-vision cyclegan deep-learning generative-adversarial-network image-generation image-processing pytorch
Last synced: 6 days ago
JSON representation
A clean and readable Pytorch implementation of CycleGAN
- Host: GitHub
- URL: https://github.com/aitorzip/pytorch-cyclegan
- Owner: aitorzip
- License: gpl-3.0
- Created: 2017-12-12T00:01:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-20T23:23:16.000Z (over 2 years ago)
- Last Synced: 2024-12-15T20:06:06.786Z (6 days ago)
- Topics: artificial-intelligence, computer-graphics, computer-vision, cyclegan, deep-learning, generative-adversarial-network, image-generation, image-processing, pytorch
- Language: Python
- Homepage: https://arxiv.org/abs/1703.10593
- Size: 534 KB
- Stars: 1,249
- Watchers: 12
- Forks: 289
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pytorch-CycleGAN
A clean and readable Pytorch implementation of CycleGAN (https://arxiv.org/abs/1703.10593)## Prerequisites
Code is intended to work with ```Python 3.6.x```, it hasn't been tested with previous versions### [PyTorch & torchvision](http://pytorch.org/)
Follow the instructions in [pytorch.org](http://pytorch.org) for your current setup### [Visdom](https://github.com/facebookresearch/visdom)
To plot loss graphs and draw images in a nice web browser view
```
pip3 install visdom
```## Training
### 1. Setup the dataset
First, you will need to download and setup a dataset. The easiest way is to use one of the already existing datasets on UC Berkeley's repository:
```
./download_dataset
```
Valid are: apple2orange, summer2winter_yosemite, horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, ae_photosAlternatively you can build your own dataset by setting up the following directory structure:
.
├── datasets
| ├── # i.e. brucewayne2batman
| | ├── train # Training
| | | ├── A # Contains domain A images (i.e. Bruce Wayne)
| | | └── B # Contains domain B images (i.e. Batman)
| | └── test # Testing
| | | ├── A # Contains domain A images (i.e. Bruce Wayne)
| | | └── B # Contains domain B images (i.e. Batman)
### 2. Train!
```
./train --dataroot datasets// --cuda
```
This command will start a training session using the images under the *dataroot/train* directory with the hyperparameters that showed best results according to CycleGAN authors. You are free to change those hyperparameters, see ```./train --help``` for a description of those.Both generators and discriminators weights will be saved under the output directory.
If you don't own a GPU remove the --cuda option, although I advise you to get one!
You can also view the training progress as well as live output images by running ```python3 -m visdom``` in another terminal and opening [http://localhost:8097/](http://localhost:8097/) in your favourite web browser. This should generate training loss progress as shown below (default params, horse2zebra dataset):
![Generator loss](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/loss_G.png)
![Discriminator loss](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/loss_D.png)
![Generator GAN loss](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/loss_G_GAN.png)
![Generator identity loss](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/loss_G_identity.png)
![Generator cycle loss](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/loss_G_cycle.png)## Testing
```
./test --dataroot datasets// --cuda
```
This command will take the images under the *dataroot/test* directory, run them through the generators and save the output under the *output/A* and *output/B* directories. As with train, some parameters like the weights to load, can be tweaked, see ```./test --help``` for more information.Examples of the generated outputs (default params, horse2zebra dataset):
![Real horse](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/real_A.jpg)
![Fake zebra](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/fake_B.png)
![Real zebra](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/real_B.jpg)
![Fake horse](https://github.com/ai-tor/PyTorch-CycleGAN/raw/master/output/fake_A.png)## License
This project is licensed under the GPL v3 License - see the [LICENSE.md](LICENSE.md) file for details## Acknowledgments
Code is basically a cleaner and less obscured implementation of [pytorch-CycleGAN-and-pix2pix](https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix). All credit goes to the authors of [CycleGAN](https://arxiv.org/abs/1703.10593), Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A.