stable-diffusion.cpp README

The project's README from github.com/leejet/stable-diffusion.cpp. As one markdown file: README.md.

stable-diffusion.cpp

leejet%2Fstable-diffusion.cpp | Trendshift

Diffusion model(SD,Flux,Wan,...) inference in pure C/C++

Note that this project is under active development.
API and command-line option may change frequently.

🔥Important News

Features

Quick Start

Get the sd executable

Download model weights

Generate an image with just one command

./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"

For detailed command-line arguments, check out cli doc.

Performance

If you want to improve performance or reduce VRAM/RAM usage, please refer to performance guide. For runtime and parameter backend placement, see the backend selection guide.

Bindings

These projects wrap stable-diffusion.cpp for easier use in other languages/frameworks.

UIs

These projects use stable-diffusion.cpp as a backend for their image generation.

Contributors

Thank you to all the people who have already contributed to stable-diffusion.cpp!

Contributors

stable-diffusion.cpp (leejet/stable-diffusion.cpp)

Searching Database…

What is this?A pure C/C++ inference engine for diffusion models like Stable Diffusion, Flux, Wan, Qwen Image, and Z-Image, built the same way as llama.cpp so you can generate images and videos without heavy Python dependencies.
Is this a library or a ready-to-use app?It is primarily a command-line tool and library (same philosophy as llama.cpp), but it also ships a brand-new embedded web UI and has third-party GUIs and language bindings (Go, Python, Rust, C#, Dart) built on top of it.
How do I get it running?Download a pre-built 'sd' executable from the releases page (or build from source via the build guide), download model weights (.ckpt/.safetensors/.gguf), then run the generate command with your prompt.
Do I need Python or any ML framework to use it?No, it's a plain C/C++ implementation based on ggml with no external dependencies — you just need model weight files in checkpoint, safetensors, or GGUF format.
Does it support GPU acceleration, or is it CPU-only?Both: it runs on CPU (with AVX/AVX2/AVX512 on x86) and also supports CUDA, Vulkan, Metal, OpenCL, and SYCL backends, so performance varies a lot depending on which backend you pick.
Which platforms and model types are supported?It runs on Linux, macOS, Windows, and Android (via Termux/Local Diffusion), and supports a huge range of image and video models including SD1.x/SDXL/SD3.5, Flux, Qwen Image, Wan, LTX video, and more.
What extra features does it support beyond plain text-to-image?It supports LoRA, ControlNet, IP-Adapter, PhotoMaker, LCM/LCM-LoRA, VAE tiling for lower memory use, ESRGAN upscaling, ADetailer, and embeds generation parameters into PNG output compatible with webui.
What weight formats can I load?It can load PyTorch checkpoints (.ckpt/.pth/.pt), Safetensors, and GGUF files, and the convert mode can turn weights into .gguf or .safetensors.
Can I get reproducible results across different machines?Yes, it offers cross-platform reproducibility with --rng cuda (matching stable-diffusion-webui's GPU RNG) or --rng cpu (matching ComfyUI's RNG).
Are there bindings for other languages?Yes — community bindings exist for Go, C#, Python, Rust, and Flutter/Dart, letting you use stable-diffusion.cpp as a backend from other ecosystems.
Creator
leejet
Size
165.9 MB
Stars
7.7K
Age
3y
Commits · 90 Days