steps default

This commit is contained in:
tami-p40 2024-06-09 11:33:02 +03:00
parent 9f8bff3540
commit 8fd4b07559

37
main.py
View File

@ -28,17 +28,6 @@ IMAGE_PATH = 'images'
# Ensure IMAGE_PATH directory exists
os.makedirs(IMAGE_PATH, exist_ok=True)
# Model-specific embeddings for negative prompts
model_negative_prompts = {
"coloringPage_v10": "fake",
"Anything-Diffusion": "",
"Deliberate": "",
"Dreamshaper": "",
"DreamShaperXL_Lightning": "",
"realisticVisionV60B1_v51VAE": "realisticvision-negative-embedding",
"v1-5-pruned-emaonly": "",
"Juggernaut-XL_v9_RunDiffusionPhoto_v2": "bad eyes, cgi, airbrushed, plastic, watermark"
}
def get_current_model_name():
try:
@ -85,11 +74,24 @@ default_payload = {
"override_settings_restore_afterwards": True,
}
# Model-specific embeddings for negative prompts
model_negative_prompts = {
"coloringPage_v10": "fake",
"Anything-Diffusion": "",
"Deliberate": "",
"Dreamshaper": "",
"DreamShaperXL_Lightning": "",
"realisticVisionV60B1_v51VAE": "realisticvision-negative-embedding",
"v1-5-pruned-emaonly": "",
"Juggernaut-XL_v9_RunDiffusionPhoto_v2": "bad eyes, cgi, airbrushed, plastic, watermark"
}
def update_negative_prompt(model_name):
"""Update the negative prompt for a given model."""
if model_name in model_negative_prompts:
suffix = model_negative_prompts[model_name]
default_payload["negative_prompt"] += f", {suffix}"
print(f"Updated negative prompt to: {default_payload['negative_prompt']}")
def update_resolution(model_name):
"""Update resolution based on the selected model."""
@ -99,6 +101,15 @@ def update_resolution(model_name):
else:
default_payload["width"] = 512
default_payload["height"] = 512
print(f"Updated resolution to {default_payload['width']}x{default_payload['height']}")
def update_steps(model_name):
"""Update CFG scale based on the selected model."""
if model_name == "Juggernaut-XL_v9_RunDiffusionPhoto_v2":
default_payload["steps"] = 15
else:
default_payload["steps"] = 35
print(f"Updated steps to {default_payload['cfg_scale']}")
def update_cfg_scale(model_name):
"""Update CFG scale based on the selected model."""
@ -106,12 +117,14 @@ def update_cfg_scale(model_name):
default_payload["cfg_scale"] = 2.5
else:
default_payload["cfg_scale"] = 7
print(f"Updated CFG scale to {default_payload['cfg_scale']}")
# Update configurations based on the current model name
if current_model_name:
update_negative_prompt(current_model_name)
update_resolution(current_model_name)
update_cfg_scale(current_model_name)
update_steps(current_model_name)
else:
print("Failed to update configurations as the current model name is not available.")
@ -187,7 +200,7 @@ def parse_input(input_string):
if script_name:
payload["script_name"] = script_name
payload["script_args"] = script_args
print(f"Generated payload: {payload}")
return payload, include_info
def create_caption(payload, user_name, user_id, info, include_info):