Have upscale button use the same seed as hires fix.

This commit is contained in:
AUTOMATIC1111
2024-01-04 19:47:00 +03:00
parent f903b4dda3
commit 15ec54dd96
5 changed files with 53 additions and 20 deletions

View File

@@ -91,6 +91,9 @@ class Script:
setup_for_ui_only = False
"""If true, the script setup will only be run in Gradio UI, not in API"""
controls = None
"""A list of controls retured by the ui()."""
def title(self):
"""this function should return the title of the script. This is what will be displayed in the dropdown menu."""
@@ -624,6 +627,7 @@ class ScriptRunner:
import modules.api.models as api_models
controls = wrap_call(script.ui, script.filename, "ui", script.is_img2img)
script.controls = controls
if controls is None:
return
@@ -918,6 +922,23 @@ class ScriptRunner:
except Exception:
errors.report(f"Error running setup: {script.filename}", exc_info=True)
def set_named_arg(self, args, script_type, arg_elem_id, value):
script = next((x for x in self.scripts if type(x).__name__ == script_type), None)
if script is None:
return
for i, control in enumerate(script.controls):
if arg_elem_id in control.elem_id:
index = script.args_from + i
if isinstance(args, list):
args[index] = value
return args
elif isinstance(args, tuple):
return args[:index] + (value,) + args[index+1:]
else:
return None
scripts_txt2img: ScriptRunner = None
scripts_img2img: ScriptRunner = None