Flower DDPM — 32×32 Unconditional Diffusion Model
This model is a small unconditional diffusion model trained from scratch to generate 32×32 RGB images resembling flowers from the Ambrosiussen/flower-dataset.
The model uses a UNet2DModel from 🤗 Diffusers as its denoising network and a DDPM noise process with 1,000 training timesteps.
Unlike text-to-image models such as Stable Diffusion, this model does not contain a text encoder and does not accept prompts. Images are generated unconditionally from random Gaussian noise.
Model Details
Model Description
The model was trained as a compact educational implementation of a Denoising Diffusion Probabilistic Model (DDPM).
During training, clean flower images are progressively corrupted with Gaussian noise. The U-Net receives a noisy image together with its diffusion timestep and learns to predict the noise that was added.
At inference time, generation starts from random noise. The learned U-Net repeatedly predicts noise while the DDPM scheduler gradually denoises the sample until a 32×32 RGB image is produced.
- Model type: Unconditional Denoising Diffusion Probabilistic Model
- Denoising network:
diffusers.UNet2DModel - Scheduler:
diffusers.DDPMScheduler - Task: Unconditional image generation
- Training: From scratch
- Image resolution: 32×32
- Input channels: 3 RGB channels
- Output channels: 3 RGB channels
- Training timesteps: 1,000
- Noise schedule:
squaredcos_cap_v2 - Prediction target: Added Gaussian noise / epsilon
- Training objective: Mean Squared Error between predicted and sampled noise
- Training epochs: 50
- Batch size: 32
- Optimizer: AdamW
- Learning rate:
4e-4 - Framework: PyTorch + 🤗 Diffusers
- License: MIT
- Training dataset:
Ambrosiussen/flower-dataset
Architecture
The denoising network uses the following configuration:
UNet2DModel(
sample_size=32,
in_channels=3,
out_channels=3,
layers_per_block=2,
block_out_channels=(64, 128, 128, 256),
down_block_types=(
"DownBlock2D",
"DownBlock2D",
"AttnDownBlock2D",
"AttnDownBlock2D",
),
up_block_types=(
"AttnUpBlock2D",
"AttnUpBlock2D",
"UpBlock2D",
"UpBlock2D",
),
)
The network therefore combines standard residual U-Net blocks with spatial self-attention at the deeper resolutions.
The encoder progressively transforms the image through feature widths of:
64 → 128 → 128 → 256
and the decoder reconstructs the image while using skip connections from the corresponding encoder stages.
Self-attention is used in the deeper two downsampling and first two upsampling stages, allowing the model to capture relationships between spatial regions of the image in addition to local convolutional features.
Model Sources
- Training dataset: Ambrosiussen/flower-dataset
- Framework: Hugging Face Diffusers
- DDPM paper: Denoising Diffusion Probabilistic Models
Uses
Direct Use
The intended use of this model is unconditional generation of small flower images.
It can be used to:
- experiment with diffusion-model inference,
- study DDPM denoising,
- visualize the diffusion process,
- learn how U-Net-based diffusion models work,
- test alternative diffusion schedulers,
- explore small-scale generative-model training,
- generate 32×32 flower-like samples.
The model does not require a prompt.
Instead, generation begins from randomly sampled Gaussian noise.
Downstream Use
The checkpoint can also be used as a starting point for educational experiments involving:
- alternative samplers or schedulers,
- different numbers of inference steps,
- diffusion visualization,
- transfer-learning experiments,
- fine-tuning on related visual domains,
- architecture modifications,
- comparisons between attention and non-attention U-Nets,
- noise-schedule experiments.
Because the model operates at only 32×32 resolution, it is particularly useful for inexpensive experimentation with diffusion algorithms.
Out-of-Scope Use
The model is not intended for:
- general-purpose text-to-image generation,
- prompt-controlled generation,
- photorealistic high-resolution image generation,
- image editing,
- image-to-image generation without additional implementation,
- commercial production image generation without further evaluation,
- generating domains substantially different from the training data.
The model has only been trained on flower imagery and should not be expected to generalize reliably to unrelated visual concepts.
How to Get Started with the Model
If the repository contains the trained UNet2DModel checkpoint, it can be combined with the same DDPM scheduler used during training.
Replace YOUR_USERNAME/YOUR_MODEL_ID with this model repository.
import torch
from diffusers import (
DDPMPipeline,
DDPMScheduler,
UNet2DModel,
)
model_id = "YOUR_USERNAME/YOUR_MODEL_ID"
device = (
"cuda"
if torch.cuda.is_available()
else "cpu"
)
# Load trained denoising network
unet = UNet2DModel.from_pretrained(model_id)
# Recreate the scheduler used during training
scheduler = DDPMScheduler(
num_train_timesteps=1000,
beta_schedule="squaredcos_cap_v2",
)
# Build the DDPM generation pipeline
pipe = DDPMPipeline(
unet=unet,
scheduler=scheduler,
)
pipe = pipe.to(device)
# Optional reproducibility
generator = torch.Generator(device=device).manual_seed(42)
image = pipe(
generator=generator,
).images[0]
image.save("generated_flower.png")
Different random seeds will produce different samples:
generator = torch.Generator(device=device).manual_seed(123)
image = pipe(
generator=generator,
).images[0]
The number of denoising steps can also be varied during inference to study the trade-off between generation speed and output quality.
Training Details
Training Data
The model was trained using:
Images were loaded using Hugging Face datasets:
from datasets import load_dataset
dataset = load_dataset(
"Ambrosiussen/flower-dataset",
split="train",
)
Only the training split was used in the provided training procedure.
No separate validation or test split was used for the reported model.
Preprocessing
Images were converted to RGB and transformed on-the-fly using:
preprocess = T.Compose(
[
T.Resize((32, 32)),
T.RandomHorizontalFlip(),
T.ToTensor(),
T.Normalize([0.5], [0.5]),
]
)
The preprocessing pipeline therefore consists of:
- conversion to RGB,
- resizing to 32×32 pixels,
- random horizontal flipping,
- conversion to a PyTorch tensor,
- normalization from approximately
[0, 1]to[-1, 1].
The horizontal flip acts as a simple data augmentation.
Diffusion Training Procedure
For each training batch:
- A clean flower image is sampled.
- Gaussian noise is generated with the same shape as the image.
- A random diffusion timestep
tbetween 0 and 999 is sampled independently for each image. - The DDPM scheduler corrupts the clean image according to timestep
t. - The U-Net receives the noisy image and timestep.
- The network predicts the Gaussian noise that was added.
- Mean Squared Error is computed between the predicted and true noise.
- Gradients are propagated through the U-Net.
- AdamW updates the model parameters.
Conceptually, the training objective is:
clean image x₀
↓
sample timestep t
↓
sample Gaussian noise ε
↓
create noisy image xₜ
↓
UNet(xₜ, t)
↓
predicted noise ε̂
↓
MSE(ε̂, ε)
The model therefore learns the reverse of the corruption process indirectly by learning to estimate the noise present at each diffusion timestep.
Noise Scheduler
The training scheduler was:
DDPMScheduler(
num_train_timesteps=1000,
beta_schedule="squaredcos_cap_v2",
)
This defines a diffusion process containing 1,000 discrete noise levels.
During training, a timestep is sampled uniformly:
timesteps = torch.randint(
0,
noise_scheduler.num_train_timesteps,
(batch_size,),
device=device,
).long()
The scheduler then produces the noisy training image:
noisy_img = noise_scheduler.add_noise(
clean_img,
noise,
timesteps,
)
Objective
The model predicts the noise added to each image:
noise_pred = model(
noisy_img,
timesteps,
return_dict=False,
)[0]
The intended training objective is:
loss = F.mse_loss(noise_pred, noise)
This corresponds to epsilon prediction, where the network learns to estimate the Gaussian noise used to corrupt the image.
Training Hyperparameters
Image size 32 × 32
Channels RGB / 3
Epochs 50
Batch size 32
Optimizer AdamW
Learning rate 4e-4
Training timesteps 1000
Noise schedule squaredcos_cap_v2
Objective Noise / epsilon prediction
Loss Mean Squared Error
Augmentation Random horizontal flip
No learning-rate scheduler, gradient clipping, EMA model, mixed-precision configuration, or gradient accumulation was specified in the provided training configuration.
Evaluation
Testing Data
No independent testing dataset was used in the provided training procedure.
The model was primarily assessed through its training loss and generated samples.
Consequently, this checkpoint should be considered an experimental/educational generative model rather than a formally benchmarked image-generation model.
Factors
Relevant factors when qualitatively evaluating the model include:
- flower shape,
- color distribution,
- background consistency,
- diversity between random seeds,
- presence of recognizable flower-like structures,
- visual artifacts,
- sample diversity,
- resemblance to training examples.
Metrics
The training objective uses Mean Squared Error:
F.mse_loss(noise_pred, noise)
This measures how accurately the U-Net predicts the Gaussian noise added at each diffusion timestep.
Training loss alone should not be interpreted as a complete measurement of generated-image quality.
No FID, KID, Inception Score, CLIP Score, or human-preference evaluation was reported.
Results
The model was trained for 50 epochs on the flower dataset.
Training loss was averaged over the most recent epoch and printed every five epochs.
Example evaluation logic:
if (epoch + 1) % 5 == 0:
loss_last_epoch = (
sum(loss_l[-len(train_loader):])
/ len(train_loader)
)
print(
f"Epoch: {epoch + 1}, "
f"loss: {loss_last_epoch}"
)
Exact final loss values and quantitative image-quality metrics were not recorded in this model card.
Summary
The model demonstrates that a relatively compact U-Net can learn an unconditional diffusion process for a restricted visual domain at low resolution.
Its main purpose is experimentation and education rather than state-of-the-art image synthesis.
Bias, Risks, and Limitations
The behavior of the model is strongly determined by the flower images contained in its training dataset.
The model may reproduce biases in:
- flower species represented,
- colors,
- photographic styles,
- framing,
- backgrounds,
- lighting,
- image composition.
Because the model operates at 32×32 pixels, generated images have very limited spatial detail.
Small resolution can produce:
- blurry structures,
- distorted petals,
- ambiguous flower shapes,
- incorrect geometry,
- noisy backgrounds,
- poor fine-detail generation.
The model also has no semantic conditioning mechanism. Users cannot request a particular flower, color, composition, species, or style through natural-language prompts.
The model was trained without a dedicated validation or test set in the provided training procedure. Its generalization performance has therefore not been quantitatively established.
As with other generative models trained on finite datasets, there is also a possibility of memorization or outputs resembling individual training samples.
Recommendations
This model is best treated as a small research and educational checkpoint.
For stronger evaluation, future versions could include:
- a held-out validation set,
- a held-out test set,
- FID or KID evaluation,
- nearest-neighbor analysis for memorization,
- sample grids generated from fixed seeds,
- comparisons across training checkpoints,
- larger image resolutions,
- Exponential Moving Average model weights,
- additional data augmentation.
For reproducible comparisons, generated samples should use fixed random seeds and identical scheduler settings.
Model Examination
The architecture can be examined by monitoring intermediate feature maps or attention layers during denoising.
Because the network contains self-attention in its deeper U-Net stages, attention patterns can also be inspected to explore which spatial regions interact during noise prediction.
Another useful analysis is visualizing the reverse diffusion process:
Gaussian noise
↓
very noisy structure
↓
rough color regions
↓
flower-like structure
↓
final generated flower
This makes the checkpoint useful for teaching how iterative diffusion-based generation works.
Technical Specifications
Model Architecture and Objective
The model consists of a convolutional U-Net with residual blocks, timestep conditioning, skip connections, downsampling/upsampling paths, and spatial self-attention at deeper resolutions.
The model maps:
noisy RGB image + diffusion timestep
↓
UNet2DModel
↓
predicted RGB noise
Both the input and output tensors have the form:
[B, 3, 32, 32]
where:
Bis the batch size,3represents RGB channels,32 × 32is the spatial resolution.
The network's objective is to predict the sampled Gaussian noise:
εθ(xₜ, t) ≈ ε
where:
xₜis the image corrupted to timestept,tis the diffusion timestep,εis the Gaussian noise used to corrupt the image,εθis the noise predicted by the neural network.
Training minimizes:
L = MSE(εθ(xₜ, t), ε)
Citation
This model does not have an associated research paper.
The underlying DDPM methodology originates from:
Denoising Diffusion Probabilistic Models
Jonathan Ho, Ajay Jain, and Pieter Abbeel, 2020.
BibTeX:
@article{ho2020denoising,
title={Denoising Diffusion Probabilistic Models},
author={Ho, Jonathan and Jain, Ajay and Abbeel, Pieter},
journal={Advances in Neural Information Processing Systems},
volume={33},
pages={6840--6851},
year={2020}
}
APA:
Ho, J., Jain, A., & Abbeel, P. (2020). Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33, 6840–6851.
Glossary
DDPM — Denoising Diffusion Probabilistic Model. A generative model that learns to reverse a gradual noise-corruption process.
U-Net — A neural-network architecture with an encoder and decoder connected through skip connections. It is commonly used as the denoising network in diffusion models.
Diffusion timestep — A value describing how far an image has progressed through the noise process.
Gaussian noise — Random values sampled from a normal distribution and progressively added to training images.
Noise prediction / epsilon prediction — A diffusion training objective where the neural network attempts to predict the noise that was added to an image.
Scheduler — The component controlling how noise is added during training and removed during inference.
Self-attention — A mechanism allowing spatial positions in the feature map to exchange information with other positions rather than relying only on local convolutional neighborhoods.
Unconditional generation — Image generation without additional input such as text prompts, class labels, or reference images.
More Information
This model is intended as a compact implementation of unconditional diffusion training using 🤗 Diffusers.
It is particularly suitable for learning and experimenting with:
image
↓
forward diffusion
↓
noise
↓
U-Net learns noise prediction
↓
reverse diffusion
↓
generated image
The small 32×32 resolution makes training and experimentation considerably more accessible than modern large-scale diffusion systems.
Model Card Authors
Model card created for the author of this Hugging Face model based on the provided training configuration.
Model Card Contact
Please use the Hugging Face repository's Community section for questions, issues, or feedback regarding the model.