# leejet/stable-diffusion.cpp

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/leejet-stable-diffusion-cpp).**

5,430 stars · 534 forks · C++ · mit

## Links

- GitHub: https://github.com/leejet/stable-diffusion.cpp
- awesome-repositories: https://awesome-repositories.com/repository/leejet-stable-diffusion-cpp.md

## Topics

`ai` `cplusplus` `diffusion` `flux` `flux-dev` `flux-schnell` `ggml` `image-generation` `image2image` `img2img` `latent-diffusion` `qwen-image` `stable-diffusion` `text2image` `txt2img` `videogeneration` `wan` `z-image` `z-image-turbo`

## Description

stable-diffusion.cpp is a high-performance C++ inference engine designed for generating images and video from text prompts using Stable Diffusion models. It functions as a latent diffusion model runtime and a lightweight machine learning framework that enables local diffusion model execution on consumer hardware.

The project distinguishes itself as a CPU-based image generator capable of running without a dedicated GPU. It employs a specialized C++ tensor backend and cross-backend hardware abstraction to dispatch compute tasks across different processor instruction sets and graphics APIs.

The engine covers a broad range of generative capabilities, including text-to-image generation, AI image editing, and super-resolution upscaling. It incorporates memory usage optimizations such as tiled decoding and low-level memory mapping to reduce hardware requirements.

The framework also includes utilities for model weight conversion, transforming weights between different storage formats to ensure compatibility across various runtimes.

## Tags

### Artificial Intelligence & ML

- [Text-to-Visual Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-visual-generation.md) — Produces images and video from text prompts using diffusion models across multiple hardware backends. ([source](https://cdn.jsdelivr.net/gh/leejet/stable-diffusion.cpp@master/README.md))
- [CPU-Optimized Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-image-generators/cpu-optimized-generators.md) — Provides a generative AI tool optimized for running diffusion models on consumer CPUs without a GPU.
- [C++ Machine Learning Libraries](https://awesome-repositories.com/f/artificial-intelligence-ml/c-machine-learning-libraries.md) — Functions as a lightweight C++ library for running neural network inference with efficient memory tiling.
- [Local Execution Optimizations](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-models/diffusion-models/local-execution-optimizations.md) — Optimizes the execution of Stable Diffusion models on consumer hardware to reduce memory consumption.
- [Text-to-Image Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-image-generators.md) — Generates high-resolution images from text prompts using Stable Diffusion models.
- [Latent Diffusion Models](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-models/latent-diffusion-models.md) — Provides a runtime for performing image synthesis through iterative denoising within latent spaces.
- [Stable Diffusion Inference Engines](https://awesome-repositories.com/f/artificial-intelligence-ml/stable-diffusion-inference-engines.md) — Implements a high-performance C++ engine for generating images and video from text prompts using Stable Diffusion.
- [Tensor Computation Backends](https://awesome-repositories.com/f/artificial-intelligence-ml/tensor-computation-backends.md) — Provides a high-performance C++ tensor backend for executing mathematical operations on CPUs and GPUs.
- [Attention Mechanisms](https://awesome-repositories.com/f/artificial-intelligence-ml/attention-mechanisms.md) — Implements efficient matrix multiplication specifically for optimizing attention layers within transformer blocks.
- [Tiled Decoding](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-models/latent-space-generative-models/latent-space-projections/image-to-latent-projections/latent-to-pixel-decoding/tiled-decoding.md) — Prevents out-of-memory errors by processing large image latent spaces in smaller overlapping blocks.
- [Image Editing](https://awesome-repositories.com/f/artificial-intelligence-ml/image-generation/image-editing.md) — Provides capabilities to modify existing visual content using specialized generative image editing models. ([source](https://cdn.jsdelivr.net/gh/leejet/stable-diffusion.cpp@master/README.md))
- [Image Super Resolution Models](https://awesome-repositories.com/f/artificial-intelligence-ml/image-super-resolution-models.md) — Increases the resolution and quality of generated images using super-resolution algorithms. ([source](https://cdn.jsdelivr.net/gh/leejet/stable-diffusion.cpp@master/README.md))
- [Memory-Mapped Weight Loaders](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/inference-optimization/memory-mapped-weight-loaders.md) — Maps model weight files directly into process memory to minimize RAM usage and startup time.
- [Memory Optimization Techniques](https://awesome-repositories.com/f/artificial-intelligence-ml/memory-optimization-techniques.md) — Implements tiled decoding and attention optimizations to reduce the memory footprint during image generation. ([source](https://cdn.jsdelivr.net/gh/leejet/stable-diffusion.cpp@master/README.md))
- [Weight Conversion Utilities](https://awesome-repositories.com/f/artificial-intelligence-ml/model-parameter-management/weight-conversion-utilities.md) — Transforms machine learning weights between different storage formats for cross-runtime compatibility.

### Software Engineering & Architecture

- [Hardware Abstraction Layers](https://awesome-repositories.com/f/software-engineering-architecture/hardware-abstraction-layers.md) — Ships a unified interface to dispatch compute tasks across different processor instruction sets and graphics APIs.

### Data & Databases

- [Model Weight Conversions](https://awesome-repositories.com/f/data-databases/vector-data-formats/format-conversion-utilities/model-weight-conversions.md) — Transforms complex model tensors into streamlined binary layouts optimized for sequential memory access.

### Part of an Awesome List

- [AI & Machine Learning](https://awesome-repositories.com/f/awesome-lists/ai/ai-machine-learning.md) — Diffusion model inference in pure C/C++
