{"id":18673674,"url":"https://github.com/carpedm20/discogan-pytorch","last_synced_at":"2025-04-12T21:36:22.216Z","repository":{"id":37431490,"uuid":"85299452","full_name":"carpedm20/DiscoGAN-pytorch","owner":"carpedm20","description":"PyTorch implementation of \"Learning to Discover Cross-Domain Relations with Generative Adversarial Networks\"","archived":false,"fork":false,"pushed_at":"2018-03-26T15:26:18.000Z","size":83796,"stargazers_count":1089,"open_issues_count":12,"forks_count":225,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-04-04T01:10:02.235Z","etag":null,"topics":["gan","generative-model","pytorch","unsupervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carpedm20.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":"2017-03-17T10:26:12.000Z","updated_at":"2025-04-01T10:30:41.000Z","dependencies_parsed_at":"2022-08-19T06:10:52.875Z","dependency_job_id":null,"html_url":"https://github.com/carpedm20/DiscoGAN-pytorch","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/carpedm20%2FDiscoGAN-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpedm20%2FDiscoGAN-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpedm20%2FDiscoGAN-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpedm20%2FDiscoGAN-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carpedm20","download_url":"https://codeload.github.com/carpedm20/DiscoGAN-pytorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637408,"owners_count":21137533,"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":["gan","generative-model","pytorch","unsupervised-learning"],"created_at":"2024-11-07T09:16:15.621Z","updated_at":"2025-04-12T21:36:22.192Z","avatar_url":"https://github.com/carpedm20.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DiscoGAN in PyTorch\n\nPyTorch implementation of [Learning to Discover Cross-Domain Relations with Generative Adversarial Networks](https://arxiv.org/abs/1703.05192).\n\n\u003cimg src=\"./assets/model.png\" width=\"80%\"\u003e\n\n**\\* All samples in README.md are genearted by neural network except the first image for each row.**  \n\\* Network structure is slightly diffferent ([here](https://github.com/carpedm20/DiscoGAN-pytorch/blob/master/models.py#L13-L32)) from the author's [code](https://github.com/SKTBrain/DiscoGAN/blob/master/discogan/model.py#L69-L125).\n\n\n## Requirements\n\n- Python 2.7\n- [Pillow](https://pillow.readthedocs.io/en/4.0.x/)\n- [tqdm](https://github.com/tqdm/tqdm)\n- [PyTorch](https://github.com/pytorch/pytorch)\n- [torch-vision](https://github.com/pytorch/vision)\n\n\n## Usage\n\nFirst download datasets (from [pix2pix](https://github.com/phillipi/pix2pix)) with:\n\n    $ bash ./data/download_dataset.sh dataset_name\n\n- `facades`: 400 images from [CMP Facades dataset](http://cmp.felk.cvut.cz/~tylecr1/facade/).\n- `cityscapes`: 2975 images from the [Cityscapes training set](https://www.cityscapes-dataset.com/).\n- `maps`: 1096 training images scraped from Google Maps\n- `edges2shoes`: 50k training images from [UT Zappos50K dataset](http://vision.cs.utexas.edu/projects/finegrained/utzap50k/).\n- `edges2handbags`: 137K Amazon Handbag images from [iGAN project](https://github.com/junyanz/iGAN).\n\nor you can use your own dataset by placing images like:\n\n    data\n    ├── YOUR_DATASET_NAME\n    │   ├── A\n    │   |   ├── xxx.jpg (name doesn't matter)\n    │   |   ├── yyy.jpg\n    │   |   └── ...\n    │   └── B\n    │       ├── zzz.jpg\n    │       ├── www.jpg\n    │       └── ...\n    └── download_dataset.sh\n\n**All images in each dataset should have same size** like using [imagemagick](https://www.imagemagick.org/script/index.php):\n\n    # for Ubuntu\n    $ sudo apt-get install imagemagick\n    $ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/A/*.jpg\n    $ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/B/*.jpg\n\n    # for Mac\n    $ brew install imagemagick\n    $ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/A/*.jpg\n    $ mogrify -resize 256x256! -quality 100 -path YOUR_DATASET_NAME/B/*.jpg\n\n    # for scale and center crop\n    $ mogrify -resize 256x256^ -gravity center -crop 256x256+0+0 -quality 100 -path ../A/*.jpg\n\nTo train a model:\n\n    $ python main.py --dataset=edges2shoes --num_gpu=1\n    $ python main.py --dataset=YOUR_DATASET_NAME --num_gpu=4\n\nTo test a model (use your `load_path`):\n\n    $ python main.py --dataset=edges2handbags --load_path=logs/edges2handbags_2017-03-18_10-55-37 --num_gpu=0 --is_train=False\n\n\n## Results\n\n### 1. Toy dataset\n\nResult of samples from 2-dimensional Gaussian mixture models. [IPython notebook](./notebooks/DiscoGAN.ipynb)\n\n**# iteration: 0**:\n\n\u003cimg src=\"./assets/toy_before.png\" width=\"30%\"\u003e\n\n**# iteration: 10000**:\n\n\u003cimg src=\"./assets/toy_after.png\" width=\"30%\"\u003e\n\n\n### 2. Shoes2handbags dataset\n\n**# iteration: 11200**:\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (shoe -\u003e handbag -\u003e shoe)\n\n\u003cimg src=\"assets/shoes2handbags_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/shoes2handbags_x_BA_11200.png\" width=\"30%\"\u003e \u003cimg src=\"assets/shoes2handbags_x_BAB_11200.png\" width=\"30%\"\u003e\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (handbag -\u003e shoe -\u003e handbag)\n\n\u003cimg src=\"assets/shoes2handbags_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/shoes2handbags_x_AB_11200.png\" width=\"30%\"\u003e \u003cimg src=\"assets/shoes2handbags_x_ABA_11200.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` -\u003e `G_AB(G_BA(G_AB(x_A)))` -\u003e `G_BA(G_AB(G_BA(G_AB(x_A))))` -\u003e ...\n\n\u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_0.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_1.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_2.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_3.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_4.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_5.png\" width=\"13%\"\u003e \u003cimg src=\"assets/shoes2handbags_repetitive_0_x_A_6.png\" width=\"13%\"\u003e\n\n\n### 3. Edges2shoes dataset\n\n**# iteration: 9600**:\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (color -\u003e sketch -\u003e color)\n\n\u003cimg src=\"assets/edges2shoes_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2shoes_x_BA_9600.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2shoes_x_BAB_9600.png\" width=\"30%\"\u003e\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (sketch -\u003e color -\u003e sketch)\n\n\u003cimg src=\"assets/edges2shoes_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2shoes_x_AB_9600.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2shoes_x_ABA_9600.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` -\u003e `G_AB(G_BA(G_AB(x_A)))` -\u003e `G_BA(G_AB(G_BA(G_AB(x_A))))` -\u003e ...\n\n\u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_0.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_1.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_2.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_3.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_4.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_5.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2shoes_repetitive_0_x_A_6.png\" width=\"13%\"\u003e\n\n\n### 4. Edges2handbags dataset\n\n**# iteration: 9500**:\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (color -\u003e sketch -\u003e color)\n\n\u003cimg src=\"assets/edges2handbags_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2handbags_x_BA_9500.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2handbags_x_BAB_9500.png\" width=\"30%\"\u003e\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (sketch -\u003e color -\u003e sketch)\n\n\u003cimg src=\"assets/edges2handbags_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2handbags_x_AB_9500.png\" width=\"30%\"\u003e \u003cimg src=\"assets/edges2handbags_x_ABA_9500.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` -\u003e `G_AB(G_BA(G_AB(x_A)))` -\u003e `G_BA(G_AB(G_BA(G_AB(x_A))))` -\u003e ...\n\n\u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_0.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_1.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_2.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_3.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_4.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_5.png\" width=\"13%\"\u003e \u003cimg src=\"assets/edges2handbags_repetitive_0_x_A_6.png\" width=\"13%\"\u003e\n\n\n### 5. Cityscapes dataset\n\n**# iteration: 8350**:\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (image -\u003e segmentation -\u003e image)\n\n\u003cimg src=\"assets/cityscapes_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/cityscapes_x_AB_8350.png\" width=\"30%\"\u003e \u003cimg src=\"assets/cityscapes_x_ABA_8350.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (segmentation -\u003e image -\u003e segmentation)\n\n\u003cimg src=\"assets/cityscapes_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/cityscapes_x_BA_8350.png\" width=\"30%\"\u003e \u003cimg src=\"assets/cityscapes_x_BAB_8350.png\" width=\"30%\"\u003e\n\n\n### 6. Map dataset\n\n**# iteration: 22200**:\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (image -\u003e segmentation -\u003e image)\n\n\u003cimg src=\"assets/maps_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/maps_x_AB_22200.png\" width=\"30%\"\u003e \u003cimg src=\"assets/maps_x_ABA_22200.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (segmentation -\u003e image -\u003e segmentation)\n\n\u003cimg src=\"assets/maps_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/maps_x_BA_22200.png\" width=\"30%\"\u003e \u003cimg src=\"assets/maps_x_BAB_22200.png\" width=\"30%\"\u003e\n\n\n### 7. Facades dataset\n\nGeneration and reconstruction on dense segmentation dataset looks weird which are not included in the paper.  \nI guess a naive choice of `mean square error` loss for reconstruction need some change on this dataset.\n\n**# iteration: 19450**:\n\n`x_B` -\u003e `G_BA(x_B)` -\u003e `G_AB(G_BA(x_B))` (image -\u003e segmentation -\u003e image)\n\n\u003cimg src=\"assets/facades_valid_x_A.png\" width=\"30%\"\u003e \u003cimg src=\"assets/facades_x_AB_19450.png\" width=\"30%\"\u003e \u003cimg src=\"assets/facades_x_ABA_19450.png\" width=\"30%\"\u003e\n\n`x_A` -\u003e `G_AB(x_A)` -\u003e `G_BA(G_AB(x_A))` (segmentation -\u003e image -\u003e segmentation)\n\n\u003cimg src=\"assets/facades_valid_x_B.png\" width=\"30%\"\u003e \u003cimg src=\"assets/facades_x_BA_19450.png\" width=\"30%\"\u003e \u003cimg src=\"assets/facades_x_BAB_19450.png\" width=\"30%\"\u003e\n\n\n## Related works\n\n- [DCGAN-tensorflow](https://github.com/carpedm20/DCGAN-tensorflow)\n- [BEGAN-tensorflow](https://github.com/carpedm20/BEGAN-tensorflow)\n- [simulated-unsupervised-tensorflow](https://github.com/carpedm20/simulated-unsupervised-tensorflow)\n\n\n\n## Author\n\nTaehoon Kim / [@carpedm20](http://carpedm20.github.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpedm20%2Fdiscogan-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarpedm20%2Fdiscogan-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpedm20%2Fdiscogan-pytorch/lists"}