aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-10 15:58:53 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-08-10 15:58:53 +0300
commit1b3093fe3aedb20aa8d505ceeea7900ac592e6fe (patch)
tree6493d911a9771da6dba7729fad76663542523aee /modules
parent4d93f48f090e19a81d1608837e8e6449045601a8 (diff)
fix --use-textbox-seed
Diffstat (limited to 'modules')
-rw-r--r--modules/processing.py12
-rw-r--r--modules/ui.py6
-rw-r--r--modules/ui_loadsave.py5
3 files changed, 19 insertions, 4 deletions
diff --git a/modules/processing.py b/modules/processing.py
index 68a8f1c6..f06c374a 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -521,7 +521,15 @@ def decode_latent_batch(model, batch, target_device=None, check_for_nans=False):
def get_fixed_seed(seed):
- if seed is None or seed == '' or seed == -1:
+ if seed == '' or seed is None:
+ seed = -1
+ elif isinstance(seed, str):
+ try:
+ seed = int(seed)
+ except Exception:
+ seed = -1
+
+ if seed == -1:
return int(random.randrange(4294967294))
return seed
@@ -728,7 +736,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
# strength, which is saved as "Model Strength: 1.0" in the infotext
if n == 0:
with open(os.path.join(paths.data_path, "params.txt"), "w", encoding="utf8") as file:
- processed = Processed(p, [], p.seed, "")
+ processed = Processed(p, [])
file.write(processed.infotext(p, 0))
p.setup_conds()
diff --git a/modules/ui.py b/modules/ui.py
index b87e95a6..e7433cbd 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -144,7 +144,11 @@ def interrogate_deepbooru(image):
def create_seed_inputs(target_interface):
with FormRow(elem_id=f"{target_interface}_seed_row", variant="compact"):
- seed = (gr.Textbox if cmd_opts.use_textbox_seed else gr.Number)(label='Seed', value=-1, elem_id=f"{target_interface}_seed")
+ if cmd_opts.use_textbox_seed:
+ seed = gr.Textbox(label='Seed', value="", elem_id=f"{target_interface}_seed")
+ else:
+ seed = gr.Number(label='Seed', value=-1, elem_id=f"{target_interface}_seed")
+
random_seed = ToolButton(random_symbol, elem_id=f"{target_interface}_random_seed", label='Random seed')
reuse_seed = ToolButton(reuse_symbol, elem_id=f"{target_interface}_reuse_seed", label='Reuse seed')
diff --git a/modules/ui_loadsave.py b/modules/ui_loadsave.py
index 0052a5cc..99d763e1 100644
--- a/modules/ui_loadsave.py
+++ b/modules/ui_loadsave.py
@@ -8,7 +8,7 @@ from modules.ui_components import ToolButton
class UiLoadsave:
- """allows saving and restorig default values for gradio components"""
+ """allows saving and restoring default values for gradio components"""
def __init__(self, filename):
self.filename = filename
@@ -48,6 +48,9 @@ class UiLoadsave:
elif condition and not condition(saved_value):
pass
else:
+ if isinstance(x, gr.Textbox) and field == 'value': # due to an undersirable behavior of gr.Textbox, if you give it an int value instead of str, everything dies
+ saved_value = str(saved_value)
+
setattr(obj, field, saved_value)
if init_field is not None:
init_field(saved_value)