Merge branch 'feature/add-preset-selection'
This commit is contained in:
commit
1e0f95c6cf
|
|
@ -376,9 +376,9 @@ possible_preset_keys = {
|
|||
"default_prompt_negative": "Negative Prompt",
|
||||
"default_styles": "Styles",
|
||||
"default_aspect_ratio": "Resolution",
|
||||
"checkpoint_downloads": None,
|
||||
"embeddings_downloads": None,
|
||||
"lora_downloads": None,
|
||||
"checkpoint_downloads": "checkpoint_downloads",
|
||||
"embeddings_downloads": "embeddings_downloads",
|
||||
"lora_downloads": "lora_downloads",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -149,13 +149,25 @@ def parse_meta_from_preset(preset_content):
|
|||
items = preset_content
|
||||
|
||||
for settings_key, meta_key in modules.config.possible_preset_keys.items():
|
||||
if settings_key != "default_loras":
|
||||
preset_prepared[meta_key] = items[settings_key] if settings_key in items and items[settings_key] is not None else getattr(modules.config, settings_key)
|
||||
else:
|
||||
if settings_key == "default_loras":
|
||||
loras = getattr(modules.config, settings_key)
|
||||
if settings_key in items:
|
||||
loras = items[settings_key]
|
||||
for index, lora in enumerate(loras[:5]):
|
||||
preset_prepared[f'LoRA {index + 1}'] = ' : '.join(map(str, lora))
|
||||
elif settings_key == "default_aspect_ratio":
|
||||
if settings_key in items and items[settings_key] is not None:
|
||||
default_aspect_ratio = items[settings_key]
|
||||
width, height = default_aspect_ratio.split('*')
|
||||
else:
|
||||
default_aspect_ratio = getattr(modules.config, settings_key)
|
||||
width, height = default_aspect_ratio.split('×')
|
||||
height = height[:height.index(" ")]
|
||||
preset_prepared[meta_key] = (width, height)
|
||||
else:
|
||||
preset_prepared[meta_key] = items[settings_key] if settings_key in items and items[settings_key] is not None else getattr(modules.config, settings_key)
|
||||
|
||||
if settings_key == "default_styles" or settings_key == "default_aspect_ratio":
|
||||
preset_prepared[meta_key] = str(preset_prepared[meta_key])
|
||||
|
||||
return load_parameter_button_click(json.dumps(preset_prepared))
|
||||
return preset_prepared
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"default_model": "realisticStockPhoto_v10.safetensors",
|
||||
"default_refiner": "",
|
||||
"default_refiner": "None",
|
||||
"default_refiner_switch": 0.5,
|
||||
"default_loras": [
|
||||
[
|
||||
|
|
|
|||
15
webui.py
15
webui.py
|
|
@ -16,6 +16,7 @@ import modules.style_sorter as style_sorter
|
|||
import modules.meta_parser
|
||||
import args_manager
|
||||
import copy
|
||||
import launch
|
||||
|
||||
from modules.sdxl_styles import legal_style_names
|
||||
from modules.private_logger import get_current_html_path
|
||||
|
|
@ -506,7 +507,14 @@ with shared.gradio_root:
|
|||
|
||||
def preset_selection_change(preset):
|
||||
preset_content = modules.config.try_get_preset_content(preset) if preset != 'initial' else {}
|
||||
return modules.meta_parser.parse_meta_from_preset(preset_content)
|
||||
preset_prepared = modules.meta_parser.parse_meta_from_preset(preset_content)
|
||||
|
||||
launch.checkpoint_downloads = preset_prepared['checkpoint_downloads']
|
||||
launch.embeddings_downloads = preset_prepared['embeddings_downloads']
|
||||
launch.lora_downloads = preset_prepared['lora_downloads']
|
||||
launch.download_models()
|
||||
|
||||
return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared))
|
||||
|
||||
preset_selection.change(preset_selection_change, inputs=preset_selection, outputs=[
|
||||
advanced_checkbox,
|
||||
|
|
@ -532,7 +540,10 @@ with shared.gradio_root:
|
|||
image_seed,
|
||||
generate_button,
|
||||
load_parameter_button
|
||||
] + lora_ctrls, queue=False, show_progress=False)
|
||||
] + lora_ctrls, queue=False, show_progress=True) \
|
||||
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \
|
||||
.then(lambda: None, _js='()=>{refresh_style_localization();}')
|
||||
|
||||
|
||||
performance_selection.change(lambda x: [gr.update(interactive=x != 'Extreme Speed')] * 11 +
|
||||
[gr.update(visible=x != 'Extreme Speed')] * 1 +
|
||||
|
|
|
|||
Loading…
Reference in New Issue