Skip to content

LGMOak/PyTorch-DCGAN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DCGAN on OASIS Dataset

This repository contains an implementation of a Deep Convolutional Generative Adversarial Network (DCGAN) trained on the OASIS dataset. The model is designed to generate synthetic brain scan images based on the dataset provided.

Theory & Background

Generative Adversarial Networks (GANs) consist of two neural networks, a generator and a discriminator, that are trained simultaneously through adversarial learning:

  • The generator (G) takes in a random noise vector and generates fake images that resemble the real dataset.
  • The discriminator (D) evaluates images and tries to distinguish between real and fake images.
  • The generator is optimized to fool the discriminator, while the discriminator is optimized to correctly classify images.

DCGANs extend this concept using convolutional layers to improve the quality of generated images.

Model Architecture

Generator:

  • Uses transposed convolutional layers to upsample random noise into an image.
  • Includes batch normalization and ReLU activation for stable training.
  • Outputs images using a Tanh activation function.

Discriminator:

  • Uses convolutional layers with LeakyReLU activation to classify images as real or fake.
  • Includes batch normalization for improved gradient flow.
  • Outputs a probability score using a Sigmoid activation function.

Installation & Setup

Prerequisites:

  • Python 3.12+
  • PyTorch
  • Torchvision
  • Matplotlib
  • NumPy

Training

Run the training script:

python torch_dcgan.py

img.png

Results

After training, the model will generate synthetic images. The results are saved as:

  • brains.jpg: Comparison of real vs. generated images.
  • loss.jpg: Training loss curves for generator and discriminator.

img.png img.png

References

License

MIT License. Feel free to modify and use the code!

About

Pattern Recognition & analysis project. Implement DCGAN model to OASIS brain dataset

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages