feat: add config default_inpaint_method, reload on start and preset change
This commit is contained in:
parent
72bb6ec065
commit
333cc6db50
|
|
@ -466,6 +466,12 @@ default_inpaint_engine_version = get_config_item_or_set_default(
|
|||
validator=lambda x: x in modules.flags.inpaint_engine_versions,
|
||||
expected_type=str
|
||||
)
|
||||
default_inpaint_method = get_config_item_or_set_default(
|
||||
key='default_inpaint_method',
|
||||
default_value=modules.flags.inpaint_option_default,
|
||||
validator=lambda x: x in modules.flags.inpaint_options,
|
||||
expected_type=str
|
||||
)
|
||||
default_cfg_tsnr = get_config_item_or_set_default(
|
||||
key='default_cfg_tsnr',
|
||||
default_value=7.0,
|
||||
|
|
@ -553,7 +559,8 @@ possible_preset_keys = {
|
|||
"checkpoint_downloads": "checkpoint_downloads",
|
||||
"embeddings_downloads": "embeddings_downloads",
|
||||
"lora_downloads": "lora_downloads",
|
||||
"default_vae": "vae"
|
||||
"default_vae": "vae",
|
||||
"default_inpaint_method": "inpaint_method"
|
||||
}
|
||||
|
||||
REWRITE_PRESET = False
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ def load_parameter_button_click(raw_metadata: dict | str, is_generating: bool):
|
|||
get_str('scheduler', 'Scheduler', loaded_parameter_dict, results)
|
||||
get_str('vae', 'VAE', loaded_parameter_dict, results)
|
||||
get_seed('seed', 'Seed', loaded_parameter_dict, results)
|
||||
get_inpaint_method('inpaint_method', 'Inpaint Mode', loaded_parameter_dict, results)
|
||||
|
||||
if is_generating:
|
||||
results.append(gr.update())
|
||||
|
|
@ -160,6 +161,17 @@ def get_seed(key: str, fallback: str | None, source_dict: dict, results: list, d
|
|||
results.append(gr.update())
|
||||
|
||||
|
||||
def get_inpaint_method(key: str, fallback: str | None, source_dict: dict, results: list, default=None) -> str | None:
|
||||
try:
|
||||
h = source_dict.get(key, source_dict.get(fallback, default))
|
||||
assert isinstance(h, str) and h in modules.flags.inpaint_options
|
||||
results.append(h)
|
||||
return h
|
||||
except:
|
||||
results.append(gr.update())
|
||||
return None
|
||||
|
||||
|
||||
def get_adm_guidance(key: str, fallback: str | None, source_dict: dict, results: list, default=None):
|
||||
try:
|
||||
h = source_dict.get(key, source_dict.get(fallback, default))
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
],
|
||||
"default_aspect_ratio": "896*1152",
|
||||
"default_overwrite_step": -1,
|
||||
"default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)",
|
||||
"checkpoint_downloads": {
|
||||
"ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors"
|
||||
},
|
||||
|
|
|
|||
14
webui.py
14
webui.py
|
|
@ -207,7 +207,7 @@ with shared.gradio_root:
|
|||
with gr.Row():
|
||||
inpaint_additional_prompt = gr.Textbox(placeholder="Describe what you want to inpaint.", elem_id='inpaint_additional_prompt', label='Inpaint Additional Prompt', visible=False)
|
||||
outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint Direction')
|
||||
inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.flags.inpaint_option_default, label='Method')
|
||||
inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, value=modules.config.default_inpaint_method, label='Method')
|
||||
example_inpaint_prompts = gr.Dataset(samples=modules.config.example_inpaint_prompts, label='Additional Prompt Quick List', components=[inpaint_additional_prompt], visible=False)
|
||||
gr.HTML('* Powered by Fooocus Inpaint Engine <a href="https://github.com/lllyasviel/Fooocus/discussions/414" target="_blank">\U0001F4D4 Document</a>')
|
||||
example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False)
|
||||
|
|
@ -589,7 +589,8 @@ with shared.gradio_root:
|
|||
overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
|
||||
adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, clip_skip,
|
||||
base_model, refiner_model, refiner_switch, sampler_name, scheduler_name, vae_name,
|
||||
seed_random, image_seed, generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
|
||||
seed_random, image_seed, inpaint_mode, generate_button, load_parameter_button
|
||||
] + freeu_ctrls + lora_ctrls
|
||||
|
||||
if not args_manager.args.disable_preset_selection:
|
||||
def preset_selection_change(preset, is_generating):
|
||||
|
|
@ -658,7 +659,14 @@ with shared.gradio_root:
|
|||
False, modules.config.default_inpaint_engine_version, 1.0, 0.618
|
||||
]
|
||||
|
||||
inpaint_mode.input(inpaint_mode_change, inputs=inpaint_mode, outputs=[
|
||||
inpaint_mode.change(inpaint_mode_change, inputs=inpaint_mode, outputs=[
|
||||
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
||||
inpaint_disable_initial_latent, inpaint_engine,
|
||||
inpaint_strength, inpaint_respective_field
|
||||
], show_progress=False, queue=False)
|
||||
|
||||
# load configured default_inpaint_method
|
||||
shared.gradio_root.load(inpaint_mode_change, inputs=inpaint_mode, outputs=[
|
||||
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
||||
inpaint_disable_initial_latent, inpaint_engine,
|
||||
inpaint_strength, inpaint_respective_field
|
||||
|
|
|
|||
Loading…
Reference in New Issue