diff --git a/launch.py b/launch.py
index a8c156b8c..00adf4475 100755
--- a/launch.py
+++ b/launch.py
@@ -47,6 +47,16 @@ def get_custom_args():
if current != default:
custom[arg] = getattr(args, arg)
installer.log.info(f'Command line args: {sys.argv[1:]} {installer.print_dict(custom)}')
+ if os.environ.get('SD_ENV_DEBUG', None) is not None:
+ env = os.environ.copy()
+ if 'PATH' in env:
+ del env['PATH']
+ if 'PS1' in env:
+ del env['PS1']
+ installer.log.trace(f'Environment: {installer.print_dict(env)}')
+ else:
+ env = [f'{k}={v}' for k, v in os.environ.items() if k.startswith('SD_')]
+ installer.log.debug(f'Env flags: {env}')
@lru_cache()
diff --git a/modules/hypernetworks/ui.py b/modules/hypernetworks/ui.py
index 2d6acbafb..c8b6cd5c3 100644
--- a/modules/hypernetworks/ui.py
+++ b/modules/hypernetworks/ui.py
@@ -23,8 +23,8 @@ Training {'interrupted' if shared.state.interrupted else 'finished'} at {hyperne
Hypernetwork saved to {html.escape(filename)}
"""
return res, ""
- except Exception:
- raise
+ except Exception as e:
+ raise RuntimeError("Hypernetwork error") from e
finally:
shared.sd_model.cond_stage_model.to(devices.device)
shared.sd_model.first_stage_model.to(devices.device)
diff --git a/modules/processing.py b/modules/processing.py
index 41857ea3c..7710117fe 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -11,7 +11,7 @@ from dataclasses import dataclass, field
import torch
import numpy as np
import cv2
-from PIL import Image, ImageFilter, ImageOps
+from PIL import Image, ImageOps
from skimage import exposure
from ldm.data.util import AddMiDaS
from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion
diff --git a/modules/ui.py b/modules/ui.py
index ac328469f..f8de15f4e 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -9,41 +9,32 @@ import gradio.utils
import numpy as np
from PIL import Image
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call
-
-from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, ui_loadsave, ui_train, ui_models, ui_control, ui_interrogate, modelloader
+from modules import timer, shared, theme, sd_models, script_callbacks, modelloader, prompt_parser, ui_common, ui_loadsave, ui_symbols, generation_parameters_copypaste
from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML
from modules.paths import script_path, data_path
-from modules.shared import opts, cmd_opts
from modules.dml import directml_override_opts
-from modules import prompt_parser
-from modules import timer
-import modules.ui_symbols as symbols
-import modules.generation_parameters_copypaste as parameters_copypaste
-import modules.hypernetworks.ui
import modules.scripts
-import modules.shared
-import modules.errors
-import modules.styles
-import modules.extras
-import modules.theme
import modules.textual_inversion.ui
-import modules.sd_samplers
+import modules.hypernetworks.ui
+import modules.errors
modules.errors.install()
mimetypes.init()
mimetypes.add_type('application/javascript', '.js')
-log = modules.shared.log
+log = shared.log
+opts = shared.opts
+cmd_opts = shared.cmd_opts
ui_system_tabs = None
-switch_values_symbol = symbols.switch
-detect_image_size_symbol = symbols.detect
-paste_symbol = symbols.paste
-clear_prompt_symbol = symbols.clear
-restore_progress_symbol = symbols.apply
-folder_symbol = symbols.folder
-extra_networks_symbol = symbols.networks
-apply_style_symbol = symbols.apply
-save_style_symbol = symbols.save
+switch_values_symbol = ui_symbols.switch
+detect_image_size_symbol = ui_symbols.detect
+paste_symbol = ui_symbols.paste
+clear_prompt_symbol = ui_symbols.clear
+restore_progress_symbol = ui_symbols.apply
+folder_symbol = ui_symbols.folder
+extra_networks_symbol = ui_symbols.networks
+apply_style_symbol = ui_symbols.apply
+save_style_symbol = ui_symbols.save
txt2img_paste_fields = []
img2img_paste_fields = []
txt2img_args = []
@@ -77,16 +68,17 @@ def infotext_to_html(text): # may be referenced by extensions
def send_gradio_gallery_to_image(x):
if len(x) == 0:
return None
- return parameters_copypaste.image_from_url_text(x[0])
+ return generation_parameters_copypaste.image_from_url_text(x[0])
def add_style(name: str, prompt: str, negative_prompt: str):
+ from modules import styles
if name is None:
return [gr_show() for x in range(4)]
- style = modules.styles.Style(name, prompt, negative_prompt)
- modules.shared.prompt_styles.styles[style.name] = style
- modules.shared.prompt_styles.save_styles(modules.shared.opts.styles_dir)
- return [gr.Dropdown.update(visible=True, choices=list(modules.shared.prompt_styles.styles)) for _ in range(2)]
+ style = styles.Style(name, prompt, negative_prompt)
+ shared.prompt_styles.styles[style.name] = style
+ shared.prompt_styles.save_styles(shared.opts.styles_dir)
+ return [gr.Dropdown.update(visible=True, choices=list(shared.prompt_styles.styles)) for _ in range(2)]
def calc_resolution_hires(width, height, hr_scale, hr_resize_x, hr_resize_y, hr_upscaler):
@@ -109,8 +101,8 @@ def resize_from_to_html(width, height, scale_by):
def apply_styles(prompt, prompt_neg, styles):
- prompt = modules.shared.prompt_styles.apply_styles_to_prompt(prompt, styles)
- prompt_neg = modules.shared.prompt_styles.apply_negative_styles_to_prompt(prompt_neg, styles)
+ prompt = shared.prompt_styles.apply_styles_to_prompt(prompt, styles)
+ prompt_neg = shared.prompt_styles.apply_negative_styles_to_prompt(prompt_neg, styles)
return [gr.Textbox.update(value=prompt), gr.Textbox.update(value=prompt_neg), gr.Dropdown.update(value=[])]
@@ -130,7 +122,7 @@ def process_interrogate(interrogation_function, mode, ii_input_files, ii_input_d
if not os.path.isdir(ii_input_dir):
log.error(f"Interrogate: Input directory not found: {ii_input_dir}")
return [gr.update(), None]
- images = modules.shared.listfiles(ii_input_dir)
+ images = shared.listfiles(ii_input_dir)
if ii_output_dir != "":
os.makedirs(ii_output_dir, exist_ok=True)
else:
@@ -147,11 +139,12 @@ def interrogate(image):
if image is None:
log.error("Interrogate: no image selected")
return gr.update()
- prompt = modules.shared.interrogator.interrogate(image.convert("RGB"))
+ prompt = shared.interrogator.interrogate(image.convert("RGB"))
return gr.update() if prompt is None else prompt
def interrogate_deepbooru(image):
+ from modules import deepbooru
prompt = deepbooru.model.tag(image)
return gr.update() if prompt is None else prompt
@@ -161,7 +154,7 @@ def create_batch_inputs(tab):
with FormRow(elem_id=f"{tab}_row_batch"):
batch_count = gr.Slider(minimum=1, step=1, label='Batch count', value=1, elem_id=f"{tab}_batch_count")
batch_size = gr.Slider(minimum=1, maximum=32, step=1, label='Batch size', value=1, elem_id=f"{tab}_batch_size")
- batch_switch_btn = ToolButton(value=symbols.switch, elem_id=f"{tab}_batch_switch_btn", label="Switch dims")
+ batch_switch_btn = ToolButton(value=ui_symbols.switch, elem_id=f"{tab}_batch_switch_btn", label="Switch dims")
batch_switch_btn.click(lambda w, h: (h, w), inputs=[batch_count, batch_size], outputs=[batch_count, batch_size], show_progress=False)
return batch_count, batch_size
@@ -170,12 +163,12 @@ def create_seed_inputs(tab, reuse_visible=True):
with gr.Accordion(open=False, label="Seed", elem_id=f"{tab}_seed_group", elem_classes=["small-accordion"]):
with FormRow(elem_id=f"{tab}_seed_row", variant="compact"):
seed = gr.Number(label='Initial seed', value=-1, elem_id=f"{tab}_seed", container=True)
- random_seed = ToolButton(symbols.random, elem_id=f"{tab}_random_seed", label='Random seed')
- reuse_seed = ToolButton(symbols.reuse, elem_id=f"{tab}_reuse_seed", label='Reuse seed', visible=reuse_visible)
+ random_seed = ToolButton(ui_symbols.random, elem_id=f"{tab}_random_seed", label='Random seed')
+ reuse_seed = ToolButton(ui_symbols.reuse, elem_id=f"{tab}_reuse_seed", label='Reuse seed', visible=reuse_visible)
with FormRow(visible=True, elem_id=f"{tab}_subseed_row", variant="compact"):
subseed = gr.Number(label='Variation', value=-1, elem_id=f"{tab}_subseed", container=True)
- random_subseed = ToolButton(symbols.random, elem_id=f"{tab}_random_subseed")
- reuse_subseed = ToolButton(symbols.reuse, elem_id=f"{tab}_reuse_subseed", visible=reuse_visible)
+ random_subseed = ToolButton(ui_symbols.random, elem_id=f"{tab}_random_subseed")
+ reuse_subseed = ToolButton(ui_symbols.reuse, elem_id=f"{tab}_reuse_subseed", visible=reuse_visible)
subseed_strength = gr.Slider(label='Variation strength', value=0.0, minimum=0, maximum=1, step=0.01, elem_id=f"{tab}_subseed_strength")
with FormRow(visible=False):
seed_resize_from_w = gr.Slider(minimum=0, maximum=4096, step=8, label="Resize seed from width", value=0, elem_id=f"{tab}_seed_resize_from_w")
@@ -193,13 +186,13 @@ def create_advanced_inputs(tab):
clip_skip = gr.Slider(label='CLIP skip', value=1, minimum=1, maximum=14, step=1, elem_id=f"{tab}_clip_skip", interactive=True)
with FormRow():
image_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.1, label='Secondary CFG scale', value=6.0, elem_id=f"{tab}_image_cfg_scale")
- diffusers_guidance_rescale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Guidance rescale', value=0.7, elem_id=f"{tab}_image_cfg_rescale", visible=modules.shared.backend == modules.shared.Backend.DIFFUSERS)
+ diffusers_guidance_rescale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Guidance rescale', value=0.7, elem_id=f"{tab}_image_cfg_rescale", visible=shared.backend == shared.Backend.DIFFUSERS)
with gr.Group():
with FormRow():
full_quality = gr.Checkbox(label='Full quality', value=True, elem_id=f"{tab}_full_quality")
- restore_faces = gr.Checkbox(label='Face restore', value=False, visible=len(modules.shared.face_restorers) > 1, elem_id=f"{tab}_restore_faces")
- tiling = gr.Checkbox(label='Tiling', value=False, elem_id=f"{tab}_tiling", visible=modules.shared.backend == modules.shared.Backend.ORIGINAL)
- with gr.Group(visible=modules.shared.backend == modules.shared.Backend.DIFFUSERS):
+ restore_faces = gr.Checkbox(label='Face restore', value=False, visible=len(shared.face_restorers) > 1, elem_id=f"{tab}_restore_faces")
+ tiling = gr.Checkbox(label='Tiling', value=False, elem_id=f"{tab}_tiling", visible=shared.backend == shared.Backend.ORIGINAL)
+ with gr.Group(visible=shared.backend == shared.Backend.DIFFUSERS):
with FormRow():
hdr_clamp = gr.Checkbox(label='HDR clamp', value=False, elem_id=f"{tab}_hdr_clamp")
hdr_boundary = gr.Slider(minimum=0.0, maximum=10.0, step=0.1, value=4.0, label='Range', elem_id=f"{tab}_hdr_boundary")
@@ -219,10 +212,10 @@ def create_resize_inputs(tab, images, time_selector=False, scale_visible=True):
dummy_component = gr.Number(visible=False, value=0)
with gr.Accordion(open=False, label="Resize", elem_classes=["small-accordion"], elem_id=f"{tab}_resize_group"):
with gr.Row():
- resize_mode = gr.Radio(label="Resize mode", elem_id=f"{tab}_resize_mode", choices=modules.shared.resize_modes, type="index", value="None")
+ resize_mode = gr.Radio(label="Resize mode", elem_id=f"{tab}_resize_mode", choices=shared.resize_modes, type="index", value="None")
resize_time = gr.Radio(label="Resize order", elem_id=f"{tab}_resize_order", choices=['Before', 'After'], value="Before", visible=time_selector)
with gr.Row():
- resize_name = gr.Dropdown(label="Resize method", elem_id=f"{tab}_resize_name", choices=[x.name for x in modules.shared.sd_upscalers], value=opts.upscaler_for_img2img)
+ resize_name = gr.Dropdown(label="Resize method", elem_id=f"{tab}_resize_name", choices=[x.name for x in shared.sd_upscalers], value=opts.upscaler_for_img2img)
create_refresh_button(resize_name, modelloader.load_upscalers, lambda: {"choices": modelloader.load_upscalers()}, 'refresh_upscalers')
with FormRow(visible=True) as _resize_group:
@@ -235,9 +228,9 @@ def create_resize_inputs(tab, images, time_selector=False, scale_visible=True):
with FormRow():
width = gr.Slider(minimum=64, maximum=8192, step=8, label="Width", value=512, elem_id=f"{tab}_width")
height = gr.Slider(minimum=64, maximum=8192, step=8, label="Height", value=512, elem_id=f"{tab}_height")
- res_switch_btn = ToolButton(value=symbols.switch, elem_id=f"{tab}_res_switch_btn")
+ res_switch_btn = ToolButton(value=ui_symbols.switch, elem_id=f"{tab}_res_switch_btn")
res_switch_btn.click(lambda w, h: (h, w), inputs=[width, height], outputs=[width, height], show_progress=False)
- detect_image_size_btn = ToolButton(value=symbols.detect, elem_id=f"{tab}_detect_image_size_btn")
+ detect_image_size_btn = ToolButton(value=ui_symbols.detect, elem_id=f"{tab}_detect_image_size_btn")
detect_image_size_btn.click(fn=lambda w, h, _: (w or gr.update(), h or gr.update()), _js="currentImg2imgSourceResolution", inputs=[dummy_component, dummy_component, dummy_component], outputs=[width, height], show_progress=False)
with gr.Tab(label="Resize by") as tab_scale_by:
@@ -293,28 +286,28 @@ def connect_reuse_seed(seed: gr.Number, reuse_seed: gr.Button, generation_info:
def update_token_counter(text, steps):
+ from modules import extra_networks, sd_hijack
try:
text, _ = extra_networks.parse_prompt(text)
_, prompt_flat_list, _ = prompt_parser.get_multicond_prompt_list([text])
prompt_schedules = prompt_parser.get_learned_conditioning_prompt_schedules(prompt_flat_list, steps)
except Exception:
- # a parsing error can happen here during typing, and we don't want to bother the user with
- # messages related to it in console
prompt_schedules = [[[steps, text]]]
+
flat_prompts = reduce(lambda list1, list2: list1+list2, prompt_schedules)
prompts = [prompt_text for step, prompt_text in flat_prompts]
- if modules.shared.backend == modules.shared.Backend.ORIGINAL:
+ if shared.backend == shared.Backend.ORIGINAL:
token_count, max_length = max([sd_hijack.model_hijack.get_prompt_lengths(prompt) for prompt in prompts], key=lambda args: args[0])
- elif modules.shared.backend == modules.shared.Backend.DIFFUSERS:
- if modules.shared.sd_model is not None and hasattr(modules.shared.sd_model, 'tokenizer'):
- tokenizer = modules.shared.sd_model.tokenizer
+ elif shared.backend == shared.Backend.DIFFUSERS:
+ if shared.sd_model is not None and hasattr(shared.sd_model, 'tokenizer'):
+ tokenizer = shared.sd_model.tokenizer
if tokenizer is None:
token_count = 0
max_length = 75
else:
has_bos_token = tokenizer.bos_token_id is not None
has_eos_token = tokenizer.eos_token_id is not None
- ids = [modules.shared.sd_model.tokenizer(prompt) for prompt in prompts]
+ ids = [shared.sd_model.tokenizer(prompt) for prompt in prompts]
if len(ids) > 0 and hasattr(ids[0], 'input_ids'):
ids = [x.input_ids for x in ids]
token_count = max([len(x) for x in ids]) - int(has_bos_token) - int(has_eos_token)
@@ -349,11 +342,11 @@ def create_toprow(is_img2img: bool = False, id_part: str = None):
submit = gr.Button('Generate', elem_id=f"{id_part}_generate", variant='primary')
with gr.Row(elem_id=f"{id_part}_generate_line2"):
interrupt = gr.Button('Stop', elem_id=f"{id_part}_interrupt")
- interrupt.click(fn=lambda: modules.shared.state.interrupt(), _js="requestInterrupt", inputs=[], outputs=[])
+ interrupt.click(fn=lambda: shared.state.interrupt(), _js="requestInterrupt", inputs=[], outputs=[])
skip = gr.Button('Skip', elem_id=f"{id_part}_skip")
- skip.click(fn=lambda: modules.shared.state.skip(), inputs=[], outputs=[])
+ skip.click(fn=lambda: shared.state.skip(), inputs=[], outputs=[])
pause = gr.Button('Pause', elem_id=f"{id_part}_pause")
- pause.click(fn=lambda: modules.shared.state.pause(), _js='checkPaused', inputs=[], outputs=[])
+ pause.click(fn=lambda: shared.state.pause(), _js='checkPaused', inputs=[], outputs=[])
with gr.Row(elem_id=f"{id_part}_tools"):
button_paste = gr.Button(value='Restore', variant='secondary', elem_id=f"{id_part}_paste") # symbols.paste
button_clear = gr.Button(value='Clear', variant='secondary', elem_id=f"{id_part}_clear_prompt_btn") # symbols.clear
@@ -365,13 +358,13 @@ def create_toprow(is_img2img: bool = False, id_part: str = None):
negative_token_counter = gr.HTML(value="0/75", elem_id=f"{id_part}_negative_token_counter", elem_classes=["token-counter"])
negative_token_button = gr.Button(visible=False, elem_id=f"{id_part}_negative_token_button")
with gr.Row(elem_id=f"{id_part}_styles_row"):
- styles = gr.Dropdown(label="Styles", elem_id=f"{id_part}_styles", choices=[style.name for style in modules.shared.prompt_styles.styles.values()], value=[], multiselect=True)
- _styles_btn_refresh = create_refresh_button(styles, modules.shared.prompt_styles.reload, lambda: {"choices": list(modules.shared.prompt_styles.styles)}, f"{id_part}_styles_refresh")
+ styles = gr.Dropdown(label="Styles", elem_id=f"{id_part}_styles", choices=[style.name for style in shared.prompt_styles.styles.values()], value=[], multiselect=True)
+ _styles_btn_refresh = create_refresh_button(styles, shared.prompt_styles.reload, lambda: {"choices": list(shared.prompt_styles.styles)}, f"{id_part}_styles_refresh")
# styles_btn_refresh = ToolButton(symbols.refresh, elem_id=f"{id_part}_styles_refresh", visible=True)
- # styles_btn_refresh.click(fn=lambda: gr.update(choices=[style.name for style in modules.shared.prompt_styles.styles.values()]), inputs=[], outputs=[styles])
+ # styles_btn_refresh.click(fn=lambda: gr.update(choices=[style.name for style in shared.prompt_styles.styles.values()]), inputs=[], outputs=[styles])
styles_btn_select = gr.Button('Select', elem_id=f"{id_part}_styles_select", visible=False)
styles_btn_select.click(_js="applyStyles", fn=parse_style, inputs=[styles], outputs=[styles])
- styles_btn_apply = ToolButton(symbols.apply, elem_id=f"{id_part}_extra_apply", visible=False)
+ styles_btn_apply = ToolButton(ui_symbols.apply, elem_id=f"{id_part}_extra_apply", visible=False)
styles_btn_apply.click(fn=apply_styles, inputs=[prompt, negative_prompt, styles], outputs=[prompt, negative_prompt, styles])
return prompt, styles, negative_prompt, submit, button_interrogate, button_deepbooru, button_paste, button_extra, token_counter, token_button, negative_token_counter, negative_token_button
@@ -383,7 +376,7 @@ def setup_progressbar(*args, **kwargs): # pylint: disable=unused-argument
def apply_setting(key, value):
if value is None:
return gr.update()
- if modules.shared.cmd_opts.freeze:
+ if shared.cmd_opts.freeze:
return gr.update()
# dont allow model to be swapped when model hash exists in prompt
if key == "sd_model_checkpoint" and opts.disable_weights_auto_swap:
@@ -402,7 +395,7 @@ def apply_setting(key, value):
opts.data[key] = valtype(value) if valtype != type(None) else value
if oldval != value and opts.data_labels[key].onchange is not None:
opts.data_labels[key].onchange()
- opts.save(modules.shared.config_filename)
+ opts.save(shared.config_filename)
return getattr(opts, key)
@@ -415,19 +408,19 @@ def create_sampler_and_steps_selection(choices, tabname):
opts.data['schedulers_brownian_noise'] = 'brownian noise' in sampler_options
opts.data['schedulers_discard_penultimate'] = 'discard penultimate sigma' in sampler_options
opts.data['schedulers_sigma'] = sampler_algo
- opts.save(modules.shared.config_filename, silent=True)
+ opts.save(shared.config_filename, silent=True)
def set_sampler_diffuser_options(sampler_options):
opts.data['schedulers_use_karras'] = 'karras' in sampler_options
opts.data['schedulers_use_thresholding'] = 'dynamic thresholding' in sampler_options
opts.data['schedulers_use_loworder'] = 'low order' in sampler_options
opts.data['schedulers_rescale_betas'] = 'rescale beta' in sampler_options
- opts.save(modules.shared.config_filename, silent=True)
+ opts.save(shared.config_filename, silent=True)
with FormRow(elem_classes=['flex-break']):
sampler_index = gr.Dropdown(label='Sampling method', elem_id=f"{tabname}_sampling", choices=[x.name for x in choices], value='Default', type="index")
steps = gr.Slider(minimum=1, maximum=99, step=1, label="Sampling steps", elem_id=f"{tabname}_steps", value=20)
- if modules.shared.backend == modules.shared.Backend.ORIGINAL:
+ if shared.backend == shared.Backend.ORIGINAL:
with FormRow(elem_classes=['flex-break']):
choices = ['brownian noise', 'discard penultimate sigma']
values = []
@@ -453,10 +446,11 @@ def create_sampler_and_steps_selection(choices, tabname):
def create_sampler_inputs(tab):
+ from modules import sd_samplers
with gr.Accordion(open=False, label="Sampler", elem_id=f"{tab}_sampler", elem_classes=["small-accordion"]):
with FormRow(elem_id=f"{tab}_row_sampler"):
- modules.sd_samplers.set_samplers()
- steps, sampler_index = create_sampler_and_steps_selection(modules.sd_samplers.samplers, tab)
+ sd_samplers.set_samplers()
+ steps, sampler_index = create_sampler_and_steps_selection(sd_samplers.samplers, tab)
return steps, sampler_index
@@ -471,7 +465,7 @@ def create_hires_inputs(tab):
with FormRow(elem_id=f"{tab}_hires_finalres", variant="compact"):
hr_final_resolution = FormHTML(value="", elem_id=f"{tab}_hr_finalres", label="Upscaled resolution", interactive=False)
with FormRow(elem_id=f"{tab}_hires_fix_row1", variant="compact"):
- hr_upscaler = gr.Dropdown(label="Upscaler", elem_id=f"{tab}_hr_upscaler", choices=[*modules.shared.latent_upscale_modes, *[x.name for x in modules.shared.sd_upscalers]], value=modules.shared.latent_upscale_default_mode)
+ hr_upscaler = gr.Dropdown(label="Upscaler", elem_id=f"{tab}_hr_upscaler", choices=[*shared.latent_upscale_modes, *[x.name for x in shared.sd_upscalers]], value=shared.latent_upscale_default_mode)
hr_force = gr.Checkbox(label='Force Hires', value=False, elem_id=f"{tab}_hr_force")
with FormRow(elem_id=f"{tab}_hires_fix_row2", variant="compact"):
hr_second_pass_steps = gr.Slider(minimum=0, maximum=99, step=1, label='Hires steps', elem_id=f"{tab}_steps_alt", value=20)
@@ -479,7 +473,7 @@ def create_hires_inputs(tab):
with FormRow(elem_id=f"{tab}_hires_fix_row3", variant="compact"):
hr_resize_x = gr.Slider(minimum=0, maximum=4096, step=8, label="Resize width to", value=0, elem_id=f"{tab}_hr_resize_x")
hr_resize_y = gr.Slider(minimum=0, maximum=4096, step=8, label="Resize height to", value=0, elem_id=f"{tab}_hr_resize_y")
- with FormGroup(visible=modules.shared.backend == modules.shared.Backend.DIFFUSERS):
+ with FormGroup(visible=shared.backend == shared.Backend.DIFFUSERS):
with FormRow(elem_id=f"{tab}_refiner_row1", variant="compact"):
refiner_start = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Refiner start', value=0.8, elem_id=f"{tab}_refiner_start")
refiner_steps = gr.Slider(minimum=0, maximum=99, step=1, label="Refiner steps", elem_id=f"{tab}_refiner_steps", value=5)
@@ -513,7 +507,7 @@ def create_ui(startup_timer = None):
if startup_timer is None:
timer.startup = timer.Timer()
reload_javascript()
- parameters_copypaste.reset()
+ generation_parameters_copypaste.reset()
import modules.txt2img # pylint: disable=redefined-outer-name
modules.scripts.scripts_current = modules.scripts.scripts_txt2img
@@ -535,7 +529,7 @@ def create_ui(startup_timer = None):
with FormRow():
width = gr.Slider(minimum=64, maximum=4096, step=8, label="Width", value=512, elem_id="txt2img_width")
height = gr.Slider(minimum=64, maximum=4096, step=8, label="Height", value=512, elem_id="txt2img_height")
- res_switch_btn = ToolButton(value=symbols.switch, elem_id="txt2img_res_switch_btn", label="Switch dims")
+ res_switch_btn = ToolButton(value=ui_symbols.switch, elem_id="txt2img_res_switch_btn", label="Switch dims")
res_switch_btn.click(lambda w, h: (h, w), inputs=[width, height], outputs=[width, height], show_progress=False)
with FormGroup(elem_classes="settings-accordion"):
@@ -642,9 +636,9 @@ def create_ui(startup_timer = None):
(seed_resize_from_h, "Seed resize from-2"),
*modules.scripts.scripts_txt2img.infotext_fields
]
- parameters_copypaste.add_paste_fields("txt2img", None, txt2img_paste_fields, override_settings)
- txt2img_bindings = parameters_copypaste.ParamBinding(paste_button=txt2img_paste, tabname="txt2img", source_text_component=txt2img_prompt, source_image_component=None)
- parameters_copypaste.register_paste_params_button(txt2img_bindings)
+ generation_parameters_copypaste.add_paste_fields("txt2img", None, txt2img_paste_fields, override_settings)
+ txt2img_bindings = generation_parameters_copypaste.ParamBinding(paste_button=txt2img_paste, tabname="txt2img", source_text_component=txt2img_prompt, source_image_component=None)
+ generation_parameters_copypaste.register_paste_params_button(txt2img_bindings)
txt2img_token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[txt2img_prompt, steps], outputs=[txt2img_token_counter])
txt2img_negative_token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[txt2img_negative_prompt, steps], outputs=[txt2img_negative_token_counter])
@@ -716,16 +710,16 @@ def create_ui(startup_timer = None):
init_mask_inpaint = gr.Image(label="Mask", source="upload", interactive=True, type="pil", elem_id="img_inpaint_mask")
with gr.TabItem('Batch', id='batch', elem_id="img2img_batch_tab") as tab_batch:
- hidden = '
Disabled when launched with --hide-ui-dir-config.' if modules.shared.cmd_opts.hide_ui_dir_config else ''
+ hidden = '
Disabled when launched with --hide-ui-dir-config.' if shared.cmd_opts.hide_ui_dir_config else ''
gr.HTML(
"
Upload images or process images in a directory" +
"
Add inpaint batch mask directory to enable inpaint batch processing"
f"{hidden}