mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-06 15:15:05 +08:00
fix --use-textbox-seed
This commit is contained in:
parent
4d93f48f09
commit
1b3093fe3a
@ -521,7 +521,15 @@ def decode_latent_batch(model, batch, target_device=None, check_for_nans=False):
|
|||||||
|
|
||||||
|
|
||||||
def get_fixed_seed(seed):
|
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 int(random.randrange(4294967294))
|
||||||
|
|
||||||
return seed
|
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
|
# strength, which is saved as "Model Strength: 1.0" in the infotext
|
||||||
if n == 0:
|
if n == 0:
|
||||||
with open(os.path.join(paths.data_path, "params.txt"), "w", encoding="utf8") as file:
|
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))
|
file.write(processed.infotext(p, 0))
|
||||||
|
|
||||||
p.setup_conds()
|
p.setup_conds()
|
||||||
|
@ -144,7 +144,11 @@ def interrogate_deepbooru(image):
|
|||||||
|
|
||||||
def create_seed_inputs(target_interface):
|
def create_seed_inputs(target_interface):
|
||||||
with FormRow(elem_id=f"{target_interface}_seed_row", variant="compact"):
|
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')
|
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')
|
reuse_seed = ToolButton(reuse_symbol, elem_id=f"{target_interface}_reuse_seed", label='Reuse seed')
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from modules.ui_components import ToolButton
|
|||||||
|
|
||||||
|
|
||||||
class UiLoadsave:
|
class UiLoadsave:
|
||||||
"""allows saving and restorig default values for gradio components"""
|
"""allows saving and restoring default values for gradio components"""
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
@ -48,6 +48,9 @@ class UiLoadsave:
|
|||||||
elif condition and not condition(saved_value):
|
elif condition and not condition(saved_value):
|
||||||
pass
|
pass
|
||||||
else:
|
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)
|
setattr(obj, field, saved_value)
|
||||||
if init_field is not None:
|
if init_field is not None:
|
||||||
init_field(saved_value)
|
init_field(saved_value)
|
||||||
|
Loading…
Reference in New Issue
Block a user