mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 18:19:00 +08:00
enhance: use override_settings for concurrent stable diffusion (#2818)
This commit is contained in:
parent
4fe585acc2
commit
1e5455e266
@ -131,7 +131,8 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
negative_prompt=negative_prompt,
|
negative_prompt=negative_prompt,
|
||||||
width=width,
|
width=width,
|
||||||
height=height,
|
height=height,
|
||||||
steps=steps)
|
steps=steps,
|
||||||
|
model=model)
|
||||||
|
|
||||||
return self.text2img(base_url=base_url,
|
return self.text2img(base_url=base_url,
|
||||||
lora=lora,
|
lora=lora,
|
||||||
@ -139,7 +140,8 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
negative_prompt=negative_prompt,
|
negative_prompt=negative_prompt,
|
||||||
width=width,
|
width=width,
|
||||||
height=height,
|
height=height,
|
||||||
steps=steps)
|
steps=steps,
|
||||||
|
model=model)
|
||||||
|
|
||||||
def validate_models(self) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
def validate_models(self) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||||
"""
|
"""
|
||||||
@ -197,7 +199,7 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
|
|
||||||
def img2img(self, base_url: str, lora: str, image_binary: bytes,
|
def img2img(self, base_url: str, lora: str, image_binary: bytes,
|
||||||
prompt: str, negative_prompt: str,
|
prompt: str, negative_prompt: str,
|
||||||
width: int, height: int, steps: int) \
|
width: int, height: int, steps: int, model: str) \
|
||||||
-> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
-> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||||
"""
|
"""
|
||||||
generate image
|
generate image
|
||||||
@ -213,7 +215,8 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
"sampler_name": "Euler a",
|
"sampler_name": "Euler a",
|
||||||
"restore_faces": False,
|
"restore_faces": False,
|
||||||
"steps": steps,
|
"steps": steps,
|
||||||
"script_args": ["outpainting mk2"]
|
"script_args": ["outpainting mk2"],
|
||||||
|
"override_settings": {"sd_model_checkpoint": model}
|
||||||
}
|
}
|
||||||
|
|
||||||
if lora:
|
if lora:
|
||||||
@ -236,7 +239,7 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return self.create_text_message('Failed to generate image')
|
return self.create_text_message('Failed to generate image')
|
||||||
|
|
||||||
def text2img(self, base_url: str, lora: str, prompt: str, negative_prompt: str, width: int, height: int, steps: int) \
|
def text2img(self, base_url: str, lora: str, prompt: str, negative_prompt: str, width: int, height: int, steps: int, model: str) \
|
||||||
-> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
-> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||||
"""
|
"""
|
||||||
generate image
|
generate image
|
||||||
@ -253,6 +256,7 @@ class StableDiffusionTool(BuiltinTool):
|
|||||||
draw_options['height'] = height
|
draw_options['height'] = height
|
||||||
draw_options['steps'] = steps
|
draw_options['steps'] = steps
|
||||||
draw_options['negative_prompt'] = negative_prompt
|
draw_options['negative_prompt'] = negative_prompt
|
||||||
|
draw_options['override_settings']['sd_model_checkpoint'] = model
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = str(URL(base_url) / 'sdapi' / 'v1' / 'txt2img')
|
url = str(URL(base_url) / 'sdapi' / 'v1' / 'txt2img')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user