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…

这是什么?一个纯 C/C++ 的扩散模型推理引擎,支持 Stable Diffusion、Flux、Wan、Qwen Image、Z-Image 等模型,构建方式与 llama.cpp 相同,让你无需繁重的 Python 依赖就能生成图像和视频。
这是库,还是拿来就能用的应用?它主要是一个命令行工具和库(理念与 llama.cpp 相同),但也附带一个全新的内嵌网页 UI,还有基于它构建的第三方图形界面和语言绑定(Go、Python、Rust、C#、Dart)。
怎么把它跑起来?从 releases 页面下载预构建的 'sd' 可执行文件(或按构建指南从源码构建),下载模型权重(.ckpt/.safetensors/.gguf),然后用你的提示词运行 generate 命令。
用它需要 Python 或什么机器学习框架吗?不需要,它是基于 ggml 的纯 C/C++ 实现,没有外部依赖——你只需要 checkpoint、safetensors 或 GGUF 格式的模型权重文件。
它支持 GPU 加速吗,还是只能靠 CPU?都支持:它能跑在 CPU 上(x86 上支持 AVX/AVX2/AVX512),也支持 CUDA、Vulkan、Metal、OpenCL 和 SYCL 后端,所以性能会因所选后端而有很大差异。
它支持哪些平台和模型类型?它能跑在 Linux、macOS、Windows 和 Android(经 Termux/Local Diffusion)上,支持范围极广的图像和视频模型,包括 SD1.x/SDXL/SD3.5、Flux、Qwen Image、Wan、LTX 视频模型等。
除了基础的文生图,它还支持哪些额外功能?它支持 LoRA、ControlNet、IP-Adapter、PhotoMaker、LCM/LCM-LoRA、降低内存占用的 VAE 分块、ESRGAN 超分辨率、ADetailer,还会把生成参数嵌入 PNG 输出,与 webui 兼容。
能加载哪些权重格式?它能加载 PyTorch checkpoint(.ckpt/.pth/.pt)、Safetensors 和 GGUF 文件,convert 模式还能把权重转换成 .gguf 或 .safetensors。
在不同机器上能得到可复现的结果吗?可以,它通过 --rng cuda(对齐 stable-diffusion-webui 的 GPU 随机数)或 --rng cpu(对齐 ComfyUI 的随机数)提供跨平台可复现性。
有其他语言的绑定吗?有——社区为 Go、C#、Python、Rust 和 Flutter/Dart 提供了绑定,让你能在其他生态里把 stable-diffusion.cpp 当作后端使用。
Creator
leejet
Size
165.9 MB
Stars
7.7K
Age
3y
Commits · 90 Days