How the Generative Models codebase works
mainThe codebase follows a config-driven approach centered on modularity. Submodules are built and combined by calling instantiate_from_config() on objects defined in YAML configuration files (found in the configs/ directory).
Core Architectural Changes (vs. old ldm codebase):
- DiffusionEngine: The core diffusion model class (formerly
LatentDiffusion) now handles all types of conditioning (vectors, sequences, and spatial conditionings) via a singleGeneralConditionerclass. - Decoupled Components: Guiders (e.g., classifier-free guidance in
sgm/modules/diffusionmodules/guiders.py) are separated from samplers (sgm/modules/diffusionmodules/sampling.py). Samplers are independent of the model. - Denoiser Framework: The codebase adopts a denoiser framework where discrete-time models are treated as special cases of continuous-time models. Features like diffusion loss weighting, network preconditioning, and noise level sampling are now independent components.