Skip to content

Commit 274ecd5

Browse files
committed
Merge branch 'master' into ltx2.3
2 parents 51d681e + b8bdffc commit 274ecd5

84 files changed

Lines changed: 7887 additions & 3336 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ jobs:
176176
177177
build-and-push-docker-images:
178178
name: Build and push container images
179+
if: ${{ github.event_name != 'pull_request' }}
179180
runs-on: ubuntu-latest
180181

181182
permissions:

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ endif()
1111
if (MSVC)
1212
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
1313
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
14+
add_compile_options(
15+
$<$<COMPILE_LANGUAGE:C>:/MP>
16+
$<$<COMPILE_LANGUAGE:CXX>:/MP>
17+
)
1418
endif()
1519

1620
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -152,12 +156,16 @@ endif()
152156

153157
set(SD_LIB stable-diffusion)
154158

155-
file(GLOB SD_LIB_SOURCES
159+
file(GLOB SD_LIB_SOURCES CONFIGURE_DEPENDS
156160
"src/*.h"
157161
"src/*.cpp"
158162
"src/*.hpp"
159-
"src/vocab/*.h"
160-
"src/vocab/*.cpp"
163+
"src/model_io/*.h"
164+
"src/model_io/*.cpp"
165+
"src/tokenizers/*.h"
166+
"src/tokenizers/*.cpp"
167+
"src/tokenizers/vocab/*.h"
168+
"src/tokenizers/vocab/*.cpp"
161169
)
162170

163171
find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
@@ -250,7 +258,7 @@ endif()
250258
add_subdirectory(thirdparty)
251259

252260
target_link_libraries(${SD_LIB} PUBLIC ggml zip)
253-
target_include_directories(${SD_LIB} PUBLIC . include)
261+
target_include_directories(${SD_LIB} PUBLIC . src include)
254262
target_include_directories(${SD_LIB} PUBLIC . thirdparty)
255263
target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17)
256264

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ API and command-line option may change frequently.***
5757
- [Z-Image](./docs/z_image.md)
5858
- [Ovis-Image](./docs/ovis_image.md)
5959
- [Anima](./docs/anima.md)
60+
- [ERNIE-Image](./docs/ernie_image.md)
6061
- Image Edit Models
6162
- [FLUX.1-Kontext-dev](./docs/kontext.md)
6263
- [Qwen Image Edit series](./docs/qwen_image_edit.md)
@@ -76,9 +77,10 @@ API and command-line option may change frequently.***
7677
- OpenCL
7778
- SYCL
7879
- Supported weight formats
79-
- Pytorch checkpoint (`.ckpt` or `.pth`)
80+
- Pytorch checkpoint (`.ckpt` or `.pth` or `.pt`)
8081
- Safetensors (`.safetensors`)
8182
- GGUF (`.gguf`)
83+
- Convert mode supports converting model weights to `.gguf` or `.safetensors`
8284
- Supported platforms
8385
- Linux
8486
- Mac OS
@@ -96,6 +98,7 @@ API and command-line option may change frequently.***
9698
- `DPM++ 2M`
9799
- [`DPM++ 2M v2`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/8457)
98100
- `DPM++ 2S a`
101+
- `ER-SDE`
99102
- [`LCM`](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13952)
100103
- Cross-platform reproducibility
101104
- `--rng cuda`, default, consistent with the `stable-diffusion-webui GPU RNG`
@@ -144,6 +147,7 @@ If you want to improve performance or reduce VRAM/RAM usage, please refer to [pe
144147
- [🔥Z-Image](./docs/z_image.md)
145148
- [Ovis-Image](./docs/ovis_image.md)
146149
- [Anima](./docs/anima.md)
150+
- [ERNIE-Image](./docs/ernie_image.md)
147151
- [LoRA](./docs/lora.md)
148152
- [LCM/LCM-LoRA](./docs/lcm.md)
149153
- [Using PhotoMaker to personalize image generation](./docs/photo_maker.md)

assets/ernie_image/example.png

595 KB
Loading
562 KB
Loading

docs/distilled_sd.md

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,51 +87,32 @@ pipe.save_pretrained("segmindtiny-sd", safe_serialization=True)
8787
```bash
8888
python convert_diffusers_to_original_stable_diffusion.py \
8989
--model_path ./segmindtiny-sd \
90-
--checkpoint_path ./segmind_tiny-sd.ckpt --half
90+
--checkpoint_path ./segmind_tiny-sd.safetensors --half --use_safetensors
9191
```
9292

93-
The file segmind_tiny-sd.ckpt will be generated and is now ready for use with sd.cpp. You can follow a similar process for the other models mentioned above.
93+
The file segmind_tiny-sd.safetensors will be generated and is now ready for use with sd.cpp. You can follow a similar process for the other models mentioned above.
9494

9595

96-
##### Another available .ckpt file:
97-
98-
* https://huggingface.co/ClashSAN/small-sd/resolve/main/tinySDdistilled.ckpt
99-
100-
To use this file, you must first adjust its non-contiguous tensors:
101-
102-
```python
103-
import torch
104-
ckpt = torch.load("tinySDdistilled.ckpt", map_location=torch.device('cpu'))
105-
for key, value in ckpt['state_dict'].items():
106-
if isinstance(value, torch.Tensor):
107-
ckpt['state_dict'][key] = value.contiguous()
108-
torch.save(ckpt, "tinySDdistilled_fixed.ckpt")
109-
```
110-
111-
112-
### SDXS-512
96+
### SDXS-512-DreamShaper
11397

11498
Another very tiny and **incredibly fast** model is SDXS by IDKiro et al. The authors refer to it as *"Real-Time One-Step Latent Diffusion Models with Image Conditions"*. For details read the paper: https://arxiv.org/pdf/2403.16627 . Once again the authors removed some more blocks of U-Net part and unlike other SD1 models they use an adjusted _AutoEncoderTiny_ instead of default _AutoEncoderKL_ for the VAE part.
99+
##### Some ready-to-run SDXS-512 model files are available online, such as:
115100

116-
##### 1. Download the diffusers model from Hugging Face using Python:
117-
118-
```python
119-
from diffusers import StableDiffusionPipeline
120-
pipe = StableDiffusionPipeline.from_pretrained("IDKiro/sdxs-512-dreamshaper")
121-
pipe.save_pretrained(save_directory="sdxs")
122-
```
123-
##### 2. Create a safetensors file
124-
125-
```bash
126-
python convert_diffusers_to_original_stable_diffusion.py \
127-
--model_path sdxs --checkpoint_path sdxs.safetensors --half --use_safetensors
128-
```
129-
130-
##### 3. Run the model as follows:
101+
* https://huggingface.co/akleine/sdxs-512
102+
* https://huggingface.co/concedo/sdxs-512-tinySDdistilled-GGUF
131103

104+
##### Run the model as follows:
132105
```bash
133106
~/stable-diffusion.cpp/build/bin/sd-cli -m sdxs.safetensors -p "portrait of a lovely cat" \
134107
--cfg-scale 1 --steps 1
135108
```
109+
Both options: ``` --cfg-scale 1 ``` and ``` --steps 1 ``` are mandatory here.
110+
111+
### SDXS-512-0.9
112+
113+
Even though the name "SDXS-512-0.9" is similar to "SDXS-512-DreamShaper", it is *completely different* but also **incredibly fast**. Sometimes it is preferred, so try it yourself.
114+
##### Download a ready-to-run file from here:
115+
116+
* https://huggingface.co/akleine/sdxs-09
136117

137-
Both options: ``` --cfg-scale 1 ``` and ``` --steps 1 ``` are mandatory here.
118+
For the use of this model, both options ``` --cfg-scale 1 ``` and ``` --steps 1 ``` are again absolutely necessary.

docs/ernie_image.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# How to Use
2+
3+
You can run ERNIE-Image with stable-diffusion.cpp on GPUs with 4GB of VRAM — or even less.
4+
5+
## Download weights
6+
7+
- Download ERNIE-Image-Turbo
8+
- safetensors: https://huggingface.co/Comfy-Org/ERNIE-Image/tree/main/diffusion_models
9+
- gguf: https://huggingface.co/unsloth/ERNIE-Image-Turbo-GGUF/tree/main
10+
- Download ERNIE-Image
11+
- safetensors: https://huggingface.co/Comfy-Org/ERNIE-Image/tree/main/diffusion_models
12+
- gguf: https://huggingface.co/unsloth/ERNIE-Image-GGUF/tree/main
13+
- Download vae
14+
- safetensors: https://huggingface.co/Comfy-Org/ERNIE-Image/tree/main/vae
15+
- Download ministral 3b
16+
- safetensors: https://huggingface.co/Comfy-Org/ERNIE-Image/tree/main/text_encoders
17+
- gguf: https://huggingface.co/unsloth/Ministral-3-3B-Instruct-2512-GGUF/tree/main
18+
19+
## Examples
20+
21+
### ERNIE-Image-Turbo
22+
23+
```
24+
.\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\ernie-image-turbo.safetensors --vae ..\..\ComfyUI\models\vae\flux2_ae.safetensors --llm ..\..\ComfyUI\models\text_encoders\ministral-3-3b.safetensors -p "a lovely cat" --cfg-scale 1.0 --steps 8 -v --offload-to-cpu --diffusion-fa
25+
```
26+
27+
<img width="256" alt="ERNIE-Image Turbo example" src="../assets/ernie_image/turbo_example.png" />
28+
29+
### ERNIE-Image
30+
31+
```
32+
.\bin\Release\sd-cli.exe --diffusion-model ..\..\ComfyUI\models\diffusion_models\ernie-image-UD-Q4_K_M.gguf --vae ..\..\ComfyUI\models\vae\flux2_ae.safetensors --llm ..\..\ComfyUI\models\text_encoders\ministral-3-3b.safetensors -p "a lovely cat" --cfg-scale 5.0 -v --offload-to-cpu --diffusion-fa
33+
```
34+
35+
<img width="256" alt="ERNIE-Image example" src="../assets/ernie_image/example.png" />

0 commit comments

Comments
 (0)