Toy Pixel-Art DDPM
An educational, from-scratch text-to-image diffusion model (DDPM/DDIM) that generates native 32×32 RGBA pixel-art sprites with transparency.
The image U-Net (24.5M parameters) is built and trained from random weights directly in pixel space using plain PyTorch—no Stable Diffusion checkpoint, VAE, LoRA, or diffusers pipeline. The only pretrained component is a frozen CLIP ViT-L/14 text encoder.
Sample Output
Prompt: "pixel art icon of book" · Sampler: ddim (eta = 0.0) · Steps: 50 · CFG: 4.0 · Seed: 123
Denoising & Alpha Mask Progression:
Try It (Inference)
Option 1: Google Colab (Recommended)
Run interactive inference and inspect the step-by-step denoising trajectory (composite RGBA, RGB, and alpha mask) directly in your browser:
👉 Open Inference Notebook in Colab
Option 2: Run Locally
hf download Tobyz11/toy-pixelart-ddpm --local-dir toy-pixelart
cd toy-pixelart
pip install -r requirements.txt
python generate.py "pixel art icon of a purple dragon" --output sprite.png
Install huggingface_hub first if the hf command is missing. CPU works fine; CLIP weights download on the first run. Output is an unthresholded 32×32 RGBA PNG.
Source Code & Companion Notes
- GitHub Repository: tobp03/pixelart-toy-model
- Companion Notes: Understanding Diffusion Model for Pixel Art Image Generator
Model & Training Summary
- Image U-Net (
TextUNet): 24.5M trainable parameters, 4-channel RGBA input/output ([B, 4, 32, 32]), resolution stages32×32 → 16×16 → 8×8 → 4×4. - Text Encoder: Frozen
openai/clip-vit-large-patch14(max_text_length = 48), projected to 256-dim cross-attention at8×8and4×4. - Diffusion Schedule: 1,000 timesteps, cosine schedule (
cosine_s = 0.008), $\epsilon$-prediction MSE loss. - Training Data:
azyg0s/pixelart-172k(50,000 deduplicated training sprites + 512 validation sprites). - Published Weights: best validated EMA from run
rgba-clip-l14-full-v1(step39,100, best validation noise MSE0.02018). - Full Configuration: See
config.json.
Limitations
- MSE does not enforce pixel-art rules: No explicit objective for crisp 1-pixel outlines or limited color palettes.
- Alpha channel artifacts: Alpha is diffused alongside RGB, which can produce semi-transparent edges.
- Synthetic dataset noise: Training captions come from synthetic prompts and may not always align with visual details.
- Downloads last month
- 43