{"id":27643315,"url":"https://github.com/deepbiolab/gans-research","last_synced_at":"2025-04-24T00:12:36.772Z","repository":{"id":288141070,"uuid":"966971759","full_name":"deepbiolab/gans-research","owner":"deepbiolab","description":"🎨 A step-by-step implementation of key GAN architectures from Vanilla GAN to StyleGAN3, focusing on training stability, conditional control, and high-quality image generation.","archived":false,"fork":false,"pushed_at":"2025-04-23T13:59:28.000Z","size":9871,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T00:12:32.096Z","etag":null,"topics":["deep-learning","gans","image-generation","progressive-gan","stylegan","wgan"],"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/deepbiolab.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-15T18:18:50.000Z","updated_at":"2025-04-23T13:59:31.000Z","dependencies_parsed_at":"2025-04-15T19:48:24.435Z","dependency_job_id":null,"html_url":"https://github.com/deepbiolab/gans-research","commit_stats":null,"previous_names":["deepbiolab/gans-research"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fgans-research","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fgans-research/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fgans-research/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepbiolab%2Fgans-research/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepbiolab","download_url":"https://codeload.github.com/deepbiolab/gans-research/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535105,"owners_count":21446508,"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":["deep-learning","gans","image-generation","progressive-gan","stylegan","wgan"],"created_at":"2025-04-24T00:12:36.145Z","updated_at":"2025-04-24T00:12:36.734Z","avatar_url":"https://github.com/deepbiolab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GANs Research Reproduction from Scratch\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./assets/cgan_training_animation.gif\" alt=\"CGAN Training Animation\"\u003e\n\u003c/div\u003e\n\n```mermaid\ngraph LR\n    subgraph Basic_Models[\"Basic Models (2014-2015)\"]\n        VanillaGAN[Vanilla GAN 2014] --\u003e DCGAN[DCGAN 2015]\n    end\n    \n    subgraph Training_Stability[\"Training Stability Path\"]\n        DCGAN --\u003e WGAN[WGAN 2017]\n        WGAN --\u003e WGAN_GP[WGAN-GP 2017]\n    end\n    \n    subgraph Control_Mechanisms[\"Control Mechanisms\"]\n        VanillaGAN --\u003e CGAN[Conditional GAN 2014]\n        note1[Explicit Control]\n    end\n    \n    subgraph Quality_Improvement[\"Quality Improvement Path\"]\n        DCGAN --\u003e ProgGAN[Progressive GAN 2017]\n        WGAN --\u003e StyleGAN1[StyleGAN 2018]\n        ProgGAN --\u003e StyleGAN1\n        WGAN_GP -.-\u003e StyleGAN1\n        StyleGAN1 --\u003e StyleGAN2[StyleGAN2 2019]\n        StyleGAN2 --\u003e StyleGAN3[StyleGAN3 2021]\n        note2[Implicit Style Control]\n    end\n    \n    %% Relationship Notes\n    Training_Stability -. \"Stability Focus\" .-\u003e Quality_Improvement\n    Control_Mechanisms -. \"Control Evolution\" .-\u003e Quality_Improvement\n    \n    %% Styling\n    classDef done fill:#A9B7C0,stroke:#555,stroke-width:2px;\n    classDef pending fill:#D7C4BB,stroke:#555,stroke-width:2px;\n    classDef current fill:#B8C4B8,stroke:#555,stroke-width:2px;\n    classDef note fill:#fff,stroke:#555,stroke-width:1px,stroke-dasharray: 5 5;\n    \n    %% Apply styles\n    class VanillaGAN done;\n    class DCGAN,WGAN,WGAN_GP,CGAN,ProgGAN,StyleGAN1,StyleGAN2,StyleGAN3 pending;\n    class note1,note2 note;\n    \n    %% Subgraph styling\n    style Basic_Models fill:#f5f5f5,stroke:#666,stroke-width:2px;\n    style Training_Stability fill:#e8f4f8,stroke:#666,stroke-width:2px;\n    style Control_Mechanisms fill:#f8f4e8,stroke:#666,stroke-width:2px;\n    style Quality_Improvement fill:#f0f8f0,stroke:#666,stroke-width:2px;\n\n```\n\nThis repository contains implementations of key Generative Adversarial Network (GAN) architectures, organized in an incremental learning approach.\n\n\n## Implementation Progress\n\n1. **Basic GANs**\n   - [x] **Vanilla GAN**: Original formulation with fully connected layers for both generator and discriminator networks.\n   - [x] **DCGAN**: Introduced convolutional architectures and established key architectural guidelines for stable GAN training.\n   \n2. **Training Stability Improvements**\n   - [x] **WGAN**: Improved training stability using Wasserstein distance.\n   - [x] **WGAN-GP**: Enhanced WGAN with gradient penalty.\n   \n3. **Conditional Control**\n   - [x] **Conditional GAN**: Added ability to control generation with explicit labels.\n   \n4. **High-Quality Generation**\n   - [x] **Progressive GAN**: Introduced progressive growing methodology for generating high-resolution images.\n   - [ ] **StyleGAN v1**: Combined progressive growing with style-based generation.\n   - [ ] **StyleGAN v2**: Improved architecture and removing progressive growing.\n   - [ ] **StyleGAN v3**: Added alias-free generation techniques.\n\n\n\n## Installation\n\n### Option 1: Install dependencies only\n```bash\npip install -r requirements.txt\n```\n\n### Option 2: Install as a package (recommended for development)\n```bash\n# If you have a previous installation, remove it first\npip uninstall gans-research\n\n# Install in editable mode\npip install -e .\n```\n\n\n\n## Usage\n\n### Training\nEach GAN implementation has its own training script in the `experiments` directory:\n\n```bash\n# Example: Train a basic GAN on MNIST\npython experiments/stage1_basic/train_vanilla_gan.py\n```\n\n### Evaluation\nEvaluation scripts are located in the `experiments` directory:\n\n```bash\n# Evaluate a trained model\npython experiments/evaluate.py --config configs/vanilla_gan.yaml\n\n# Evaluate specific metrics\npython experiments/evaluate.py --config configs/vanilla_gan.yaml --metrics quality\npython experiments/evaluate.py --config configs/vanilla_gan.yaml --metrics coverage\npython experiments/evaluate.py --config configs/vanilla_gan.yaml --metrics speed\n\n# Customize evaluation parameters\npython experiments/evaluate.py --config configs/vanilla_gan.yaml --num_samples 5000 --batch_size 32\n```\n\n**Configuration Example**\n\nEvaluation configuration is part of the model's config YAML file:\n\n```yaml\nevaluation:\n  batch_size: 64\n  num_samples: 10000\n```\n\n### Inference\n\n#### Unconditional Generation\n\nExample: generate images using a trained Vanilla GAN model on MINIST:\n\n```\npython experiments/inference.py --config configs/vanilla_gan.yaml\n```\n\n\n#### Conditional Generation\n\nExample: generate images using a trained Conditional GAN model on MINIST:\n\n- generate multiple images for each label:\n\n```python\npython experiments/inference.py --config configs/cgan.yaml --labels 0,1,2,3,4,5,6,7,8,9 --num_samples 5\n```\n\n- generate one image for each label:\n\n```\npython experiments/inference.py --config configs/cgan.yaml --labels 2,5\n```\n\n**Configuration Example**\n\nYAML config should include the following fields:\n\n```yaml\ninference:  # or dcgan, wgan, etc.\n  checkpoint_path: outputs/vanilla_gan/checkpoints/final_model.pth\n  num_samples: 16\nmodel:\n  name: vanilla_gan\nexperiment:\n  output_dir: outputs/vanilla_gan\n```\n\n\n## Project Structure\n\nThe project is organized as follows:\n\n```\ngans-research/\n├── configs/                 # Configuration files for each GAN variant\n├── data/                    # Dataset loading and processing utilities\n├── evaluation/              # Evaluation metrics and visualization tools\n│   ├── metrics/             # Implementation of evaluation metrics (FID, etc.)\n│   └── visualization/       # Visualization utilities for generated images\n├── experiments/             # Training and evaluation scripts\n│   └── stage1_basic/        # Training scripts for basic GAN models\n├── src/                     # Core source code\n│   ├── data/                # Dataset handling\n│   ├── losses/              # Loss functions for different GAN variants\n│   ├── metrics/             # Evaluation metrics (FID, precision-recall)\n│   ├── models/              # Model implementations\n│   │   ├── base/                # Base classes for generators and discriminators\n│   │   ├── vanilla_gan/         # Vanilla GAN implementation\n│   │   ├── dcgan/               # Deep Convolutional GAN implementation\n│   │   ├── cgan/                # Conditional GAN implementation\n│   │   ├── wgan/                # Wasserstein GAN implementation\n│   │   ├── wgan_gp/             # Wasserstein GAN with Gradient Penalty implementation\n│   │   ├── prog_gan/            # Progressive GAN implementation\n│   │   ├── stylegan1/           # StyleGAN v1 implementation\n│   │   ├── stylegan2/           # StyleGAN v2 implementation\n│   │   └── stylegan3/           # StyleGAN v3 implementation\n│   ├── training/            # Training utilities\n│   └── utils/               # Helper utilities\n└── pyproject.toml           # Package configuration\n```\n\n\n## References\n\n- [Generative Adversarial Networks (2014)](https://arxiv.org/abs/1406.2661)\n- [DCGAN (2015)](https://arxiv.org/abs/1511.06434)\n- [Wasserstein GAN (2017)](https://arxiv.org/abs/1701.07875)\n- [WGAN-GP (2017)](https://arxiv.org/abs/1704.00028)\n- [Conditional GANs (2014)](https://arxiv.org/abs/1411.1784)\n- [Progressive GAN (2017)](https://arxiv.org/abs/1710.10196)\n- [StyleGAN (2018)](https://arxiv.org/abs/1812.04948)\n- [StyleGAN2 (2019)](https://arxiv.org/abs/1912.04958)\n- [StyleGAN3 (2021)](https://arxiv.org/abs/2106.12423)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepbiolab%2Fgans-research","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepbiolab%2Fgans-research","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepbiolab%2Fgans-research/lists"}