Skip to content

Commit 3eaa6e5

Browse files
committed
feat(models): add support to qwen-image
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 7e2a522 commit 3eaa6e5

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

backend/python/diffusers/backend.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ def sc(self, clip_input, images): return images, [False for i in images]
6565
UniPCMultistepScheduler,
6666
)
6767

68+
def is_float(s):
69+
try:
70+
float(s)
71+
return True
72+
except ValueError:
73+
return False
74+
75+
def is_int(s):
76+
try:
77+
int(s)
78+
return True
79+
except ValueError:
80+
return False
6881

6982
# The scheduler list mapping was taken from here: https://github.com/neggles/animatediff-cli/blob/6f336f5f4b5e38e85d7f06f1744ef42d0a45f2a7/src/animatediff/schedulers.py#L39
7083
# Credits to https://github.com/neggles
@@ -169,8 +182,24 @@ def LoadModel(self, request, context):
169182
if ":" not in opt:
170183
continue
171184
key, value = opt.split(":")
185+
# if value is a number, convert it to the appropriate type
186+
if is_float(value):
187+
value = float(value)
188+
elif is_int(value):
189+
value = int(value)
172190
self.options[key] = value
173191

192+
# From options, extract if present "torch_dtype" and set it to the appropriate type
193+
if "torch_dtype" in self.options:
194+
if self.options["torch_dtype"] == "fp16":
195+
torchType = torch.float16
196+
elif self.options["torch_dtype"] == "bf16":
197+
torchType = torch.bfloat16
198+
elif self.options["torch_dtype"] == "fp32":
199+
torchType = torch.float32
200+
# remove it from options
201+
del self.options["torch_dtype"]
202+
174203
print(f"Options: {self.options}", file=sys.stderr)
175204

176205
local = False

gallery/index.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
---
2+
- &qwenimage
3+
name: "qwen-image"
4+
url: "github:mudler/LocalAI/gallery/qwen-image.yaml@master"
5+
urls:
6+
- https://huggingface.co/Qwen/Qwen-Image
7+
icon: https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Image/qwen_image_logo.png
8+
license: apache-2.0
9+
tags:
10+
- qwen-image
11+
- gpu
12+
- text-to-image
13+
description: |
14+
We are thrilled to release Qwen-Image, an image generation foundation model in the Qwen series that achieves significant advances in complex text rendering and precise image editing. Experiments show strong general capabilities in both image generation and editing, with exceptional performance in text rendering, especially for Chinese.
215
- &gptoss
316
name: "gpt-oss-20b"
417
url: "github:mudler/LocalAI/gallery/harmony.yaml@master"

gallery/qwen-image.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: "flux"
3+
4+
config_file: |
5+
backend: diffusers
6+
cfg_scale: 0
7+
diffusers:
8+
cuda: true
9+
enable_parameters: num_inference_steps
10+
pipeline_type: DiffusionPipeline
11+
f16: true
12+
low_vram: true
13+
name: qwen-image
14+
parameters:
15+
model: Qwen/Qwen-Image
16+
step: 50
17+
options:
18+
- true_cfg_scale:4.0
19+
- torch_dtype:bf16

0 commit comments

Comments
 (0)