In this assignment, I implemented and trained a Deep Convolutional Generative Adversarial Network (DCGAN) using PyTorch to generate realistic facial images based on the CelebA-HQ 256x256 dataset. The project covers the full deep learning pipeline—from dataset preprocessing to evaluating the generated images using the Fréchet Inception Distance (FID) metric.
- Installed libraries:
torch,torchvision,matplotlib - Mounted Google Drive to access/save datasets and models
- Loaded the CelebA-HQ 256x256 dataset from Google Drive
- Preprocessing:
- Resized and center-cropped images
- Converted images to tensors and normalized to
[-1, 1]
- Created a custom PyTorch Dataset and DataLoader with batch size 128
- Implemented Generator and Discriminator based on the DCGAN paper
- Generator:
- Used
ConvTranspose2dlayers for upsampling - Applied
BatchNorm2dandReLUactivations
- Used
- Discriminator:
- Used
Conv2dlayers for downsampling - Applied
LeakyReLUandBatchNorm2d
- Used
- Weight Initialization: Normal distribution
- Loss Function: Binary Cross Entropy (BCE)
- Optimizer: Adam (used for both Generator and Discriminator)
- Training Schedule:
- Initial training: 5 epochs
- Extended training: 150 epochs total
- Metrics tracked:
- Generator & Discriminator losses
- D(x): Discriminator output on real images
- D(G(z)): Discriminator output on fake images
- Used a fixed noise vector to generate consistent image samples
- Saved generated images in
generated_fakes_1000/
- Installed
pytorch-fidfor evaluation - Compared generated images with original CelebA dataset
- FID Score Achieved:
161.74
- Saved the trained Generator model to Google Drive
- Visualized generated outputs for quality check
- Confirmed sample diversity and dataset integrity
- DCGAN effectively learned to generate faces with CelebA-like features
- Generated faces displayed reasonable structure and diversity
- FID Score could be improved further through:
- Longer training
- Hyperparameter optimization
Fréchet Inception Distance (FID): 161.74
- Google Colab
- PyTorch
- TorchVision
- pytorch-fid
- Matplotlib
Priteesh Madhav Reddy Karra
Date: April 2025