Skip to content

upender8096/GAN-model-case-study

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generative Modelling Case Study — GAN code

PyTorch implementation for the assignment: Part 1 (GANs from scratch on 2D data) and Part 2 (three applied GANs — medicine, cybersecurity, creative AI), each with its extension task.

Environment

python -m venv venv && source venv/bin/activate
pip install -r requirements.txt

Tested with Python 3.10, torch 2.6 (CPU). No GPU required (everything was trained on CPU); a GPU will simply be faster.

Project layout

code/        all scripts (see below)
data/        datasets (downloaded automatically / see links in scripts)
figures/     all figures used in the report
outputs/     loss CSVs, FID values, cached features
checkpoints/ saved generator/discriminator weights (resumable training)
report/      report skeleton & writing notes

How to reproduce each part

Run from inside code/.

Part 1 — 2D GANs (sine, mixture of Gaussians, modified architecture)

python part1_gan_2d.py

Part 2.1 — PneumoniaMNIST DCGAN (+ conditional GAN extension)

python part2_1_pneumonia_dcgan.py --explore        # data figures
python part2_1_pneumonia_dcgan.py --epochs 40      # train (resumable, run in chunks if needed)
python compute_fid.py --tag p21 --real --n 600     # FID, phase 1
python compute_fid.py --tag p21 --fake --n 600     # FID, phase 2
python compute_fid.py --tag p21 --score            # FID result
python part2_1b_pneumonia_cgan.py --epochs 28      # conditional GAN extension
python part2_1b_pneumonia_cgan.py --grid           # per-class on-demand grid

Part 2.2 — CIC-IDS-2017 tabular GAN (+ all-days extension)

python part2_2_cicids_gan.py --preprocess
python part2_2_cicids_gan.py --epochs 218
python part2_2_cicids_gan.py --evaluate            # PCA + t-SNE + metrics
python part2_2b_cicids_alldays.py --preprocess     # extension: DoS+DDoS+PortScan
python part2_2b_cicids_alldays.py --epochs 138
python part2_2b_cicids_alldays.py --evaluate

Part 2.3 — QuickDraw broccoli DCGAN (+ second-category extension)

python part2_3_broccoli_dcgan.py --explore
python part2_3_broccoli_dcgan.py --epochs 27
python part2_3_broccoli_dcgan.py --final
python compute_fid.py --tag p23 --real --n 600
python compute_fid.py --tag p23 --fake --n 600
python compute_fid.py --tag p23 --score
python part2_3b_other_category.py --category cat --explore
python part2_3b_other_category.py --category cat --epochs 18
python part2_3b_other_category.py --category cat --final

Notes

  • Training scripts checkpoint after every epoch and resume automatically, so long runs can be done in short chunks (--epochs N continues from the last checkpoint).
  • gan_utils.py holds shared helpers: DCGAN weight init, image-grid saving, the InceptionV3-based FID, and checkpoint load/save.
  • Datasets: PneumoniaMNIST (MedMNIST/Zenodo), CIC-IDS-2017 (Wednesday + Friday CSVs), QuickDraw broccoli/cat .npy bitmaps. Download URLs are in the scripts / were fetched into data/.

Key results

Task Metric
2.1 X-ray DCGAN FID 66.4
2.2 traffic GAN per-feature mean gap 0.084 / std gap 0.370
2.3 broccoli DCGAN FID 91.7
2.3 ext. cat DCGAN FID 160.7

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors