stable-diffusion.cpp
Introducing , a pure C/C++ inference engine for Stable Diffusion! This is a really awesome implementation to help speed up home inference of diffusion models. -diffusion.cpp
Tailored for developers and AI enthusiasts, this repository offers a high-performance solution for creating and manipulating images using various quantization techniques and accelerated inference.
Key Features:
- Efficient Implementation: Utilizing plain C/C++, it operates seamlessly like llama.cpp and is built on the ggml framework.
- Multiple Precision Support: Choose between 16-bit, 32-bit float, and 4-bit to 8-bit integer quantization.
- Optimized Performance: Experience memory-efficient CPU inference with AVX, AVX2, and AVX512 support for x86 architectures.
- Versatile Modes: From original
txt2img
toimg2img
modes and negative prompt handling, customize your processing needs. - Cross-Platform Compatibility: Runs smoothly on Linux, Mac OS, and Windows.
Getting Started
Cloning, building, and running are made simple, and detailed examples are provided for both text-to-image and image-to-image generation. With an array of options for precision and comprehensive usage guidelines, you can easily adapt the code for your specific project requirements.
git clone --recursive https://github.com/leejet/stable-diffusion.cpp
cd stable-diffusion.cpp
- If you have already cloned the repository, you can use the following command to update the repository to the latest code.
cd stable-diffusion.cpp
git pull origin master
git submodule update
More Details
- Plain C/C++ implementation based on ggml, working in the same way as llama.cpp
- 16-bit, 32-bit float support
- 4-bit, 5-bit and 8-bit integer quantization support
- Accelerated memory-efficient CPU inference
- Only requires ~2.3GB when using txt2img with fp16 precision to generate a 512x512 image
- AVX, AVX2 and AVX512 support for x86 architectures
- Original
txt2img
andimg2img
mode - Negative prompt
- stable-diffusion-webui style tokenizer (not all the features, only token weighting for now)
- Sampling method
Euler A
- Supported platforms
- Linux
- Mac OS
- Windows
This is a really exciting repo. I’ll be honest, I don’t think I am as well versed in what’s going on for diffusion inference - but I do know more efficient and effective methods running those models are always welcome by people frequently using diffusers. Especially for those who need to multi-task and maintain performance headroom.
I tried it out just now. Seems impressive! I managed to get it to run on a Ryzen 5 5600 w/ 16GB of RAM at ~20s/step. It’s useful if you don’t need much of the extra content that stable-diffusion-webui has. It only used around 2GB of RAM too!
Wow! I’ve been waiting for this for a long time. Hope they’ll implement all sorts of bells and whistles so I can use this for every use case. And maybe a python wrapper. I’ve been fiddling around with the OpenVino (and I think also onnx) inference projects but all other projects were a hassle to install and had dependencies that were really diffictult to set up. This one just works. And I don’t even need to spin up a cloud gpu instance any more just to generate the one-off picture. Thanks!