Diffusion Model
A generative model that creates images by progressively removing noise
A generative model that creates images by progressively removing noise
A Diffusion Model is a generative model that learns the process of gradually adding noise to data, then generates new data from pure noise through the reverse process. Since the publication of DDPM (Denoising Diffusion Probabilistic Models) in 2020, it has become the mainstream paradigm in image generation, replacing GANs.
The development of Diffusion Models runs from the 2015 theory based on non-equilibrium thermodynamics, to the practical implementation in DDPM in 2020, Latent Diffusion (the basis of Stable Diffusion) in 2021, and the release of DALL-E 2 and Imagen in 2022. Since 2023, controllable generation techniques such as ControlNet and IP-Adapter and the DiT (Diffusion Transformer) architecture have emerged, and the field is evolving rapidly.
The key components are the noise scheduler, the noise prediction network (U-Net or Transformer), and the conditioning embedding (text encoder). During training, the model receives an image with noise added at a random timestep t, together with the condition, and predicts the added noise. During inference, it starts from pure noise and repeats steps that remove the predicted noise to generate an image.
In practice, Diffusion Models are the core engine of leading image generation services such as Stable Diffusion, Midjourney, and DALL-E 3. Beyond text-to-image generation, they enable a variety of applications, including image editing (inpainting), image extension (outpainting), style transfer, and video generation (Sora). Open-source Stable Diffusion can be customized for specific domains through fine-tuning and LoRA training, making it highly useful for enterprises.
# Hugging Face Diffusers로 이미지 생성
from diffusers import StableDiffusionPipeline
import torch
# Stable Diffusion 모델 로드
pipe = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-1",
torch_dtype=torch.float16
).to("cuda")
# 메모리 최적화 (선택)
pipe.enable_attention_slicing()
pipe.enable_vae_slicing()
# 텍스트-이미지 생성
prompt = "A serene mountain landscape at sunset, photorealistic, 8k"
negative_prompt = "blurry, low quality, distorted"
image = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=30, # 샘플링 스텝 수
guidance_scale=7.5, # CFG 강도
height=768,
width=768
).images[0]
image.save("generated_image.png")
# 다양한 스케줄러 사용
from diffusers import DPMSolverMultistepScheduler
# 빠른 DPM-Solver 스케줄러로 교체 (20스텝으로 품질 유지)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
fast_image = pipe(prompt, num_inference_steps=20).images[0]
print("이미지 생성 완료!")
"We evaluated adopting Stable Diffusion XL for the image generation feature. Base SDXL supports a native resolution of 1024x1024, and a Refiner model can enhance the details. API cost is about 0.02 dollars per image."
"Latent Diffusion performs diffusion in a latent space compressed by a VAE instead of in pixel space. Compressing a 512x512 image into a 64x64 latent reduces computation by 64 times, which is the key innovation that made high-resolution generation possible even on consumer GPUs."
"If speed matters for production deployment, I recommend applying LCM (Latent Consistency Model). It reduces the default 50 steps to 4, cutting inference time by 90% with only a minor drop in quality."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Stable Diffusion is licensed under the CreativeML Open RAIL-M license, which permits commercial use, but there is controversy over the sources of its training data. For enterprise services, consider using a model with clearly sourced training data, such as Adobe Firefly.
Diffusion Models can generate inappropriate content. Be sure to enable the Safety Checker module, and build prompt filtering and a generated-image review pipeline.
SDXL inference needs at least 8GB of VRAM, and training needs a GPU with 24GB or more. When deploying in the cloud, include the cost of A10G (24GB) or A100 (40/80GB) instances in your budget.