mnoorchenar/VAE-Playground
<div align="center">
<h1>π§ VAE Β· MNIST Playground</h1> <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&size=22&duration=3000&pause=1000&color=7C3AED¢er=true&vCenter=true&width=700&lines=Train+a+Variational+Autoencoder+in+your+browser;Explore+the+2-D+latent+manifold+visually;Generate+new+digits+by+sampling+latent+space;Deep+learning+made+interactive+%26+accessible" alt="Typing SVG"/>
<br/>
     
<br/>
π§ VAE Β· MNIST Playground β An interactive web application for training, visualising, and experimenting with Variational Autoencoders on the MNIST handwritten digit dataset, directly in your browser with zero setup.
<br/>
</div>
Table of Contents
- Features
- Architecture
- Getting Started
- Docker Deployment
- Dashboard Modules
- ML Models
- Project Structure
- Author
- Contributing
- Disclaimer
- License
β¨ Features
<table> <tr> <td>β‘ <b>Live Training Dashboard</b></td> <td>Configure hyperparameters (epochs, batch size, learning rate, hidden & latent dims) and launch training with a real-time animated progress bar and loss curve</td> </tr> <tr> <td>π <b>Latent Space Visualisation</b></td> <td>Scatter-plot the 2-D encoded representations of 10 000 MNIST samples, colour-coded by digit class, revealing the learned manifold structure</td> </tr> <tr> <td>π <b>Reconstruction Comparison</b></td> <td>Side-by-side view of original MNIST digits and their VAE reconstructions, updating on every click with a freshly sampled random batch</td> </tr> <tr> <td>β¨ <b>Interactive Generation</b></td> <td>Two latent-space sliders let you navigate the learned manifold in real time and decode novel digit-like images on the fly; a full 15Γ15 grid view is also available</td> </tr> <tr> <td>π <b>Secure by Design</b></td> <td>Role-based access, audit logs, encrypted data pipelines</td> </tr> <tr> <td>π³ <b>Containerized Deployment</b></td> <td>Docker-first architecture, cloud-ready and scalable</td> </tr> </table>
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β vae-mnist-playground β
β β
β ββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β
β β MNIST βββββΆβ VAE (PyTorch) βββββΆβ Flask API β β
β β Dataset β β Encoder/Decoderβ β Backend β β
β ββββββββββββββ βββββββββββββββββββ βββββββββ¬ββββββββ β
β β β
β ββββββββββΌβββββββββ β
β β Vanilla JS β β
β β + Matplotlib β β
β β Dashboard β β
β βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββVAE Data Flow:
Input (784-D)
β
βΌ Encoder FC (ReLU)
β
ββββΆ ΞΌ head βββ
ββββΆ ΟΒ² head ββ€ z = ΞΌ + ΟΒ·Ξ΅ (reparameterization trick)
β
βΌ
Latent z (2-D / n-D)
β
βΌ Decoder FC (ReLU β Sigmoid)
β
Output (784-D)π Getting Started
Prerequisites
- Python 3.10+
- Docker & Docker Compose
- Git
Local Installation
# 1. Clone the repository
git clone https://github.com/mnoorchenar/vae-mnist-playground.git
cd vae-mnist-playground
# 2. Create a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment variables
cp .env.example .env
# Edit .env with your settings
# 5. Run the application
python app.pyOpen your browser at http://localhost:7860 π
π³ Docker Deployment
# Build and run with Docker Compose
docker compose up --build
# Or pull and run the pre-built image
docker pull mnoorchenar/vae-mnist-playground
docker run -p 7860:7860 mnoorchenar/vae-mnist-playgroundπ Dashboard Modules
π§ ML Models
# Core Models Used in vae-mnist-playground
models = {
"architecture": "Variational Autoencoder (VAE)",
"encoder": "FC 784 β hidden_dim β (ΞΌ, log ΟΒ²)",
"decoder": "FC latent_dim β hidden_dim β 784",
"loss_function": "ELBO = BCE Reconstruction + KL Divergence",
"reparameterization": "z = ΞΌ + Ο Β· Ξ΅, Ξ΅ ~ N(0, I)"
}Configurable hyperparameters at runtime:
π Project Structure
vae-mnist-playground/
β
βββ π app.py # Flask app, VAE model, all routes & HTML template
β
βββ π data/ # Auto-downloaded MNIST dataset cache
β βββ MNIST/
β
βββ π Dockerfile # Container definition (port 7860)
βββ π docker-compose.yml # Multi-service orchestration
βββ π requirements.txt # Python dependencies
βββ π .env.example # Environment variable template
βββ π README.md # This fileNote: The project uses a single-file architecture (app.py) for simplicity and Hugging Face Spaces compatibility. The HTML template, VAE class, training loop, and all Flask routes are co-located intentionally.π¨βπ» Author
<div align="center">
<table> <tr> <td align="center" width="100%">
<img src="https://avatars.githubusercontent.com/mnoorchenar" width="120" style="border-radius:50%; border: 3px solid #4f46e5;" alt="Mohammad Noorchenarboo"/>
<h3>Mohammad Noorchenarboo</h3>
<code>Data Scientist</code> | <code>AI Researcher</code> | <code>Biostatistician</code>
π Ontario, Canada π§ mohammadnoorchenarboo@gmail.com
ββββββββββββββββββββββββββββββββββββββ
    
</td> </tr> </table>
</div>
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Disclaimer
<span style="color:red">This project is developed strictly for educational and research purposes and does not constitute professional advice of any kind. All datasets used are either synthetically generated or publicly available (MNIST is a public domain dataset) β no real user data is stored. This software is provided "as is" without warranty of any kind; use at your own risk.</span>
π License
Distributed under the MIT License. See `LICENSE` for more information.
<div align="center">
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:7c3aed,100:06b6d4&height=120§ion=footer&text=Made%20with%20%E2%9D%A4%EF%B8%8F%20by%20Mohammad%20Noorchenarboo&fontColor=ffffff&fontSize=18&fontAlignY=80" width="100%"/>
 
<sub>The name "vae-mnist-playground" is used purely for academic and research purposes. Any similarity to existing product names or trademarks is entirely coincidental. This project has no affiliation with any commercial entity.</sub>
</div>
