{"id":22615533,"url":"https://github.com/sovit-123/pytorch-dcgan-framework","last_synced_at":"2026-04-18T19:32:49.682Z","repository":{"id":45996553,"uuid":"419699017","full_name":"sovit-123/pytorch-dcgan-framework","owner":"sovit-123","description":"A small PyTorch framework to try out and train DCGAN on different datasets.","archived":false,"fork":false,"pushed_at":"2021-11-22T01:12:54.000Z","size":189432,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-10T07:39:25.996Z","etag":null,"topics":["convolutional-neural-networks","deep-learning","generative-adversarial-network","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sovit-123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-21T11:40:59.000Z","updated_at":"2021-11-22T01:12:56.000Z","dependencies_parsed_at":"2022-08-25T09:21:15.092Z","dependency_job_id":null,"html_url":"https://github.com/sovit-123/pytorch-dcgan-framework","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sovit-123/pytorch-dcgan-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-dcgan-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-dcgan-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-dcgan-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-dcgan-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sovit-123","download_url":"https://codeload.github.com/sovit-123/pytorch-dcgan-framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-dcgan-framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["convolutional-neural-networks","deep-learning","generative-adversarial-network","pytorch"],"created_at":"2024-12-08T19:08:16.403Z","updated_at":"2026-04-18T19:32:49.657Z","avatar_url":"https://github.com/sovit-123.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytorch-dcgan-framework\n\n\n\n## DCGAN Training on Different Datasets using PyTorch\n\n* Currently, the generator generates 64x64 resolution images.\n\n\n\n## Current Features/Supports\n* You can resume training from any saved model.\n* TensorBoard logging of loss graphs.\n* Resuming training will also create new TensorBoard run where the old plots will be generated first, and then continue.\n* The generator model is from the paper [Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks](https://arxiv.org/abs/1511.06434v2). I tried to replicate it as well as I could.\n* The discriminator network follows all the rules from the [official paper](https://arxiv.org/abs/1511.06434v2) although there can be a few flexibilties to the size and depth of the network. Still, the core rules are all from the paper.\n* Option to save GIFs of generated images after training ends (See `config.py`). **If trained for high number of epochs (\u003e500), it will require a lot of RAM as all the saved images from the 500 epochs will be loaded directly to memory to create teh GIF**. Therefore provided option to turn it off. \n\n\n\n\n## Current Datasets Supported\n\n* MNIST\n* Fashion MNIST\n* CIFAR10\n* CELEBA \n* Abstract Art Gallery  \n\n\n\n## Dataset Directory\n\nThe datasets are one folder back from the working project directory. Relative path from current project directory:\n\n* `../input/data`\n\nFollowing is the structure showing how all the datasets are arranged:\n\n```\ninput\n|───data\n    ├───abstract_art_gallery\n    │   ├───Abstract_gallery\n    │   │   └───Abstract_gallery\n    │   └───Abstract_gallery_2\n    │       └───Abstract_gallery_2\n    ├───celeba\n    │   └───img_align_celeba\n    ├───cifar-10-batches-py\n    ├───FashionMNIST\n    │   └───raw\n    ├───MNIST\n    │   └───raw\n```\n\n* MNIST, Fashion MNIST, and CIFAR10 data are directly downloaded from PyTorch `torchvision` module.\n* To train on CelebA and Abstract Art Gallery dataset, you need to download them and arrange them proper directory first.\n* [Download CelebA dataset](https://drive.google.com/drive/folders/0B7EVK8r0v71pTUZsaXdaSnZBZzg?resourcekey=0-rJlzl934LzC-Xp28GeIBzQ).\n  * Download the `img_align_celeba.zip` file.\n* [Download Abstract Art Gallery dataset](https://www.kaggle.com/bryanb/abstract-art-gallery).\n\n\n\n## Project Directory\n\n```\n.\n├── config.py\n├── datasets.py\n├── models.py\n├── outputs_ABSTRACT_ART\n├── outputs_CELEBA\n├── outputs_CIFAR10\n├── outputs_FashionMNIST\n├── outputs_MNIST\n├── README.md\n├── runs\n├── train.py\n└── utils.py\n```\n\n\n\n## Training Configurations\n\n* The training configuration for MNIST and Fashion MNIST datasets are the same.\n\n  * Just change the `DATASET` to `'MNIST'` or `'FashionMNIST'`. `N_CHANNELS` should be `1` for grayscale images.\n\n    ```python\n    import torch\n    \n    BATCH_SIZE = 128\n    EPOCHS  = 50\n    EPOCH_START = 0\n    NUM_WORKERS = 4\n    MULT_FACTOR = 1\n    IMAGE_SIZE = 64*MULT_FACTOR\n    # image channels\n    N_CHANNELS = 1\n    \n    # SAMPLE_SIZE is the total number of images in row x column form...\n    # if SAMPLE_SIZE = 64, then 8x8 image grids will be saved to disk...\n    # if SAMPLE_SIZE = 128, then 16x8 image grids will be saved to disk...\n    SAMPLE_SIZE = 64\n    # latent vector size\n    NZ = 100\n    # number of steps to apply to the discriminator\n    K = 1\n    DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n    # one of 'MNIST', 'FashionMNIST', 'CIFAR10', 'CELEBA', ...\n    # ... 'ABSTRACT_ART'\n    DATASET = 'MNIST'\n    \n    # for printing metrics\n    PRINT_EVERY = 100\n    \n    # for optimizer\n    BETA1 = 0.5\n    BETA2 = 0.999\n    LEARNING_RATE = 0.0002\n    \n    # Epcoh nterval at which to save the Generator Model.\n    MODEL_SAVE_INTERVAL = 25\n    \n    # Provide path to a trained model to resume training, else keep `None`.\n    # GEN_MODEL_PATH = 'outputs_MNIST/generator_final.pth'\n    # DISC_MODEL_PATH = 'outputs_MNIST/discriminator_final.pth'\n    GEN_MODEL_PATH = None\n    DISC_MODEL_PATH = None\n    \n    # Whether to create GIF from all the generated images at the end or not,\n    # might need a considerable amoung of RAM as all the generated images will\n    # be loaded to at once. Give values as either `True` or `False`.\n    CREATE_GIF = False\n    ```\n\n* For CIFAR10 and other colored images datasets, change the `N_CHANNELS` to 3, RGB images.\n\n  * ```python\n    import torch\n    \n    BATCH_SIZE = 128\n    EPOCHS  = 50\n    EPOCH_START = 0\n    NUM_WORKERS = 4\n    MULT_FACTOR = 1\n    IMAGE_SIZE = 64*MULT_FACTOR\n    # image channels\n    N_CHANNELS = 3\n    \n    # SAMPLE_SIZE is the total number of images in row x column form...\n    # if SAMPLE_SIZE = 64, then 8x8 image grids will be saved to disk...\n    # if SAMPLE_SIZE = 128, then 16x8 image grids will be saved to disk...\n    SAMPLE_SIZE = 64\n    # latent vector size\n    NZ = 100\n    # number of steps to apply to the discriminator\n    K = 1\n    DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n    # one of 'MNIST', 'FashionMNIST', 'CIFAR10', 'CELEBA', ...\n    # ... 'ABSTRACT_ART'\n    DATASET = 'CELEBA'\n    \n    # for printing metrics\n    PRINT_EVERY = 100\n    \n    # for optimizer\n    BETA1 = 0.5\n    BETA2 = 0.999\n    LEARNING_RATE = 0.0002\n    \n    # Epcoh nterval at which to save the Generator Model.\n    MODEL_SAVE_INTERVAL = 25\n    \n    # Provide path to a trained model to resume training, else keep `None`.\n    # GEN_MODEL_PATH = 'outputs_MNIST/generator_final.pth'\n    # DISC_MODEL_PATH = 'outputs_MNIST/discriminator_final.pth'\n    GEN_MODEL_PATH = None\n    DISC_MODEL_PATH = None\n    \n    # Whether to create GIF from all the generated images at the end or not,\n    # might need a considerable amoung of RAM as all the generated images will\n    # be loaded to at once. Give values as either `True` or `False`.\n    CREATE_GIF = False\n    ```\n    \n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fpytorch-dcgan-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsovit-123%2Fpytorch-dcgan-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fpytorch-dcgan-framework/lists"}