{"id":16359326,"url":"https://github.com/gaborvecsei/sle-gan","last_synced_at":"2025-03-21T00:31:41.188Z","repository":{"id":50782911,"uuid":"312077414","full_name":"gaborvecsei/SLE-GAN","owner":"gaborvecsei","description":"Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis","archived":false,"fork":false,"pushed_at":"2021-05-30T16:15:49.000Z","size":11960,"stargazers_count":70,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T19:21:21.387Z","etag":null,"topics":["few-shot-image-generation","gan","image-synthesis","lighweight-gan","tensorflow","tensorflow2"],"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/gaborvecsei.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-11T20:05:45.000Z","updated_at":"2024-11-10T12:58:13.000Z","dependencies_parsed_at":"2022-08-24T11:10:47.851Z","dependency_job_id":null,"html_url":"https://github.com/gaborvecsei/SLE-GAN","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborvecsei%2FSLE-GAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborvecsei%2FSLE-GAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborvecsei%2FSLE-GAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaborvecsei%2FSLE-GAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaborvecsei","download_url":"https://codeload.github.com/gaborvecsei/SLE-GAN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717391,"owners_count":20498283,"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":["few-shot-image-generation","gan","image-synthesis","lighweight-gan","tensorflow","tensorflow2"],"created_at":"2024-10-11T02:08:05.875Z","updated_at":"2025-03-21T00:31:39.820Z","avatar_url":"https://github.com/gaborvecsei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis\n\n*Unofficial implementation*, with understandability in mind (verbose implementation)\n\n\u003e Why the name *SLE-GAN*? Because the paper introduces a new block in the Generator network called *Skip-Layer Excitation (SLE)*\n\n- [Paper](https://openreview.net/forum?id=1Fqg133qRaI)\n\n\u003cimg src=\"art/flower_interpolation_512.png\" width=\"400\"\u003e\u003c/a\u003e \u003cimg src=\"art/generated_flowers_512.png\" width=\"400\"\u003e\u003c/a\u003e\n\n\u003e *512x512 generated images (randomly selected) trained for 9 hours with batch size of 8 on [Oxford 17 flowers dataset](https://www.robots.ox.ac.uk/~vgg/data/flowers/17/index.html)\nwhich contains only 1360 images*\n\nThe implementation tries to replicate the results from the paper based only on the publication.\n\nWhat is not discussed in the paper (e.g. filter sizes, training scheduling, hyper parameters), is chosen based on some\nexperiments and previous knowledge.\n\n## Usage\n\nYou can easily use the separate parts of the code. The `Generator` and `Discriminator` are Tensorflow Keras models (`tf.keras.models.Model`)\n\nFor example if you'd like to generate new images:\n\n```python\nimport sle_gan\n\nG = sle_gan.Generator(output_resolution=512)\nG.load_weights(\"generator_weights.h5\")\n\ninput_noise = sle_gan.create_input_noise(batch_size=1)\ngenerated_images = G(input_noise)\ngenerated_images = sle_gan.postprocess_images(generated_images, tf.uint8).numpy()\n```\n\n## Train\n\n```\n$ python train.py --help\n\nusage: train.py [-h] [--name NAME] [--override] --data-folder DATA_FOLDER\n                [--resolution RESOLUTION]\n                [--generator-weights GENERATOR_WEIGHTS]\n                [--discriminator-weights DISCRIMINATOR_WEIGHTS]\n                [--batch-size BATCH_SIZE] [--epochs EPOCHS]\n                [--G-learning-rate G_LEARNING_RATE]\n                [--D-learning-rate D_LEARNING_RATE] [--diff-augment] [--fid]\n                [--fid-frequency FID_FREQUENCY]\n                [--fid-number-of-images FID_NUMBER_OF_IMAGES]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --name NAME           Name of the experiment\n  --override            Removes previous experiment with same name\n  --data-folder DATA_FOLDER\n                        Folder with the images\n  --resolution RESOLUTION\n                        Either 256, 512 or 1024. Default is 512.\n  --generator-weights GENERATOR_WEIGHTS\n  --discriminator-weights DISCRIMINATOR_WEIGHTS\n  --batch-size BATCH_SIZE\n  --epochs EPOCHS\n  --G-learning-rate G_LEARNING_RATE\n                        Learning rate for the Generator\n  --D-learning-rate D_LEARNING_RATE\n                        Learning rate for the Discriminator\n  --diff-augment        Apply diff augmentation\n  --fid                 If this is used, FID will be evaluated\n  --fid-frequency FID_FREQUENCY\n                        FID will be evaluated at this frequency (epochs)\n  --fid-number-of-images FID_NUMBER_OF_IMAGES\n                        This many images will be used for the FID calculation\n```\n\nFID score calculation can be enabled with the `--fid` flag. Just pay attention that as the caluclation uses\nthe Inception model, you need some extra GPU memory.\n\nExample train command:\n\n```\n$ python train.py --name experiment_1 --resolution 512 --batch-size 8 --diff-augment --fid --fid-number-of-images 256\n```\n\n## Differences from the paper\n\n- Instead of random cropping to get `I_{part}` now only center cropping is implemented\n- Optionally you can use [Differentiable Augmentations](https://arxiv.org/abs/2006.10738) (`--diff-augment`)\n\n### Not mentioned in the paper\n\nIn these cases I took the freedom and defined these myself based on previous experience\n\n- Number of filters in the Generator and Discriminator\n- How they change the architecture for resolutions `256`, `1024` (or any other resolution)\n- Training schedule, or any hyperparameter connected to the training\n\n## Citations\n\n```bibtex\n@inproceedings{\n    anonymous2021towards,\n    title={Towards Faster and Stabilized {\\{}GAN{\\}} Training for High-fidelity Few-shot Image Synthesis},\n    author={Anonymous},\n    booktitle={Submitted to International Conference on Learning Representations},\n    year={2021},\n    url={https://openreview.net/forum?id=1Fqg133qRaI},\n    note={under review}\n}\n```\n\n```bibtex\n@misc{\n      zhao2020differentiable,\n      title={Differentiable Augmentation for Data-Efficient GAN Training}, \n      author={Shengyu Zhao and Zhijian Liu and Ji Lin and Jun-Yan Zhu and Song Han},\n      year={2020},\n      eprint={2006.10738},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaborvecsei%2Fsle-gan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaborvecsei%2Fsle-gan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaborvecsei%2Fsle-gan/lists"}