bilal3406/DDPM-Face-Generator
0
DDPM Face Generator & Reconstructor (From Scratch)
This Space hosts a Denoising Diffusion Probabilistic Model (DDPM) built entirely from scratch using base PyTorch, without relying on abstracted pipelines like HuggingFace Diffusers. It was trained on a subset of the FFHQ (Flickr-Faces-HQ) dataset.
๐๏ธ Architecture Details
- Framework: Pure PyTorch.
- Backbone: Custom U-Net with a channel progression of 64 โ 128 โ 256.
- Time Awareness: Sinusoidal Positional Embeddings injected into every Residual Block.
- Global Structure: A Self-Attention block deployed at the $32 \times 32$ bottleneck to help the model learn spatial symmetry.
- Forward Process: Linear variance schedule over $T = 300$ timesteps.
โ ๏ธ Training & Hardware Constraints
This model was engineered to train within the strict hardware limits of a Kaggle Notebook (Dual T4 GPUs with 16GB VRAM, and a 30GB System RAM limit).
- To prevent VRAM fragmentation, it utilizes Automatic Mixed Precision (AMP) and aggressive garbage collection.
- To prevent System RAM leaks, the PyTorch DataLoader is restricted to the main thread.
- Note on Visual Quality: Due to compute time limitations, these weights were trained for ~20 epochs. Therefore, the model has successfully learned local distributions (skin tones, hair textures) but lacks the compute time required to fully lock in global facial symmetry (resulting in the current abstract, "Picasso-style" outputs).
๐ How to Use This Space
This interactive Gradio application features two main tabs:
- Generate Face: Performs unconditional generation. The model starts with a tensor of pure Gaussian noise and iteratively removes the noise over 300 steps to hallucinate a novel face. No input required.
- Reconstruct & Evaluate: Upload a target image. The script will apply maximum noise to destroy the image, and then force the U-Net to walk backward to reconstruct it. The app calculates PSNR and SSIM scores to quantitatively evaluate the spatial accuracy of the reconstruction.
๐ฅ Authors
Engineered and trained by:
- Muhammad Bilal Ahmad Ali Hamza FAST National University of Computer and Emerging Sciences (FAST NUCES)
