Stability-AI/generative-models
A YAML-driven diffusion framework for local SDXL inference and training experiments
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Stability AI's sgm is a Python/PyTorch framework that assembles diffusion pipelines from YAML. instantiate_from_config() constructs the configured components: network_config selects the backbone, loss_config defines the training loss and its sigma sampler, and sampler_config selects the numerical solver, step count, discretization, and guidance wrapper independently of the model. That separation lets a team compare sampling strategies without changing the backbone implementation.
GeneralConditioner calls each configured AbstractEmbModel with the batch field named by its input_key, such as txt or cls. Each embedder can specify trainability and classifier-free guidance dropout. The conditioner combines 2D–4D outputs into vector, sequence, and spatial conditioning, with concatenation sensitive to embedder order. Extending the system means implementing or configuring Python components and keeping their batch and tensor interfaces compatible.
Key Capabilities & Differentiators
The Streamlit entry point at scripts/demo/sampling.py supports text-to-image and image-to-image sampling with SDXL base and refiner variants in versions 1.0 and 0.9. The 1.0 checkpoints have both full-file SHA-256 and tensor-data hashes, so users can verify the download and the stored tensors separately. The image output path embeds an invisible watermark; scripts/demo/detect.py checks individual files or batches of files for that watermark, which differs from the one used in Stable Diffusion 1.x/2.x.
Training starts at python main.py --base ...; YAML files merge left to right, with later values taking precedence. Example configs range from class-conditional pixel diffusion on MNIST to latent diffusion and text-to-image training. The non-toy examples require dataset-specific edits for WebDataset tar files. The latent and text-to-image examples also require a VAE checkpoint path in place of CKPT_PATH, so those configs are starting points rather than turnkey training jobs.
Trade-offs & Limitations
Choose sgm over a higher-level inference pipeline when the work involves changing conditioning, solvers, or training components. The flexibility comes with more integration work: configuration changes still have to respect input keys, embedder order, checkpoint compatibility, and dependency versions. The Streamlit entry point serves local experiments; teams building an application still need to provide their own serving and operational controls.
Local execution gives you control of checkpoints and configuration, but it also makes GPU capacity your responsibility. Profile VRAM at the intended resolution and batch size, then test the refiner and expected concurrency separately rather than extrapolating from a base-only run. License review is likewise checkpoint-specific: MIT covers code, SDXL 1.0 weights use CreativeML Open RAIL++-M, and SDXL 0.9 weights are gated under a separate research license.
Hardware & Deployment Guide
Use a local Python environment with a compatible GPU stack. The package metadata allows Python 3.8 or later, but Python 3.10 is the tested baseline. The PyTorch 2.0 installation path uses CUDA 11.8 wheels for torch, torchvision, and torchaudio, followed by requirements/pt2.txt and pip install .. Hatch packages the YAML configs under sgm/configs, but the package does not declare runtime dependencies for the installer to resolve. Download model checkpoints separately, then run inference locally rather than through a hosted generation API.
For training, install sdata from Stability AI's datapipelines project. Training supports PyTorch 1.13 and 2.0, but the autoencoder training path is limited to 1.13, so validate the environment against the actual configuration. Release 0.0.1 introduced the reworked sgm codebase, separated samplers from guiders, and shipped SDXL 0.9 base and refiner; release 0.1.0, dated July 27, 2023, added the SDXL 1.0 pair.
instantiate_from_config() wire the network, conditioner, sampler, and loss as separate components.GeneralConditioner combines vector, sequence, and spatial embeddings; embedder order matters.sampler_config controls solver, step count, discretization, and classifier-free guidance independently of the model.scripts/demo/sampling.py runs a local Streamlit demo for text-to-image and image-to-image with SDXL base and refiner variants.main.py --base merges YAML files left to right, so later files can override model, training, or data settings.scripts/demo/detect.py checks for the output watermark.Teams running SDXL locally or experimenting with diffusion conditioning, sampling, and training at the component level.
You need a ready-made production image API, an installer that resolves all runtime dependencies, or weights covered by the same MIT license as the code.
Quick Start & Installation
python3.10 -m venv .generativemodels source .generativemodels/bin/activate pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # check CUDA version pip3 install -r requirements/pt2.txt pip3 install . pip3 install -e git+https://github.com/Stability-AI/datapipelines.git@main#egg=sdata
Comparison vs. Top Voice, Vision & Video Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| generative-models ★ | 27.4k | +13 | Python | MIT | A YAML-driven diffusion framework for local SDXL inference and training experime |
| whisperX | 26.5k | +677 | Python | BSD-2-Clause | Batched Whisper with forced alignment for word timings and optional speaker labe |
| hypit | 32.4k | +731 | TypeScript | — | An SVML framework and CLI for turning video references into reusable workflows |
| diffusers | 35k | +36 | Python | Apache-2.0 | A modular PyTorch SDK for running and customizing multimodal diffusion pipelines |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/Stability-AI/generative-models.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about generative-models
Can I change the sampler or add a conditioning input without rewriting the model?
sampler_config to select the solver, step count, discretization, and guidance wrapper without rewriting the model. To add a conditioning input, configure an AbstractEmbModel implementation in GeneralConditioner and supply its input_key in the batch. Preserve embedder order and check that the combined conditioning matches what the network expects.How should I size a GPU for local SDXL inference?
Does the MIT code license cover commercial self-hosting of the weights?
When is `sgm` a better fit than an inference pipeline or hosted API?
sgm when you need to modify and compare conditioning, sampling, or training components directly. A higher-level inference pipeline is a better fit if you mainly want to run a supported checkpoint behind a stable application interface. A hosted API shifts GPU operation to the provider, but gives you less control over the underlying runtime and model internals.Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy