# Repository Briefing: leejet/stable-diffusion.cpp
> Source: https://repoforai.com/repo/leejet/stable-diffusion.cpp (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/leejet/stable-diffusion.cpp
- **Category**: Voice, Vision & Video (语音 / 视觉 / 视频生成)
- **Primary Language**: C++
- **License**: MIT
- **Engineering Health**: A+ (96/100 · Maintenance 35/35 · Adoption 21/25 · Releases 20/20 · License 20/20)
- **Latest Release**: master-1173-95bb623 (2026-12-02) — https://github.com/leejet/stable-diffusion.cpp/releases
- **Review Snapshot**: 2026-12-01 (Note: master-1173-95bb623 on 2026-12-02 shipped after this review; verify latest release notes)
- **Deployment / Stack Signals**: Local AI, CLI, Self-Hosted, GPU
- **Momentum**: 8,183 ★ total (+4 24h / +42 7d) · 1,020 forks
- **Topics**: `ai`, `cplusplus`, `diffusion`, `flux`, `flux-dev`, `ggml`, `image-generation`, `image2image`, `img2img`, `latent-diffusion`, `ltx-video`, `qwen-image`
- **When to Use**: Best for: Teams that want diffusion inference on their own machines, with a CLI for scripted jobs or an embedded browser UI for interactive generation, and can validate the exact model and backend before rollout. Skip if: You need to modify pipelines primarily in Python, want a provider to handle serving and capacity, or require a stable API contract without pinning and qualifying releases.

## Overview
```text
### Architecture & Core Mechanics
stable-diffusion.cpp is a native C/C++ diffusion inference engine built on ggml, rather than a Python or PyTorch application. The repository separates engine code in `src/` and headers in `include/` from the runnable examples under `examples/cli/` and `examples/server/`. Its two user-facing entrypoints are `sd-cli` for scripted generation and `sd-server` for an embedded Web UI.

The CLI example passes a checkpoint with `-m` and a prompt with `-p`. The server starts with `--model-dir`; in the UI, the user selects a model recipe and checkpoint, explicitly loads the model, and then generates from a prompt. Model selection and loading are therefore distinct from issuing a generation request in the UI. For device configuration, the engine distinguishes the backend used for runtime execution from where model parameters are placed.

### Key Capabilities & Differentiators
Image coverage extends from SD 1.x, SD 2.x, SDXL and SD3/3.5 to FLUX, Qwen Image and Z-Image. Video coverage includes Wan 2.1/2.2 and LTX releases such as LTX-2.5. Model-specific workflows include Qwen-Image-Edit and DGL ControlNet for Z-Image; those are reasons to choose a particular model path, not features to assume across every checkpoint.

The SD 1.5 example loads a single `.safetensors` checkpoint, while other models may require weights and additional components specified in their individual model guides. Quantization and RAM/VRAM tuning are covered separately from model selection. Evaluate the exact model variant, components and backend together: a working SD 1.5 smoke test verifies the deployment path, not compatibility or performance for a larger image or video workflow.

### Trade-offs & Limitations
Compared with a Python/PyTorch diffusion stack, the native executable is useful when the deliverable is a local runner or small self-hosted service rather than a pipeline developers need to modify in Python. Compared with a managed generation API, it keeps inference on infrastructure you control, but shifts model downloads, storage, device configuration and capacity testing to your team.

A lightweight runtime does not make the weights lightweight. RAM, VRAM and generation time still depend on the model, its components, output settings, backend placement and concurrent load. Treat the embedded UI as a practical generation surface, not evidence of multi-tenant serving features. Verify any required API contract against a pinned build. The engine's MIT license is separate from the terms governing model use and redistribution.

### Hardware & Deployment Guide
Start with a prebuilt release binary or build from source using the CMake project. The quick start has Windows PowerShell and Linux/macOS examples. From the build directory, the Unix-style paths are `./bin/sd-cli` and `./bin/sd-server`; the Windows examples use `bin/Release`. Download the weights separately into the repository's `models/` directory. For the UI, start the server with `--model-dir ../models`; for a CLI smoke test, pass the SD 1.5 checkpoint with `-m` and a prompt with `-p`. A Docker getting-started path is also available.

With the executable and required weights in place, inference can run locally without calling a hosted model API. Provision against the intended model, output settings and concurrency rather than the size of the executable. Recent milestones include MiniMax-H3-Image support and the addition of the embedded Web UI; the latest listed build is `master-1170-5544c54`. Because interfaces can change frequently, pin the binary and keep a loading and generation smoke test for each model recipe you deploy.
```

## Key Capabilities
```text
- Runtime: ggml-backed C/C++ inference without a Python or PyTorch runtime requirement.
- Entrypoints: `sd-cli` runs prompt-driven jobs; `sd-server` provides an embedded image and video Web UI.
- Models: Supports image families including SDXL, FLUX and Qwen Image, plus video families including Wan and LTX.
- Backend placement: Runtime execution and model parameter placement are separate configuration considerations.
- Model provisioning: The SD 1.5 example uses one `.safetensors` checkpoint; other models can require additional components.
- Release management: CLI options and APIs can change frequently, so pin builds and validate integrations before upgrading.
```

## Quick Start / Clone
```bash
mkdir -p ../models/checkpoints
curl -L -o ../models/checkpoints/v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
```
