stable-diffusion.cpp
Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,Minimax H3,...) inference in pure C/C++
What is stable-diffusion.cpp?
Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,Minimax H3,...) inference in pure C/C++
Overview of stable-diffusion.cpp
What it is
stable-diffusion.cpp is a pure C/C++ implementation of diffusion model inference, including Stable Diffusion, FLUX, Wan, Qwen Image, Z-Image, and others. It is built on ggml and operates similarly to llama.cpp. The project is under active development, and its API and command-line options may change frequently.
Key features
- Supports a wide range of image models (SD1.x, SD2.x, SDXL, SD3/SD3.5, FLUX.1/2/3, Qwen Image, Z-Image, and many more), image edit models, video models (Wan2.1/Wan2.2, MiniMax-H3, LTX-2.3/2.5, HunyuanVideo 1.5), and video upscale models (RelayVSR, SeedVR2).
- Includes PhotoMaker, IP-Adapter (SD 1.5 and SDXL), Control Net (SD 1.5), ADetailer, LoRA, and Latent Consistency Models (LCM/LCM-LoRA).
- Supports multiple backends: CPU (AVX, AVX2, AVX512), CUDA, Vulkan, Metal, OpenCL, and SYCL.
- Accepts model weights in PyTorch checkpoint (.ckpt, .pth, .pt), Safetensors (.safetensors), and GGUF (.gguf) formats; can convert weights to .gguf or .safetensors.
- Runs on Linux, macOS, Windows, and Android (via Termux, Local Diffusion).
- Provides sampling methods including Euler A, Euler, Heun, DPM2, DPM++ 2M, DPM++ 2M v2, DPM++ 2S a, ER-SDE, and LCM.
Use cases
stable-diffusion.cpp is intended for developers and users who need to run diffusion model inference locally on various hardware, including CPUs and GPUs with different backends. It can be used for image generation, image editing, video generation, and video upscaling. The lightweight, dependency-free design makes it suitable for integration into other applications or for use on resource-constrained devices.
Getting started
Download a pre-built binary from the releases page or build from source. Then download model weights, for example:curl -L -O https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensorsGenerate an image with one command:./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
License and pricing
The project is licensed under MIT. It is open source and free to use.
Based on the project's public README and repository metadata.