mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
feat: add preset option for default_inpaint_engine_version, revert previous overwrite_step changes
add handling with state to allow overrides with inpaint_mode preset setting (currently disabled)
This commit is contained in:
+2
-1
@@ -562,7 +562,8 @@ possible_preset_keys = {
|
|||||||
"lora_downloads": "lora_downloads",
|
"lora_downloads": "lora_downloads",
|
||||||
"vae_downloads": "vae_downloads",
|
"vae_downloads": "vae_downloads",
|
||||||
"default_vae": "vae",
|
"default_vae": "vae",
|
||||||
"default_inpaint_method": "inpaint_method"
|
# "default_inpaint_method": "inpaint_method", # disabled so inpaint mode doesn't refresh after every preset change
|
||||||
|
"default_inpaint_engine_version": "inpaint_engine_version",
|
||||||
}
|
}
|
||||||
|
|
||||||
REWRITE_PRESET = False
|
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('scheduler', 'Scheduler', loaded_parameter_dict, results)
|
||||||
get_str('vae', 'VAE', loaded_parameter_dict, results)
|
get_str('vae', 'VAE', loaded_parameter_dict, results)
|
||||||
get_seed('seed', 'Seed', loaded_parameter_dict, results)
|
get_seed('seed', 'Seed', loaded_parameter_dict, results)
|
||||||
|
get_inpaint_engine_version('inpaint_engine_version', 'Inpaint Engine Version', loaded_parameter_dict, results)
|
||||||
get_inpaint_method('inpaint_method', 'Inpaint Mode', loaded_parameter_dict, results)
|
get_inpaint_method('inpaint_method', 'Inpaint Mode', loaded_parameter_dict, results)
|
||||||
|
|
||||||
if is_generating:
|
if is_generating:
|
||||||
@@ -161,6 +162,19 @@ def get_seed(key: str, fallback: str | None, source_dict: dict, results: list, d
|
|||||||
results.append(gr.update())
|
results.append(gr.update())
|
||||||
|
|
||||||
|
|
||||||
|
def get_inpaint_engine_version(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_engine_versions
|
||||||
|
results.append(h)
|
||||||
|
results.append(h)
|
||||||
|
return h
|
||||||
|
except:
|
||||||
|
results.append(gr.update())
|
||||||
|
results.append('empty')
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_inpaint_method(key: str, fallback: str | None, source_dict: dict, results: list, default=None) -> str | None:
|
def get_inpaint_method(key: str, fallback: str | None, source_dict: dict, results: list, default=None) -> str | None:
|
||||||
try:
|
try:
|
||||||
h = source_dict.get(key, source_dict.get(fallback, default))
|
h = source_dict.get(key, source_dict.get(fallback, default))
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "896*1152",
|
"default_aspect_ratio": "896*1152",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"animaPencilXL_v310.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v310.safetensors"
|
"animaPencilXL_v310.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v310.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "1152*896",
|
"default_aspect_ratio": "1152*896",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors"
|
"juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "1152*896",
|
"default_aspect_ratio": "1152*896",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors"
|
"juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,8 +41,7 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "1024*1024",
|
"default_aspect_ratio": "1024*1024",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
"default_inpaint_engine_version": "None",
|
||||||
"default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)",
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"playground-v2.5-1024px-aesthetic.fp16.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/playground-v2.5-1024px-aesthetic.fp16.safetensors"
|
"playground-v2.5-1024px-aesthetic.fp16.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/playground-v2.5-1024px-aesthetic.fp16.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"default_model": "ponyDiffusionV6XL.safetensors",
|
"default_model": "ponyDiffusionV6XL.safetensors",
|
||||||
"default_refiner": "None",
|
"default_refiner": "None",
|
||||||
"default_refiner_switch": 1,
|
"default_refiner_switch": 0.5,
|
||||||
"default_vae": "ponyDiffusionV6XL_vae.safetensors",
|
"default_vae": "ponyDiffusionV6XL_vae.safetensors",
|
||||||
"default_loras": [
|
"default_loras": [
|
||||||
[
|
[
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "896*1152",
|
"default_aspect_ratio": "896*1152",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": 999,
|
"default_inpaint_engine_version": "None",
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors"
|
"ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "896*1152",
|
"default_aspect_ratio": "896*1152",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"realisticStockPhoto_v20.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticStockPhoto_v20.safetensors"
|
"realisticStockPhoto_v20.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticStockPhoto_v20.safetensors"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
],
|
],
|
||||||
"default_aspect_ratio": "1152*896",
|
"default_aspect_ratio": "1152*896",
|
||||||
"default_overwrite_step": -1,
|
"default_overwrite_step": -1,
|
||||||
"default_overwrite_switch": -1,
|
|
||||||
"checkpoint_downloads": {
|
"checkpoint_downloads": {
|
||||||
"sd_xl_base_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors",
|
"sd_xl_base_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors",
|
||||||
"sd_xl_refiner_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors"
|
"sd_xl_refiner_1.0_0.9vae.safetensors": "https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors"
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ shared.gradio_root = gr.Blocks(title=title).queue()
|
|||||||
|
|
||||||
with shared.gradio_root:
|
with shared.gradio_root:
|
||||||
currentTask = gr.State(worker.AsyncTask(args=[]))
|
currentTask = gr.State(worker.AsyncTask(args=[]))
|
||||||
|
inpaint_engine_state = gr.State('empty')
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Column(scale=2):
|
with gr.Column(scale=2):
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
@@ -589,8 +590,8 @@ with shared.gradio_root:
|
|||||||
overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
|
overwrite_width, overwrite_height, guidance_scale, sharpness, adm_scaler_positive,
|
||||||
adm_scaler_negative, adm_scaler_end, refiner_swap_method, adaptive_cfg, clip_skip,
|
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,
|
base_model, refiner_model, refiner_switch, sampler_name, scheduler_name, vae_name,
|
||||||
seed_random, image_seed, inpaint_mode, generate_button, load_parameter_button
|
seed_random, image_seed, inpaint_engine, inpaint_engine_state, inpaint_mode,
|
||||||
] + freeu_ctrls + lora_ctrls
|
generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls
|
||||||
|
|
||||||
if not args_manager.args.disable_preset_selection:
|
if not args_manager.args.disable_preset_selection:
|
||||||
def preset_selection_change(preset, is_generating):
|
def preset_selection_change(preset, is_generating):
|
||||||
@@ -632,7 +633,7 @@ with shared.gradio_root:
|
|||||||
queue=False, show_progress=False) \
|
queue=False, show_progress=False) \
|
||||||
.then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
|
.then(fn=lambda: None, _js='refresh_grid_delayed', queue=False, show_progress=False)
|
||||||
|
|
||||||
def inpaint_mode_change(mode):
|
def inpaint_mode_change(mode, inpaint_engine_version):
|
||||||
assert mode in modules.flags.inpaint_options
|
assert mode in modules.flags.inpaint_options
|
||||||
|
|
||||||
# inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
# inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
||||||
@@ -645,28 +646,30 @@ with shared.gradio_root:
|
|||||||
gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts),
|
gr.Dataset.update(visible=True, samples=modules.config.example_inpaint_prompts),
|
||||||
False, 'None', 0.5, 0.0
|
False, 'None', 0.5, 0.0
|
||||||
]
|
]
|
||||||
|
if inpaint_engine_version == 'empty':
|
||||||
|
inpaint_engine_version = modules.config.default_inpaint_engine_version
|
||||||
|
|
||||||
if mode == modules.flags.inpaint_option_modify:
|
if mode == modules.flags.inpaint_option_modify:
|
||||||
return [
|
return [
|
||||||
gr.update(visible=True), gr.update(visible=False, value=[]),
|
gr.update(visible=True), gr.update(visible=False, value=[]),
|
||||||
gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
|
gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
|
||||||
True, modules.config.default_inpaint_engine_version, 1.0, 0.0
|
True, inpaint_engine_version, 1.0, 0.0
|
||||||
]
|
]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
gr.update(visible=False, value=''), gr.update(visible=True),
|
gr.update(visible=False, value=''), gr.update(visible=True),
|
||||||
gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
|
gr.Dataset.update(visible=False, samples=modules.config.example_inpaint_prompts),
|
||||||
False, modules.config.default_inpaint_engine_version, 1.0, 0.618
|
False, inpaint_engine_version, 1.0, 0.618
|
||||||
]
|
]
|
||||||
|
|
||||||
inpaint_mode.change(inpaint_mode_change, inputs=inpaint_mode, outputs=[
|
inpaint_mode.change(inpaint_mode_change, inputs=[inpaint_mode, inpaint_engine_state], outputs=[
|
||||||
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
||||||
inpaint_disable_initial_latent, inpaint_engine,
|
inpaint_disable_initial_latent, inpaint_engine,
|
||||||
inpaint_strength, inpaint_respective_field
|
inpaint_strength, inpaint_respective_field
|
||||||
], show_progress=False, queue=False)
|
], show_progress=False, queue=False)
|
||||||
|
|
||||||
# load configured default_inpaint_method
|
# load configured default_inpaint_method
|
||||||
shared.gradio_root.load(inpaint_mode_change, inputs=inpaint_mode, outputs=[
|
shared.gradio_root.load(inpaint_mode_change, inputs=[inpaint_mode, inpaint_engine_state], outputs=[
|
||||||
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts,
|
||||||
inpaint_disable_initial_latent, inpaint_engine,
|
inpaint_disable_initial_latent, inpaint_engine,
|
||||||
inpaint_strength, inpaint_respective_field
|
inpaint_strength, inpaint_respective_field
|
||||||
|
|||||||
Reference in New Issue
Block a user