Skip to content

Commit d3a7eb7

Browse files
feat: add Ovis support, update submodule
1 parent a07fa26 commit d3a7eb7

5 files changed

Lines changed: 103 additions & 3 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,36 @@ output = stable_diffusion.generate_image(
686686
687687
---
688688
689+
### <u>Ovis</u>
690+
691+
Download the weights from the links below:
692+
693+
- Download `Ovis-Image-7B`
694+
- safetensors: https://huggingface.co/Comfy-Org/Ovis-Image/tree/main/split_files/diffusion_models
695+
- gguf: https://huggingface.co/leejet/Ovis-Image-7B-GGUF
696+
- Download `vae`
697+
- safetensors: https://huggingface.co/black-forest-labs/FLUX.1-schnell/tree/main
698+
- Download `Ovis 2.5`
699+
- safetensors: https://huggingface.co/Comfy-Org/Ovis-Image/tree/main/split_files/text_encoders
700+
701+
```python
702+
from stable_diffusion_cpp import StableDiffusion
703+
704+
stable_diffusion = StableDiffusion(
705+
diffusion_model_path="../models/ovis_image-Q4_0.gguf",
706+
llm_path="../models/ovis_2.5.safetensors",
707+
vae_path="../models/ae.safetensors",
708+
diffusion_flash_attn=True,
709+
)
710+
711+
output = stable_diffusion.generate_image(
712+
prompt="a lovely cat",
713+
cfg_scale=5.0,
714+
)
715+
```
716+
717+
---
718+
689719
### <u>Wan Video Generation</u>
690720
691721
See [stable-diffusion.cpp Wan download weights](https://github.com/leejet/stable-diffusion.cpp/blob/master/docs/wan.md#download-weights) for a complete list of Wan models.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ sdist.include = [
5454
sdist.exclude = [
5555
"assets",
5656
"vendor/stable-diffusion.cpp/assets",
57-
# Exclude ALL objects
5857
".git/objects/**",
5958
"vendor/stable-diffusion.cpp/.git/objects/**",
6059
".git/logs/**",

tests/test_ovis.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from PIL import PngImagePlugin
2+
from conftest import OUTPUT_DIR
3+
4+
from stable_diffusion_cpp import StableDiffusion
5+
6+
DIFFUSION_MODEL_PATH = "F:\\stable-diffusion\\ovis\\ovis_image-Q4_0.gguf"
7+
LLM_PATH = "F:\\stable-diffusion\\ovis\\ovis_2.5.safetensors"
8+
VAE_PATH = "F:\\stable-diffusion\\ovis\\ae.safetensors"
9+
10+
PROMPT = "a lovely cat"
11+
STEPS = 20
12+
CFG_SCALE = 5.0
13+
14+
15+
def test_ovis():
16+
17+
stable_diffusion = StableDiffusion(
18+
diffusion_model_path=DIFFUSION_MODEL_PATH,
19+
llm_path=LLM_PATH,
20+
vae_path=VAE_PATH,
21+
diffusion_flash_attn=True,
22+
)
23+
24+
def progress_callback(step: int, steps: int, time: float):
25+
print("Completed step: {} of {}".format(step, steps))
26+
27+
# Generate image
28+
image = stable_diffusion.generate_image(
29+
prompt=PROMPT,
30+
sample_steps=STEPS,
31+
cfg_scale=CFG_SCALE,
32+
progress_callback=progress_callback,
33+
)[0]
34+
35+
# Save image
36+
pnginfo = PngImagePlugin.PngInfo()
37+
pnginfo.add_text("Parameters", ", ".join([f"{k.replace('_', ' ').title()}: {v}" for k, v in image.info.items()]))
38+
image.save(f"{OUTPUT_DIR}/ovis.png", pnginfo=pnginfo)
39+
40+
41+
# ===========================================
42+
# C++ CLI
43+
# ===========================================
44+
45+
# import subprocess
46+
47+
# from conftest import SD_CPP_CLI
48+
49+
# stable_diffusion = None # Clear model
50+
51+
# cli_cmd = [
52+
# SD_CPP_CLI,
53+
# "--diffusion-model",
54+
# DIFFUSION_MODEL_PATH,
55+
# "--llm",
56+
# LLM_PATH,
57+
# "--vae",
58+
# VAE_PATH,
59+
# "--prompt",
60+
# PROMPT,
61+
# "--steps",
62+
# str(STEPS),
63+
# "--cfg-scale",
64+
# str(CFG_SCALE),
65+
# "--diffusion-fa",
66+
# "--output",
67+
# f"{OUTPUT_DIR}/ovis_cli.png",
68+
# "-v",
69+
# ]
70+
# print(" ".join(cli_cmd))
71+
# subprocess.run(cli_cmd, check=True)

tests/tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ pytest -s
33
```
44

55
```bash
6-
pytest tests\test_txt2img.py -s; pytest tests\test_controlnet.py -s; pytest tests\test_convert_model.py -s; pytest tests\test_flux.py -s; pytest tests\test_img2img.py -s; pytest tests\test_preprocess_canny.py -s; pytest tests\test_system_info.py -s; pytest tests\test_list_maps.py -s; pytest tests\test_upscale.py -s; pytest tests\test_photomaker.py -s; pytest tests\test_photomaker_2.py -s; pytest tests\test_inpainting.py -s; pytest tests\test_chroma.py -s; pytest tests\test_edit.py -s; pytest tests/test_sd3.py -s; pytest tests\test_vid.py -s; pytest tests\test_vid_vace.py -s; pytest tests\test_multi_gpu.py -s; pytest tests\test_flex2.py -s; pytest tests\test_memory_leak.py -s; pytest tests\test_qwen_image.py -s; pytest tests\test_qwen_image_edit.py -s; pytest tests\test_z_image.py -s; pytest tests\test_flux2.py -s;
6+
pytest tests\test_txt2img.py -s; pytest tests\test_controlnet.py -s; pytest tests\test_convert_model.py -s; pytest tests\test_flux.py -s; pytest tests\test_img2img.py -s; pytest tests\test_preprocess_canny.py -s; pytest tests\test_system_info.py -s; pytest tests\test_list_maps.py -s; pytest tests\test_upscale.py -s; pytest tests\test_photomaker.py -s; pytest tests\test_photomaker_2.py -s; pytest tests\test_inpainting.py -s; pytest tests\test_chroma.py -s; pytest tests\test_edit.py -s; pytest tests/test_sd3.py -s; pytest tests\test_vid.py -s; pytest tests\test_vid_vace.py -s; pytest tests\test_multi_gpu.py -s; pytest tests\test_flex2.py -s; pytest tests\test_memory_leak.py -s; pytest tests\test_qwen_image.py -s; pytest tests\test_qwen_image_edit.py -s; pytest tests\test_z_image.py -s; pytest tests\test_ovis.py -s; pytest tests\test_flux2.py -s;
77
```

0 commit comments

Comments
 (0)