Stable Diffusion is an open-source latent diffusion model for generating images from text prompts. Unlike pixel-space diffusion, it performs denoising in a compact latent representation, reducing computational cost while preserving visual quality and semantic fidelity. section 1.3.2 section 13.1.3
Trace a text prompt through three cooperating components:
- The CLIP text encoder tokenizes a prompt, pads or truncates it to 77 tokens, and produces a 77 × 768 text-embedding matrix. section 10.2.1
- The conditional denoising U-Net starts from random noise shaped (4, 64, 64) and repeatedly removes noise while conditioning each refinement on the text embedding. section 10.2.1
- The VAE decoder converts the denoised latent representation into a high-resolution image. section 10.2.1
Generate an image with Diffusers
Install Hugging Face Diffusers, load the stable-diffusion-v1-4 checkpoint with StableDiffusionPipeline.from_pretrained(), move it to CUDA, and call the pipeline with the prompt “an astronaut in a spacesuit riding a unicorn.” Half-precision float16 reduces computation time relative to float32, while prompts, image dimensions, guidance scale, and random seeds provide practical controls. section 10.1


