Views
No views yet
| Attribute | Value |
|---|---|
| Architecture | SimpleUNet with ResNet blocks + Attention |
| Parameters | 16,808,835 |
| Dataset | CIFAR-10 (50,000 training images) |
| Image Size | 32×32 RGB |
| Training Steps | 7,820 (20 epochs × 391 batches) |
| Training Time | 14.54 minutes |
| Hardware | NVIDIA RTX 3060 (0.43GB VRAM used) |
| Framework | PyTorch 2.0+ |
pip install torch torchvision matplotlib tqdm pillow numpy1import torch
2import matplotlib.pyplot as plt
3
4# Load model
5checkpoint = torch.load('complete_diffusion_model.pth')
6model = SimpleUNet(**checkpoint['model_config'])
7model.load_state_dict(checkpoint['model_state_dict'])
8model.eval()
9
10# Initialize scheduler
11scheduler = DDPMScheduler(**checkpoint['diffusion_config'])
12
13# Generate images
14@torch.no_grad()
15def generate_images(model, scheduler, num_images=4):
16 device = next(model.parameters()).device
17 images = torch.randn(num_images, 3, 32, 32).to(device)
18
19 for t in range(999, -1, -20): # 50 denoising steps
20 timestep = torch.full((num_images,), t, device=device)
21 noise_pred = model(images, timestep)
22
23 # Simplified DDPM step
24 alpha_t = scheduler.alpha_cumprod[t]
25 alpha_prev = scheduler.alpha_cumprod[t-20] if t >= 20 else 1.0
26
27 pred_x0 = (images - torch.sqrt(1-alpha_t) * noise_pred) / torch.sqrt(alpha_t)
28 images = torch.sqrt(alpha_prev) * pred_x0 + torch.sqrt(1-alpha_prev) * noise_pred
29
30 return images
31
32# Generate and display
33generated = generate_images(model, scheduler)| File | Description | Size |
|---|---|---|
complete_diffusion_model.pth | Full model with config and weights | ~64MB |
diffusion_model_final.pth | Training checkpoint (epoch 20) | ~64MB |
model_info.json | Training metadata and hyperparameters | <1KB |
inference_example.py | Complete inference script with model classes | ~5KB |
SimpleUNet(
time_embedding: TimeEmbedding(128)
encoder: 3 ResNet blocks with downsampling
middle: ResNet + Self-Attention + ResNet
decoder: 3 ResNet blocks with upsampling
output: GroupNorm → SiLU → Conv2d
)1@misc{cifar10-diffusion-2025,
2 title={CIFAR-10 Diffusion Model: Fast Training Implementation},
3 author={Karthik},
4 year={2025},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/karthik-2905/DiffusionPretrained}}
7}