-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The default name of stable_diffusion sampler_index has been changed #4717
Comments
Hey @BillDowney, I'm here to help you with any bugs, questions, or contributions you might have for the repository. Let's work together to solve this issue. To resolve the issue with the
Here is the modified code: # Remove 'sampler_index' from DRAW_TEXT_OPTIONS
DRAW_TEXT_OPTIONS = {
"prompt": "",
"negative_prompt": "",
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"batch_size": 1,
"n_iter": 1,
"steps": 10,
"cfg_scale": 7,
"width": 1024,
"height": 1024,
"restore_faces": False,
"do_not_save_samples": False,
"do_not_save_grid": False,
"eta": 0,
"denoising_strength": 0,
"s_min_uncond": 0,
"s_churn": 0,
"s_tmax": 0,
"s_tmin": 0,
"s_noise": 0,
"override_settings": {},
"override_settings_restore_afterwards": True,
"refiner_switch_at": 0,
"disable_extra_networks": False,
"comments": {},
"enable_hr": False,
"firstphase_width": 0,
"firstphase_height": 0,
"hr_scale": 2,
"hr_second_pass_steps": 0,
"hr_resize_x": 0,
"hr_resize_y": 0,
"hr_prompt": "",
"hr_negative_prompt": "",
"script_args": [],
"send_images": True,
"save_images": False,
"alwayson_scripts": {}
}
# Modify the text2img method to handle empty sampler_name
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]]:
"""
generate image
"""
# copy draw options
draw_options = deepcopy(DRAW_TEXT_OPTIONS)
if lora:
draw_options['prompt'] = f'{lora},{prompt}'
else:
draw_options['prompt'] = prompt
draw_options['width'] = width
draw_options['height'] = height
draw_options['steps'] = steps
draw_options['negative_prompt'] = negative_prompt
draw_options['override_settings']['sd_model_checkpoint'] = model
# Ensure sampler_name is not set if empty
if 'sampler_name' in draw_options and not draw_options['sampler_name']:
del draw_options['sampler_name']
try:
url = str(URL(base_url) / 'sdapi' / 'v1' / 'txt2img')
response = post(url, data=json.dumps(draw_options), timeout=120)
if response.status_code != 200:
return self.create_text_message('Failed to generate image')
image = response.json()['images'][0]
return self.create_blob_message(blob=b64decode(image),
meta={ 'mime_type': 'image/png' },
save_as=self.VARIABLE_KEY.IMAGE.value)
except Exception as e:
return self.create_text_message('Failed to generate image') This modification ensures that the
|
Self Checks
Dify version
0.6.9
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
DRAW_TEXT_OPTIONS.sampler_index in the stable_diffuse.py file, where the default name is "DPM++ SDE Karras", However, the sd webui has changed its default name to "DPM++ SDE" in the last 2024.3.24 commit record, so the api access has been unsuccessful.
It is recommended to remove the sampler_index key and use the default sd value when passing empty values
✔️ Expected Behavior
The sd tool should be called successfully
❌ Actual Behavior
sd tool call should fail
The text was updated successfully, but these errors were encountered: