VR

GAN for MNIST Synthesis

Generative Adversarial Network trained on MNIST and deployed as a live demo on HuggingFace Spaces.

PythonPyTorchGradioHuggingFace SpacesDocker

What This Is

A GAN that generates handwritten digits, trained on MNIST and deployed as a live interactive demo on HuggingFace Spaces. Training the model was the straightforward part. Building the pipeline around it — Gradio app, Docker container, CI/CD to HuggingFace — was where most of the work went.

How It Works

  • Generator (1.49M params) and Discriminator (1.46M params) trained on MNIST with LeakyReLU and Batch Normalization for stable training
  • Gradio web app with structured logging, type hints, and input validation
  • Automatic CUDA, MPS, or CPU selection, deterministic seeding, and input validation
  • Error images for failed requests and a headless Matplotlib backend for server use
  • Deployed to HuggingFace Spaces with CI/CD integration

Results

  • Live demo running on HuggingFace Spaces where anyone can generate digits
  • Containerized with Docker for portable deployment
  • Trained for 200 epochs, reaching about 0.981 generator loss and 1.213 discriminator loss
  • Exported weights of about 17 MB, with the training notebook and setup instructions in the repository