Projects Feb 2025 Solo
Genomaly
Generative AI for anomaly detection: GAN vs VAE comparison on MNIST, then VAE-based defect detection applied to pharmaceutical capsule quality control.
- Python
- PyTorch
- GAN
- VAE
Two phases: a structured GAN vs VAE comparison on benchmark data, then an industrial application of VAE reconstruction-error anomaly detection to pharmaceutical manufacturing.
GAN vs VAE
Both models were trained on MNIST Digits and MNIST Fashion (60K training / 10K test samples per dataset) under identical conditions.
| GAN | VAE | |
|---|---|---|
| Image quality | Sharper | Blurrier; bottleneck discards high-frequency detail |
| Training stability | Harder; minimax game collapses without careful tuning of LR, batch size, and discriminator dropout | Easier; explicit ELBO objective |
| Latent space | Unstructured; no reliable semantic navigation | Probabilistic via KL divergence; smooth geometry supports interpolation and class sampling |
Industrial anomaly detection: pharmaceutical capsules
The second phase applies VAE to a real inspection problem: detecting defective tablets before they reach patients. A single defective capsule in a production batch is both a regulatory risk and a safety risk.
Dataset: the Capsule subset of MVTecAD, an industrial inspection benchmark. 219 normal capsule images for training; a held-out test set includes both normal and anomalous (broken, cracked, discolored) capsules. Source images are 1000x1000; resized to 64x64 for training.
Approach: the VAE is trained exclusively on normal capsules. At inference, reconstruction error is the anomaly score. A defective capsule reconstructs poorly because the model has no prior for anomalous structure; the error exceeds the threshold and triggers a flag.
19/23
Anomalies detected
82% on test set
128
Latent dimension
The trained model also demonstrated reconstruction-based correction: when given a broken capsule image, the decoder reconstructed it with the break visually filled in, drawing from the learned distribution of intact capsule structure. The anomaly is visible by comparing the input against the reconstruction.