From 74f9ff03a6a488fc5ba81b62aca5d805cee6748a Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 14:35:55 +0200 Subject: [PATCH 01/22] feat: update animaPencilXL_v400 to animaPencilXL_v500 --- presets/anime.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/presets/anime.json b/presets/anime.json index 4394c26b..53b062c4 100644 --- a/presets/anime.json +++ b/presets/anime.json @@ -1,5 +1,5 @@ { - "default_model": "animaPencilXL_v400.safetensors", + "default_model": "animaPencilXL_v500.safetensors", "default_refiner": "None", "default_refiner_switch": 0.5, "default_loras": [ @@ -43,11 +43,12 @@ ], "default_aspect_ratio": "896*1152", "checkpoint_downloads": { - "animaPencilXL_v400.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v400.safetensors" + "animaPencilXL_v500.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v500.safetensors" }, "embeddings_downloads": {}, "lora_downloads": {}, "previous_default_models": [ + "animaPencilXL_v400.safetensors", "animaPencilXL_v310.safetensors", "animaPencilXL_v300.safetensors", "animaPencilXL_v260.safetensors", From 5a0df961fa972c73e7f890f88ca07b158e75a515 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 14:36:15 +0200 Subject: [PATCH 02/22] feat: remove "by wlop" from style Fooocus Masterpiece causes too many watermarks --- sdxl_styles/sdxl_styles_fooocus.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdxl_styles/sdxl_styles_fooocus.json b/sdxl_styles/sdxl_styles_fooocus.json index cf64eab4..33337214 100644 --- a/sdxl_styles/sdxl_styles_fooocus.json +++ b/sdxl_styles/sdxl_styles_fooocus.json @@ -14,7 +14,7 @@ }, { "name": "Fooocus Masterpiece", - "prompt": "(masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings, by wlop", + "prompt": "(masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings", "negative_prompt": "longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality" }, { From ffa4d82bd12e068945681b3d46c4737631098806 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 14:37:31 +0200 Subject: [PATCH 03/22] feat: update DreamShaperXL_Turbo to DreamShaperXL_Turbo_v2_1 --- presets/turbo.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/presets/turbo.json b/presets/turbo.json index 95050d41..f8629b2e 100644 --- a/presets/turbo.json +++ b/presets/turbo.json @@ -1,5 +1,5 @@ { - "default_model": "DreamShaperXL_Turbo_dpmppSdeKarras_half_pruned_6.safetensors", + "default_model": "DreamShaperXL_Turbo_v2_1.safetensors", "default_refiner": "None", "default_refiner_switch": 0.5, "default_loras": [ @@ -39,8 +39,11 @@ "default_aspect_ratio": "1024*1024", "default_overwrite_step": 6, "checkpoint_downloads": { - "DreamShaperXL_Turbo_dpmppSdeKarras_half_pruned_6.safetensors": "https://huggingface.co/Lykon/dreamshaper-xl-turbo/resolve/main/DreamShaperXL_Turbo_dpmppSdeKarras_half_pruned_6.safetensors" + "DreamShaperXL_Turbo_v2_1.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/DreamShaperXL_Turbo_v2_1.safetensors" }, "embeddings_downloads": {}, - "lora_downloads": {} + "lora_downloads": {}, + "previous_default_models": [ + "DreamShaperXL_Turbo_dpmppSdeKarras_half_pruned_6.safetensors" + ] } \ No newline at end of file From bbf90a97b7ebd1808836fb39d9e490966070f4c2 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 15:44:35 +0200 Subject: [PATCH 04/22] feat: add pony preset and vae downloads uses default SDXL VAE, but the model doesn't include it --- launch.py | 6 ++++-- modules/config.py | 6 ++++++ presets/.gitignore | 1 + presets/pony_v6.json | 51 ++++++++++++++++++++++++++++++++++++++++++++ webui.py | 6 ++++-- 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 presets/pony_v6.json diff --git a/launch.py b/launch.py index 5d40cc5b..0e0ac994 100644 --- a/launch.py +++ b/launch.py @@ -97,7 +97,7 @@ if config.temp_path_cleanup_on_launch: print(f"[Cleanup] Failed to delete content of temp dir.") -def download_models(default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads): +def download_models(default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads, vae_downloads): for file_name, url in vae_approx_filenames: load_file_from_url(url=url, model_dir=config.path_vae_approx, file_name=file_name) @@ -129,12 +129,14 @@ def download_models(default_model, previous_default_models, checkpoint_downloads load_file_from_url(url=url, model_dir=config.path_embeddings, file_name=file_name) for file_name, url in lora_downloads.items(): load_file_from_url(url=url, model_dir=config.paths_loras[0], file_name=file_name) + for file_name, url in vae_downloads.items(): + load_file_from_url(url=url, model_dir=config.path_vae, file_name=file_name) return default_model, checkpoint_downloads config.default_base_model_name, config.checkpoint_downloads = download_models( config.default_base_model_name, config.previous_default_models, config.checkpoint_downloads, - config.embeddings_downloads, config.lora_downloads) + config.embeddings_downloads, config.lora_downloads, config.vae_downloads) from webui import * diff --git a/modules/config.py b/modules/config.py index a6767c37..bc9744e6 100644 --- a/modules/config.py +++ b/modules/config.py @@ -442,6 +442,12 @@ embeddings_downloads = get_config_item_or_set_default( validator=lambda x: isinstance(x, dict) and all(isinstance(k, str) and isinstance(v, str) for k, v in x.items()), expected_type=dict ) +vae_downloads = get_config_item_or_set_default( + key='vae_downloads', + default_value={}, + validator=lambda x: isinstance(x, dict) and all(isinstance(k, str) and isinstance(v, str) for k, v in x.items()), + expected_type=dict +) available_aspect_ratios = get_config_item_or_set_default( key='available_aspect_ratios', default_value=modules.flags.sdxl_aspect_ratios, diff --git a/presets/.gitignore b/presets/.gitignore index 27e74136..e39511a9 100644 --- a/presets/.gitignore +++ b/presets/.gitignore @@ -3,5 +3,6 @@ !default.json !lcm.json !playground_v2.5.json +!pony_v6.json !realistic.json !sai.json \ No newline at end of file diff --git a/presets/pony_v6.json b/presets/pony_v6.json new file mode 100644 index 00000000..c43255db --- /dev/null +++ b/presets/pony_v6.json @@ -0,0 +1,51 @@ +{ + "default_model": "ponyDiffusionV6XL.safetensors", + "default_refiner": "None", + "default_refiner_switch": 0.5, + "default_vae": "ponyDiffusionV6XL_vae.safetensors", + "default_loras": [ + [ + true, + "None", + 1.0 + ], + [ + true, + "None", + 1.0 + ], + [ + true, + "None", + 1.0 + ], + [ + true, + "None", + 1.0 + ], + [ + true, + "None", + 1.0 + ] + ], + "default_cfg_scale": 7.0, + "default_sample_sharpness": 2.0, + "default_sampler": "dpmpp_2m_sde_gpu", + "default_scheduler": "karras", + "default_performance": "Speed", + "default_prompt": "score_9, score_8_up, score_7_up, ", + "default_prompt_negative": "score_6, score_5, score_4, censored", + "default_styles": [], + "default_aspect_ratio": "896*1152", + "default_overwrite_step": -1, + "checkpoint_downloads": { + "ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors" + }, + "embeddings_downloads": {}, + "lora_downloads": {}, + "vae_downloads": { + "ponyDiffusionV6XL_vae.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL_vae.safetensors" + } +} diff --git a/webui.py b/webui.py index a0982cae..fa98387c 100644 --- a/webui.py +++ b/webui.py @@ -601,9 +601,11 @@ with shared.gradio_root: checkpoint_downloads = preset_prepared.get('checkpoint_downloads', {}) embeddings_downloads = preset_prepared.get('embeddings_downloads', {}) lora_downloads = preset_prepared.get('lora_downloads', {}) + vae_downloads = preset_prepared.get('vae_downloads', {}) - preset_prepared['base_model'], preset_prepared['lora_downloads'] = launch.download_models( - default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads) + preset_prepared['base_model'], preset_prepared['checkpoint_downloads'] = launch.download_models( + default_model, previous_default_models, checkpoint_downloads, embeddings_downloads, lora_downloads, + vae_downloads) if 'prompt' in preset_prepared and preset_prepared.get('prompt') == '': del preset_prepared['prompt'] From 72bb6ec0650688f1968d9a390ca59ba32f313308 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 19:16:04 +0200 Subject: [PATCH 05/22] feat: add style Fooocus Pony --- presets/pony_v6.json | 8 +++++--- sdxl_styles/samples/fooocus_pony.jpg | Bin 0 -> 5200 bytes sdxl_styles/sdxl_styles_fooocus.json | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 sdxl_styles/samples/fooocus_pony.jpg diff --git a/presets/pony_v6.json b/presets/pony_v6.json index c43255db..f28064b8 100644 --- a/presets/pony_v6.json +++ b/presets/pony_v6.json @@ -35,9 +35,11 @@ "default_sampler": "dpmpp_2m_sde_gpu", "default_scheduler": "karras", "default_performance": "Speed", - "default_prompt": "score_9, score_8_up, score_7_up, ", - "default_prompt_negative": "score_6, score_5, score_4, censored", - "default_styles": [], + "default_prompt": "", + "default_prompt_negative": "", + "default_styles": [ + "Fooocus Pony" + ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, "checkpoint_downloads": { diff --git a/sdxl_styles/samples/fooocus_pony.jpg b/sdxl_styles/samples/fooocus_pony.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b34e5c76d3ada385487fe4af0f01a9b03b3191d2 GIT binary patch literal 5200 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 literal 0 HcmV?d00001 diff --git a/sdxl_styles/sdxl_styles_fooocus.json b/sdxl_styles/sdxl_styles_fooocus.json index cf64eab4..669e97a4 100644 --- a/sdxl_styles/sdxl_styles_fooocus.json +++ b/sdxl_styles/sdxl_styles_fooocus.json @@ -30,5 +30,10 @@ "name": "Fooocus Cinematic", "prompt": "cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy", "negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured" + }, + { + "name": "Fooocus Pony", + "prompt": "score_9, score_8_up, score_7_up, {prompt}", + "negative_prompt": "score_6, score_5, score_4" } ] From 333cc6db508780b70af2c6ab09b087cb78fa74a2 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 20:19:18 +0200 Subject: [PATCH 06/22] feat: add config default_inpaint_method, reload on start and preset change --- modules/config.py | 9 ++++++++- modules/meta_parser.py | 12 ++++++++++++ presets/pony_v6.json | 1 + webui.py | 14 +++++++++++--- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/config.py b/modules/config.py index bc9744e6..f7fc7e04 100644 --- a/modules/config.py +++ b/modules/config.py @@ -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 diff --git a/modules/meta_parser.py b/modules/meta_parser.py index ff930cc0..e5ba765f 100644 --- a/modules/meta_parser.py +++ b/modules/meta_parser.py @@ -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)) diff --git a/presets/pony_v6.json b/presets/pony_v6.json index f28064b8..8a3a962a 100644 --- a/presets/pony_v6.json +++ b/presets/pony_v6.json @@ -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" }, diff --git a/webui.py b/webui.py index fa98387c..d8e5ffe4 100644 --- a/webui.py +++ b/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 \U0001F4D4 Document') 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 From 6e8588ca0c28dba73a245bbcc39584261f36eb74 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 20:21:53 +0200 Subject: [PATCH 07/22] feat: adjust playground inpaint mode default prevent inpaint engine to be used on preset select to prevent accidental bad results due to incompatibility --- presets/playground_v2.5.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/presets/playground_v2.5.json b/presets/playground_v2.5.json index 5bc6059e..f4afaa9a 100644 --- a/presets/playground_v2.5.json +++ b/presets/playground_v2.5.json @@ -40,6 +40,8 @@ "Fooocus V2" ], "default_aspect_ratio": "1024*1024", + "default_overwrite_step": -1, + "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", "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" }, From 7068250a9940e9680f87143a85cbe71f62e6b136 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 20:52:19 +0200 Subject: [PATCH 08/22] feat: reload all inpaint modes in enhance tabs when preset is changed and inpaint_mode is set --- modules/meta_parser.py | 5 ++++- webui.py | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/modules/meta_parser.py b/modules/meta_parser.py index 191d8905..4a14a001 100644 --- a/modules/meta_parser.py +++ b/modules/meta_parser.py @@ -166,10 +166,13 @@ def get_inpaint_method(key: str, fallback: str | None, source_dict: dict, result h = source_dict.get(key, source_dict.get(fallback, default)) assert isinstance(h, str) and h in modules.flags.inpaint_options results.append(h) + for i in range(modules.config.default_enhance_tabs): + results.append(h) return h except: results.append(gr.update()) - return None + for i in range(modules.config.default_enhance_tabs): + results.append(gr.update()) def get_adm_guidance(key: str, fallback: str | None, source_dict: dict, results: list, default=None): diff --git a/webui.py b/webui.py index 6dc4ac1d..f6db5f35 100644 --- a/webui.py +++ b/webui.py @@ -377,6 +377,8 @@ with shared.gradio_root: queue=False, show_progress=False) gr.HTML('\U0001F4D4 Document') enhance_ctrls = [] + enhance_inpaint_mode_ctrls = [] + enhance_inpaint_update_ctrls = [] for index in range(modules.config.default_enhance_tabs): with gr.TabItem(label=f'#{index + 1}') as enhance_tab_item: enhance_enabled = gr.Checkbox(label='Enable', value=False, elem_classes='min_check', @@ -435,7 +437,7 @@ with shared.gradio_root: with gr.Accordion("Inpaint", visible=True, open=False): enhance_inpaint_mode = gr.Dropdown(choices=modules.flags.inpaint_options, - value=modules.flags.inpaint_option_default, + value=modules.config.default_inpaint_method, label='Method', interactive=True) enhance_inpaint_disable_initial_latent = gr.Checkbox( label='Disable initial latent in inpaint', value=False) @@ -485,7 +487,14 @@ with shared.gradio_root: enhance_mask_invert ] - enhance_inpaint_mode.input(inpaint_mode_change, inputs=enhance_inpaint_mode, outputs=[ + enhance_inpaint_mode_ctrls += [enhance_inpaint_mode] + + enhance_inpaint_update_ctrls += [[ + enhance_inpaint_mode, enhance_inpaint_disable_initial_latent, enhance_inpaint_engine, + enhance_inpaint_strength, enhance_inpaint_respective_field + ]] + + enhance_inpaint_mode.change(inpaint_mode_change, inputs=enhance_inpaint_mode, outputs=[ inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, enhance_inpaint_disable_initial_latent, enhance_inpaint_engine, enhance_inpaint_strength, enhance_inpaint_respective_field @@ -874,8 +883,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, inpaint_mode, generate_button, load_parameter_button - ] + freeu_ctrls + lora_ctrls + seed_random, image_seed, inpaint_mode] + enhance_inpaint_mode_ctrls + [generate_button, + load_parameter_button] + freeu_ctrls + lora_ctrls if not args_manager.args.disable_preset_selection: def preset_selection_change(preset, is_generating): @@ -925,11 +934,12 @@ with shared.gradio_root: ], 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 - ], show_progress=False, queue=False) + default_inpaint_ctrls = [inpaint_mode, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field] + for mode, disable_initial_latent, engine, strength, respective_field in [default_inpaint_ctrls] + enhance_inpaint_update_ctrls: + shared.gradio_root.load(inpaint_mode_change, inputs=mode, outputs=[ + inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, disable_initial_latent, + engine, strength, respective_field + ], show_progress=False, queue=False) generate_mask_button.click(fn=generate_mask, inputs=[inpaint_input_image, inpaint_mask_model, inpaint_mask_cloth_category, From 90859354496b4c1b1171af89082b4293f6cd6287 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 00:08:12 +0200 Subject: [PATCH 09/22] feat: add same functionality as inpaint image to mask upload element --- javascript/zoom.js | 1 + webui.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/javascript/zoom.js b/javascript/zoom.js index 450a0347..8d1d296d 100644 --- a/javascript/zoom.js +++ b/javascript/zoom.js @@ -642,4 +642,5 @@ onUiLoaded(async() => { } applyZoomAndPan("#inpaint_canvas"); + applyZoomAndPan("#inpaint_mask_canvas"); }); diff --git a/webui.py b/webui.py index f6db5f35..8607d5c9 100644 --- a/webui.py +++ b/webui.py @@ -246,7 +246,7 @@ with shared.gradio_root: example_inpaint_prompts.click(lambda x: x[0], inputs=example_inpaint_prompts, outputs=inpaint_additional_prompt, show_progress=False, queue=False) with gr.Column(visible=False) as inpaint_mask_generation_col: - inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", mask_opacity=1) + inpaint_mask_image = grh.Image(label='Mask Upload', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF", mask_opacity=1, elem_id='inpaint_mask_canvas') invert_mask_checkbox = gr.Checkbox(label='Invert Mask When Generating', value=False) inpaint_mask_model = gr.Dropdown(label='Mask generation model', choices=flags.inpaint_mask_models, From c44f331cee4499522f57adcd2452684ddb53ee0e Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 13:39:26 +0200 Subject: [PATCH 10/22] fix: add missing key vae_downloads to possible_preset_keys --- modules/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/config.py b/modules/config.py index f7fc7e04..8ab5edb8 100644 --- a/modules/config.py +++ b/modules/config.py @@ -559,6 +559,7 @@ possible_preset_keys = { "checkpoint_downloads": "checkpoint_downloads", "embeddings_downloads": "embeddings_downloads", "lora_downloads": "lora_downloads", + "vae_downloads": "vae_downloads", "default_vae": "vae", "default_inpaint_method": "inpaint_method" } From 34f67c01a8164f4b596ea68e336f7a66bc4f5c30 Mon Sep 17 00:00:00 2001 From: licyk <76895225+licyk@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:24:21 +0800 Subject: [PATCH 11/22] feat: add restart sampler (#3219) --- ldm_patched/k_diffusion/sampling.py | 70 +++++++++++++++++++++++++++++ ldm_patched/modules/samplers.py | 2 +- modules/flags.py | 3 +- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/ldm_patched/k_diffusion/sampling.py b/ldm_patched/k_diffusion/sampling.py index ea5540a4..4d9d4ea6 100644 --- a/ldm_patched/k_diffusion/sampling.py +++ b/ldm_patched/k_diffusion/sampling.py @@ -835,4 +835,74 @@ def sample_tcd(model, x, sigmas, extra_args=None, callback=None, disable=None, n else: x *= torch.sqrt(1.0 + sigmas[i + 1] ** 2) + return x + + +@torch.no_grad() +def sample_restart(model, x, sigmas, extra_args=None, callback=None, disable=None, s_noise=1., restart_list=None): + """Implements restart sampling in Restart Sampling for Improving Generative Processes (2023) + Restart_list format: {min_sigma: [ restart_steps, restart_times, max_sigma]} + If restart_list is None: will choose restart_list automatically, otherwise will use the given restart_list + """ + extra_args = {} if extra_args is None else extra_args + s_in = x.new_ones([x.shape[0]]) + step_id = 0 + + def heun_step(x, old_sigma, new_sigma, second_order=True): + nonlocal step_id + denoised = model(x, old_sigma * s_in, **extra_args) + d = to_d(x, old_sigma, denoised) + if callback is not None: + callback({'x': x, 'i': step_id, 'sigma': new_sigma, 'sigma_hat': old_sigma, 'denoised': denoised}) + dt = new_sigma - old_sigma + if new_sigma == 0 or not second_order: + # Euler method + x = x + d * dt + else: + # Heun's method + x_2 = x + d * dt + denoised_2 = model(x_2, new_sigma * s_in, **extra_args) + d_2 = to_d(x_2, new_sigma, denoised_2) + d_prime = (d + d_2) / 2 + x = x + d_prime * dt + step_id += 1 + return x + + steps = sigmas.shape[0] - 1 + if restart_list is None: + if steps >= 20: + restart_steps = 9 + restart_times = 1 + if steps >= 36: + restart_steps = steps // 4 + restart_times = 2 + sigmas = get_sigmas_karras(steps - restart_steps * restart_times, sigmas[-2].item(), sigmas[0].item(), device=sigmas.device) + restart_list = {0.1: [restart_steps + 1, restart_times, 2]} + else: + restart_list = {} + + restart_list = {int(torch.argmin(abs(sigmas - key), dim=0)): value for key, value in restart_list.items()} + + step_list = [] + for i in range(len(sigmas) - 1): + step_list.append((sigmas[i], sigmas[i + 1])) + if i + 1 in restart_list: + restart_steps, restart_times, restart_max = restart_list[i + 1] + min_idx = i + 1 + max_idx = int(torch.argmin(abs(sigmas - restart_max), dim=0)) + if max_idx < min_idx: + sigma_restart = get_sigmas_karras(restart_steps, sigmas[min_idx].item(), sigmas[max_idx].item(), device=sigmas.device)[:-1] + while restart_times > 0: + restart_times -= 1 + step_list.extend(zip(sigma_restart[:-1], sigma_restart[1:])) + + last_sigma = None + for old_sigma, new_sigma in tqdm(step_list, disable=disable): + if last_sigma is None: + last_sigma = old_sigma + elif last_sigma < old_sigma: + x = x + torch.randn_like(x) * s_noise * (old_sigma ** 2 - last_sigma ** 2) ** 0.5 + x = heun_step(x, old_sigma, new_sigma) + last_sigma = new_sigma + return x \ No newline at end of file diff --git a/ldm_patched/modules/samplers.py b/ldm_patched/modules/samplers.py index 9ed1fcd2..05b4b317 100644 --- a/ldm_patched/modules/samplers.py +++ b/ldm_patched/modules/samplers.py @@ -523,7 +523,7 @@ class UNIPCBH2(Sampler): KSAMPLER_NAMES = ["euler", "euler_ancestral", "heun", "heunpp2","dpm_2", "dpm_2_ancestral", "lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu", - "dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu", "ddpm", "lcm", "tcd", "edm_playground_v2.5"] + "dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu", "ddpm", "lcm", "tcd", "edm_playground_v2.5", "restart"] class KSAMPLER(Sampler): def __init__(self, sampler_function, extra_options={}, inpaint_options={}): diff --git a/modules/flags.py b/modules/flags.py index 29ac4615..2addb843 100644 --- a/modules/flags.py +++ b/modules/flags.py @@ -35,7 +35,8 @@ KSAMPLER = { "dpmpp_3m_sde_gpu": "", "ddpm": "", "lcm": "LCM", - "tcd": "TCD" + "tcd": "TCD", + "restart": "Restart" } SAMPLER_EXTRA = { From 33b1c5cb87bfeccc51d08cda4558721112861e63 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 17:20:20 +0200 Subject: [PATCH 12/22] feat: add hash_cache --- .gitignore | 1 + modules/config.py | 4 ++++ modules/hash_cache.py | 41 +++++++++++++++++++++++++++++++++++++++++ modules/meta_parser.py | 20 ++++++-------------- 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 modules/hash_cache.py diff --git a/.gitignore b/.gitignore index 85914986..8408db59 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__ *.partial *.onnx sorted_styles.json +hash_cache.json /input /cache /language/default.json diff --git a/modules/config.py b/modules/config.py index a6767c37..1fd4412b 100644 --- a/modules/config.py +++ b/modules/config.py @@ -7,6 +7,7 @@ import args_manager import tempfile import modules.flags import modules.sdxl_styles +from modules.hash_cache import load_cache_from_file, save_cache_to_file from modules.model_loader import load_file_from_url from modules.extra_utils import makedirs_with_log, get_files_from_folder, try_eval_env_var @@ -755,3 +756,6 @@ def downloading_safety_checker_model(): update_files() +load_cache_from_file() +# write cache to file again for cleanup of invalid cache entries +save_cache_to_file() diff --git a/modules/hash_cache.py b/modules/hash_cache.py new file mode 100644 index 00000000..bc9f479b --- /dev/null +++ b/modules/hash_cache.py @@ -0,0 +1,41 @@ +from modules.util import sha256, HASH_SHA256_LENGTH +import os +import json +hash_cache_filename = 'hash_cache.json' +hash_cache = {} + + +def sha256_from_cache(filepath): + global hash_cache + if filepath not in hash_cache: + hash_cache[filepath] = sha256(filepath) + save_cache_to_file() + + return hash_cache[filepath] + + +def load_cache_from_file(): + global hash_cache + + try: + if os.path.exists(hash_cache_filename): + with open(hash_cache_filename, 'rt', encoding='utf-8') as fp: + for filepath, hash in json.load(fp).items(): + if not os.path.exists(filepath) or not isinstance(hash, str) and len(hash) != HASH_SHA256_LENGTH: + print(f'[Cache] Skipping invalid cache entry: {filepath}') + continue + hash_cache[filepath] = hash + print(f'[Cache] Warmed cache from file') + except Exception as e: + print(f'[Cache] Warming failed: {e}') + + +def save_cache_to_file(): + global hash_cache + + try: + with open(hash_cache_filename, 'wt', encoding='utf-8') as fp: + json.dump(hash_cache, fp, indent=4) + print(f'[Cache] Updated cache file') + except Exception as e: + print(f'[Cache] Saving failed: {e}') diff --git a/modules/meta_parser.py b/modules/meta_parser.py index ff930cc0..307b656d 100644 --- a/modules/meta_parser.py +++ b/modules/meta_parser.py @@ -9,16 +9,16 @@ from PIL import Image import fooocus_version import modules.config import modules.sdxl_styles +from modules import hash_cache from modules.flags import MetadataScheme, Performance, Steps from modules.flags import SAMPLERS, CIVITAI_NO_KARRAS -from modules.util import quote, unquote, extract_styles_from_prompt, is_json, get_file_from_folder_list, sha256 +from modules.hash_cache import sha256_from_cache +from modules.util import quote, unquote, extract_styles_from_prompt, is_json, get_file_from_folder_list re_param_code = r'\s*(\w[\w \-/]+):\s*("(?:\\.|[^\\"])+"|[^,]*)(?:,|$)' re_param = re.compile(re_param_code) re_imagesize = re.compile(r"^(\d+)x(\d+)$") -hash_cache = {} - def load_parameter_button_click(raw_metadata: dict | str, is_generating: bool): loaded_parameter_dict = raw_metadata @@ -215,14 +215,6 @@ def get_lora(key: str, fallback: str | None, source_dict: dict, results: list, p results.append(1) -def get_sha256(filepath): - global hash_cache - if filepath not in hash_cache: - hash_cache[filepath] = sha256(filepath) - - return hash_cache[filepath] - - def parse_meta_from_preset(preset_content): assert isinstance(preset_content, dict) preset_prepared = {} @@ -290,18 +282,18 @@ class MetadataParser(ABC): self.base_model_name = Path(base_model_name).stem base_model_path = get_file_from_folder_list(base_model_name, modules.config.paths_checkpoints) - self.base_model_hash = get_sha256(base_model_path) + self.base_model_hash = sha256_from_cache(base_model_path) if refiner_model_name not in ['', 'None']: self.refiner_model_name = Path(refiner_model_name).stem refiner_model_path = get_file_from_folder_list(refiner_model_name, modules.config.paths_checkpoints) - self.refiner_model_hash = get_sha256(refiner_model_path) + self.refiner_model_hash = sha256_from_cache(refiner_model_path) self.loras = [] for (lora_name, lora_weight) in loras: if lora_name != 'None': lora_path = get_file_from_folder_list(lora_name, modules.config.paths_loras) - lora_hash = get_sha256(lora_path) + lora_hash = sha256_from_cache(lora_path) self.loras.append((Path(lora_name).stem, lora_weight, lora_hash)) self.vae_name = Path(vae_name).stem From 1fa7eeac84b261f76481f93d77c80e6f9ae5a4c0 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 17:21:30 +0200 Subject: [PATCH 13/22] feat: change type of hash_cache file to txt, append to file if single line is provided --- .gitignore | 2 +- modules/hash_cache.py | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 8408db59..5bf633a8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ __pycache__ *.partial *.onnx sorted_styles.json -hash_cache.json +hash_cache.txt /input /cache /language/default.json diff --git a/modules/hash_cache.py b/modules/hash_cache.py index bc9f479b..b2117ae9 100644 --- a/modules/hash_cache.py +++ b/modules/hash_cache.py @@ -1,15 +1,18 @@ -from modules.util import sha256, HASH_SHA256_LENGTH -import os import json -hash_cache_filename = 'hash_cache.json' +import os + +from modules.util import sha256, HASH_SHA256_LENGTH + +hash_cache_filename = 'hash_cache.txt' hash_cache = {} def sha256_from_cache(filepath): global hash_cache if filepath not in hash_cache: - hash_cache[filepath] = sha256(filepath) - save_cache_to_file() + hash_value = sha256(filepath) + hash_cache[filepath] = hash_value + save_cache_to_file(filepath, hash_value) return hash_cache[filepath] @@ -20,22 +23,33 @@ def load_cache_from_file(): try: if os.path.exists(hash_cache_filename): with open(hash_cache_filename, 'rt', encoding='utf-8') as fp: - for filepath, hash in json.load(fp).items(): - if not os.path.exists(filepath) or not isinstance(hash, str) and len(hash) != HASH_SHA256_LENGTH: - print(f'[Cache] Skipping invalid cache entry: {filepath}') - continue - hash_cache[filepath] = hash + for line in fp: + entry = json.loads(line) + for filepath, hash_value in entry.items(): + if not os.path.exists(filepath) or not isinstance(hash_value, str) and len(hash_value) != HASH_SHA256_LENGTH: + print(f'[Cache] Skipping invalid cache entry: {filepath}') + continue + hash_cache[filepath] = hash_value print(f'[Cache] Warmed cache from file') except Exception as e: print(f'[Cache] Warming failed: {e}') -def save_cache_to_file(): +def save_cache_to_file(filename=None, hash_value=None): global hash_cache + if filename is not None and hash_value is not None: + items = [(filename, hash_value)] + mode = 'at' + else: + items = sorted(hash_cache.items()) + mode = 'wt' + try: - with open(hash_cache_filename, 'wt', encoding='utf-8') as fp: - json.dump(hash_cache, fp, indent=4) + with open(hash_cache_filename, mode, encoding='utf-8') as fp: + for filepath, hash_value in items: + json.dump({filepath: hash_value}, fp) + fp.write('\n') print(f'[Cache] Updated cache file') except Exception as e: print(f'[Cache] Saving failed: {e}') From b19ecf410b6cc7e69311385eb7750dbe1c9bf4e7 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 17:44:52 +0200 Subject: [PATCH 14/22] feat: add attribute --rebuild-hash-cache, add handling --- args_manager.py | 5 ++++- modules/config.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/args_manager.py b/args_manager.py index 5a2b37c9..27fe14a5 100644 --- a/args_manager.py +++ b/args_manager.py @@ -32,7 +32,10 @@ args_parser.parser.add_argument("--enable-describe-uov-image", action='store_tru help="Disables automatic description of uov images when prompt is empty", default=False) args_parser.parser.add_argument("--always-download-new-model", action='store_true', - help="Always download newer models ", default=False) + help="Always download newer models", default=False) + +args_parser.parser.add_argument("--rebuild-hash-cache", action='store_true', + help="Generates missing model and LoRA hashes.", default=False) args_parser.parser.set_defaults( disable_cuda_malloc=True, diff --git a/modules/config.py b/modules/config.py index 1fd4412b..2f958ff6 100644 --- a/modules/config.py +++ b/modules/config.py @@ -757,5 +757,17 @@ def downloading_safety_checker_model(): update_files() load_cache_from_file() -# write cache to file again for cleanup of invalid cache entries + +if args_manager.args.rebuild_hash_cache: + from modules.hash_cache import sha256_from_cache + from modules.util import get_file_from_folder_list + + for filename in model_filenames: + filepath = get_file_from_folder_list(filename, paths_checkpoints) + sha256_from_cache(filepath) + for filename in lora_filenames: + filepath = get_file_from_folder_list(filename, paths_loras) + sha256_from_cache(filepath) + +# write cache to file again for sorting and cleanup of invalid cache entries save_cache_to_file() From df2dd194cca115f92274cb1c4bbb66f0ef2282e9 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 17:54:20 +0200 Subject: [PATCH 15/22] feat: only use hash cache logs for exceptions --- modules/config.py | 2 ++ modules/hash_cache.py | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/config.py b/modules/config.py index 2f958ff6..e9e6b1cf 100644 --- a/modules/config.py +++ b/modules/config.py @@ -762,12 +762,14 @@ if args_manager.args.rebuild_hash_cache: from modules.hash_cache import sha256_from_cache from modules.util import get_file_from_folder_list + print('[Cache] Rebuilding hash cache') for filename in model_filenames: filepath = get_file_from_folder_list(filename, paths_checkpoints) sha256_from_cache(filepath) for filename in lora_filenames: filepath = get_file_from_folder_list(filename, paths_loras) sha256_from_cache(filepath) + print('[Cache] Done') # write cache to file again for sorting and cleanup of invalid cache entries save_cache_to_file() diff --git a/modules/hash_cache.py b/modules/hash_cache.py index b2117ae9..10566560 100644 --- a/modules/hash_cache.py +++ b/modules/hash_cache.py @@ -30,9 +30,8 @@ def load_cache_from_file(): print(f'[Cache] Skipping invalid cache entry: {filepath}') continue hash_cache[filepath] = hash_value - print(f'[Cache] Warmed cache from file') except Exception as e: - print(f'[Cache] Warming failed: {e}') + print(f'[Cache] Loading failed: {e}') def save_cache_to_file(filename=None, hash_value=None): @@ -50,6 +49,5 @@ def save_cache_to_file(filename=None, hash_value=None): for filepath, hash_value in items: json.dump({filepath: hash_value}, fp) fp.write('\n') - print(f'[Cache] Updated cache file') except Exception as e: print(f'[Cache] Saving failed: {e}') From f3a44b21d84fbf62ffcc2c044ba0640bdc6fbb20 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 19:50:34 +0200 Subject: [PATCH 16/22] feat: allow default_overwrite_switch in preset --- modules/config.py | 1 + presets/anime.json | 1 + presets/default.json | 1 + presets/hyper-sd.json | 1 + presets/lcm.json | 1 + presets/playground_v2.5.json | 1 + presets/pony_v6.json | 4 ++-- presets/realistic.json | 1 + presets/sai.json | 1 + 9 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/config.py b/modules/config.py index 28deb6df..42505f27 100644 --- a/modules/config.py +++ b/modules/config.py @@ -631,6 +631,7 @@ possible_preset_keys = { "default_sampler": "sampler", "default_scheduler": "scheduler", "default_overwrite_step": "steps", + "default_overwrite_switch": "overwrite_switch", "default_performance": "performance", "default_image_number": "image_number", "default_prompt": "prompt", diff --git a/presets/anime.json b/presets/anime.json index bf735c9b..fa4e34be 100644 --- a/presets/anime.json +++ b/presets/anime.json @@ -43,6 +43,7 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "animaPencilXL_v500.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v500.safetensors" }, diff --git a/presets/default.json b/presets/default.json index e9aa2b62..0a1ad863 100644 --- a/presets/default.json +++ b/presets/default.json @@ -43,6 +43,7 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/hyper-sd.json b/presets/hyper-sd.json index 700b694d..67e06739 100644 --- a/presets/hyper-sd.json +++ b/presets/hyper-sd.json @@ -43,6 +43,7 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/lcm.json b/presets/lcm.json index 441cbdc8..cca37956 100644 --- a/presets/lcm.json +++ b/presets/lcm.json @@ -43,6 +43,7 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/playground_v2.5.json b/presets/playground_v2.5.json index f4afaa9a..34fa29b6 100644 --- a/presets/playground_v2.5.json +++ b/presets/playground_v2.5.json @@ -41,6 +41,7 @@ ], "default_aspect_ratio": "1024*1024", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", "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" diff --git a/presets/pony_v6.json b/presets/pony_v6.json index 8a3a962a..b5230f89 100644 --- a/presets/pony_v6.json +++ b/presets/pony_v6.json @@ -1,7 +1,7 @@ { "default_model": "ponyDiffusionV6XL.safetensors", "default_refiner": "None", - "default_refiner_switch": 0.5, + "default_refiner_switch": 1, "default_vae": "ponyDiffusionV6XL_vae.safetensors", "default_loras": [ [ @@ -42,7 +42,7 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, - "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", + "default_overwrite_switch": 999, "checkpoint_downloads": { "ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors" }, diff --git a/presets/realistic.json b/presets/realistic.json index f2d4773f..33d66702 100644 --- a/presets/realistic.json +++ b/presets/realistic.json @@ -43,6 +43,7 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "realisticStockPhoto_v20.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticStockPhoto_v20.safetensors" }, diff --git a/presets/sai.json b/presets/sai.json index 21146311..9bfed082 100644 --- a/presets/sai.json +++ b/presets/sai.json @@ -42,6 +42,7 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "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_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" From 49d898f6c78ccec5a7ce132a36b08765fdb01e53 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 19:50:34 +0200 Subject: [PATCH 17/22] wip: set default_overwrite_switch for pony preset synthetic refiner introduces artifacts, overriding refiner switch disables all refiners (never switches to them) discussion in https://github.com/lllyasviel/Fooocus/discussions/3217#discussioncomment-9928035 --- modules/config.py | 1 + presets/anime.json | 2 ++ presets/default.json | 2 ++ presets/lcm.json | 2 ++ presets/playground_v2.5.json | 1 + presets/pony_v6.json | 4 ++-- presets/realistic.json | 2 ++ presets/sai.json | 2 ++ 8 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/config.py b/modules/config.py index 8ab5edb8..cbc919ec 100644 --- a/modules/config.py +++ b/modules/config.py @@ -549,6 +549,7 @@ possible_preset_keys = { "default_sampler": "sampler", "default_scheduler": "scheduler", "default_overwrite_step": "steps", + "default_overwrite_switch": "overwrite_switch", "default_performance": "performance", "default_image_number": "image_number", "default_prompt": "prompt", diff --git a/presets/anime.json b/presets/anime.json index 78607edb..7bcaad89 100644 --- a/presets/anime.json +++ b/presets/anime.json @@ -42,6 +42,8 @@ "Fooocus Masterpiece" ], "default_aspect_ratio": "896*1152", + "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "animaPencilXL_v310.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v310.safetensors" }, diff --git a/presets/default.json b/presets/default.json index d02bb8a4..0a1ad863 100644 --- a/presets/default.json +++ b/presets/default.json @@ -42,6 +42,8 @@ "Fooocus Sharp" ], "default_aspect_ratio": "1152*896", + "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/lcm.json b/presets/lcm.json index 6713fdd5..cca37956 100644 --- a/presets/lcm.json +++ b/presets/lcm.json @@ -42,6 +42,8 @@ "Fooocus Sharp" ], "default_aspect_ratio": "1152*896", + "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/playground_v2.5.json b/presets/playground_v2.5.json index f4afaa9a..34fa29b6 100644 --- a/presets/playground_v2.5.json +++ b/presets/playground_v2.5.json @@ -41,6 +41,7 @@ ], "default_aspect_ratio": "1024*1024", "default_overwrite_step": -1, + "default_overwrite_switch": -1, "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", "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" diff --git a/presets/pony_v6.json b/presets/pony_v6.json index 8a3a962a..b5230f89 100644 --- a/presets/pony_v6.json +++ b/presets/pony_v6.json @@ -1,7 +1,7 @@ { "default_model": "ponyDiffusionV6XL.safetensors", "default_refiner": "None", - "default_refiner_switch": 0.5, + "default_refiner_switch": 1, "default_vae": "ponyDiffusionV6XL_vae.safetensors", "default_loras": [ [ @@ -42,7 +42,7 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, - "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", + "default_overwrite_switch": 999, "checkpoint_downloads": { "ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors" }, diff --git a/presets/realistic.json b/presets/realistic.json index 6db6d0b7..33d66702 100644 --- a/presets/realistic.json +++ b/presets/realistic.json @@ -42,6 +42,8 @@ "Fooocus Negative" ], "default_aspect_ratio": "896*1152", + "default_overwrite_step": -1, + "default_overwrite_switch": -1, "checkpoint_downloads": { "realisticStockPhoto_v20.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticStockPhoto_v20.safetensors" }, diff --git a/presets/sai.json b/presets/sai.json index 918028f3..9bfed082 100644 --- a/presets/sai.json +++ b/presets/sai.json @@ -41,6 +41,8 @@ "Fooocus Cinematic" ], "default_aspect_ratio": "1152*896", + "default_overwrite_step": -1, + "default_overwrite_switch": -1, "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_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" From 5a71495822a11bbabf7c889eed6d9b38b261bb96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:03:25 +0200 Subject: [PATCH 18/22] build(deps): bump docker/build-push-action from 5 to 6 (#3223) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5...v6) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build_container.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_container.yml b/.github/workflows/build_container.yml index eb70cda3..16056db8 100644 --- a/.github/workflows/build_container.yml +++ b/.github/workflows/build_container.yml @@ -38,7 +38,7 @@ jobs: type=edge,branch=main - name: Build and push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile From 33c22929e4f0965862e4957cc6ba4d99d4324515 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 22:08:52 +0200 Subject: [PATCH 19/22] 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) --- modules/config.py | 5 +++-- modules/meta_parser.py | 14 ++++++++++++++ presets/anime.json | 1 - presets/default.json | 1 - presets/lcm.json | 1 - presets/playground_v2.5.json | 3 +-- presets/pony_v6.json | 4 ++-- presets/realistic.json | 1 - presets/sai.json | 1 - webui.py | 17 ++++++++++------- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/modules/config.py b/modules/config.py index cbc919ec..9c5272f5 100644 --- a/modules/config.py +++ b/modules/config.py @@ -533,7 +533,7 @@ example_inpaint_prompts = [[x] for x in example_inpaint_prompts] config_dict["default_loras"] = default_loras = default_loras[:default_max_lora_number] + [[True, 'None', 1.0] for _ in range(default_max_lora_number - len(default_loras))] -# mapping config to meta parameter +# mapping config to meta parameter possible_preset_keys = { "default_model": "base_model", "default_refiner": "refiner_model", @@ -562,7 +562,8 @@ possible_preset_keys = { "lora_downloads": "lora_downloads", "vae_downloads": "vae_downloads", "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 diff --git a/modules/meta_parser.py b/modules/meta_parser.py index e5ba765f..628ec402 100644 --- a/modules/meta_parser.py +++ b/modules/meta_parser.py @@ -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_engine_version('inpaint_engine_version', 'Inpaint Engine Version', loaded_parameter_dict, results) get_inpaint_method('inpaint_method', 'Inpaint Mode', loaded_parameter_dict, results) 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()) +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: try: h = source_dict.get(key, source_dict.get(fallback, default)) diff --git a/presets/anime.json b/presets/anime.json index 7bcaad89..debfeb84 100644 --- a/presets/anime.json +++ b/presets/anime.json @@ -43,7 +43,6 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, - "default_overwrite_switch": -1, "checkpoint_downloads": { "animaPencilXL_v310.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/animaPencilXL_v310.safetensors" }, diff --git a/presets/default.json b/presets/default.json index 0a1ad863..e9aa2b62 100644 --- a/presets/default.json +++ b/presets/default.json @@ -43,7 +43,6 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, - "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/lcm.json b/presets/lcm.json index cca37956..441cbdc8 100644 --- a/presets/lcm.json +++ b/presets/lcm.json @@ -43,7 +43,6 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, - "default_overwrite_switch": -1, "checkpoint_downloads": { "juggernautXL_v8Rundiffusion.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_v8Rundiffusion.safetensors" }, diff --git a/presets/playground_v2.5.json b/presets/playground_v2.5.json index 34fa29b6..ac28c260 100644 --- a/presets/playground_v2.5.json +++ b/presets/playground_v2.5.json @@ -41,8 +41,7 @@ ], "default_aspect_ratio": "1024*1024", "default_overwrite_step": -1, - "default_overwrite_switch": -1, - "default_inpaint_method": "Improve Detail (face, hand, eyes, etc.)", + "default_inpaint_engine_version": "None", "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" }, diff --git a/presets/pony_v6.json b/presets/pony_v6.json index b5230f89..549d7c52 100644 --- a/presets/pony_v6.json +++ b/presets/pony_v6.json @@ -1,7 +1,7 @@ { "default_model": "ponyDiffusionV6XL.safetensors", "default_refiner": "None", - "default_refiner_switch": 1, + "default_refiner_switch": 0.5, "default_vae": "ponyDiffusionV6XL_vae.safetensors", "default_loras": [ [ @@ -42,7 +42,7 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, - "default_overwrite_switch": 999, + "default_inpaint_engine_version": "None", "checkpoint_downloads": { "ponyDiffusionV6XL.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/ponyDiffusionV6XL.safetensors" }, diff --git a/presets/realistic.json b/presets/realistic.json index 33d66702..f2d4773f 100644 --- a/presets/realistic.json +++ b/presets/realistic.json @@ -43,7 +43,6 @@ ], "default_aspect_ratio": "896*1152", "default_overwrite_step": -1, - "default_overwrite_switch": -1, "checkpoint_downloads": { "realisticStockPhoto_v20.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticStockPhoto_v20.safetensors" }, diff --git a/presets/sai.json b/presets/sai.json index 9bfed082..21146311 100644 --- a/presets/sai.json +++ b/presets/sai.json @@ -42,7 +42,6 @@ ], "default_aspect_ratio": "1152*896", "default_overwrite_step": -1, - "default_overwrite_switch": -1, "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_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" diff --git a/webui.py b/webui.py index d8e5ffe4..6fd1da7b 100644 --- a/webui.py +++ b/webui.py @@ -100,6 +100,7 @@ shared.gradio_root = gr.Blocks(title=title).queue() with shared.gradio_root: currentTask = gr.State(worker.AsyncTask(args=[])) + inpaint_engine_state = gr.State('empty') with gr.Row(): with gr.Column(scale=2): with gr.Row(): @@ -589,8 +590,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, inpaint_mode, generate_button, load_parameter_button - ] + freeu_ctrls + lora_ctrls + seed_random, image_seed, inpaint_engine, inpaint_engine_state, 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): @@ -632,7 +633,7 @@ with shared.gradio_root: 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 # 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), 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: return [ gr.update(visible=True), gr.update(visible=False, value=[]), 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 [ gr.update(visible=False, value=''), gr.update(visible=True), 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_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=[ + shared.gradio_root.load(inpaint_mode_change, inputs=[inpaint_mode, inpaint_engine_state], outputs=[ inpaint_additional_prompt, outpaint_selections, example_inpaint_prompts, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field From 0c2d66e2e582507f6a65a5fba8ad3694c9ad35d7 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 23:26:30 +0200 Subject: [PATCH 20/22] fix: do not update inpaint engine if inpaint mode is details --- modules/meta_parser.py | 11 +++++++---- webui.py | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/meta_parser.py b/modules/meta_parser.py index 628ec402..87a501b3 100644 --- a/modules/meta_parser.py +++ b/modules/meta_parser.py @@ -20,7 +20,7 @@ re_imagesize = re.compile(r"^(\d+)x(\d+)$") hash_cache = {} -def load_parameter_button_click(raw_metadata: dict | str, is_generating: bool): +def load_parameter_button_click(raw_metadata: dict | str, is_generating: bool, inpaint_mode: str): loaded_parameter_dict = raw_metadata if isinstance(raw_metadata, str): loaded_parameter_dict = json.loads(raw_metadata) @@ -49,7 +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_engine_version('inpaint_engine_version', 'Inpaint Engine Version', loaded_parameter_dict, results) + get_inpaint_engine_version('inpaint_engine_version', 'Inpaint Engine Version', loaded_parameter_dict, results, inpaint_mode) get_inpaint_method('inpaint_method', 'Inpaint Mode', loaded_parameter_dict, results) if is_generating: @@ -162,11 +162,14 @@ def get_seed(key: str, fallback: str | None, source_dict: dict, results: list, d results.append(gr.update()) -def get_inpaint_engine_version(key: str, fallback: str | None, source_dict: dict, results: list, default=None) -> str | None: +def get_inpaint_engine_version(key: str, fallback: str | None, source_dict: dict, results: list, inpaint_mode: str, 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) + if inpaint_mode != modules.flags.inpaint_option_detail: + results.append(h) + else: + results.append(gr.update()) results.append(h) return h except: diff --git a/webui.py b/webui.py index 6fd1da7b..bf599af1 100644 --- a/webui.py +++ b/webui.py @@ -594,7 +594,7 @@ with shared.gradio_root: generate_button, load_parameter_button] + freeu_ctrls + lora_ctrls if not args_manager.args.disable_preset_selection: - def preset_selection_change(preset, is_generating): + def preset_selection_change(preset, is_generating, inpaint_mode): preset_content = modules.config.try_get_preset_content(preset) if preset != 'initial' else {} preset_prepared = modules.meta_parser.parse_meta_from_preset(preset_content) @@ -612,9 +612,9 @@ with shared.gradio_root: if 'prompt' in preset_prepared and preset_prepared.get('prompt') == '': del preset_prepared['prompt'] - return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared), is_generating) + return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared), is_generating, inpaint_mode) - preset_selection.change(preset_selection_change, inputs=[preset_selection, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \ + preset_selection.change(preset_selection_change, inputs=[preset_selection, state_is_generating, inpaint_mode], outputs=load_data_outputs, queue=False, show_progress=True) \ .then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) performance_selection.change(lambda x: [gr.update(interactive=not flags.Performance.has_restricted_features(x))] * 11 + @@ -716,7 +716,7 @@ with shared.gradio_root: prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False) - load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=False) + load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating, inpaint_mode], outputs=load_data_outputs, queue=False, show_progress=False) def trigger_metadata_import(filepath, state_is_generating): parameters, metadata_scheme = modules.meta_parser.read_info_from_image(filepath) @@ -727,7 +727,7 @@ with shared.gradio_root: metadata_parser = modules.meta_parser.get_metadata_parser(metadata_scheme) parsed_parameters = metadata_parser.to_json(parameters) - return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating) + return modules.meta_parser.load_parameter_button_click(parsed_parameters, state_is_generating, inpaint_mode) metadata_import_button.click(trigger_metadata_import, inputs=[metadata_input_image, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \ .then(style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) From 14874af65c020c9a020a9581f5508c12b0f2dc44 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 7 Jul 2024 14:26:48 +0200 Subject: [PATCH 21/22] feat: update SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4 to SDXL_FILM_PHOTOGRAPHY_STYLE_V1 --- presets/realistic.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/presets/realistic.json b/presets/realistic.json index f2d4773f..8402bbc1 100644 --- a/presets/realistic.json +++ b/presets/realistic.json @@ -5,7 +5,7 @@ "default_loras": [ [ true, - "SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors", + "SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors", 0.25 ], [ @@ -48,7 +48,7 @@ }, "embeddings_downloads": {}, "lora_downloads": { - "SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors": "https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4.safetensors" + "SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors": "https://huggingface.co/mashb1t/fav_models/resolve/main/fav/SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors" }, "previous_default_models": ["realisticStockPhoto_v10.safetensors"] } \ No newline at end of file From 58559bd62bc7f1c11b3e3985f7eba107fd6bf37c Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 7 Jul 2024 15:01:28 +0200 Subject: [PATCH 22/22] release: bump version to 2.6.0-rc1, update changelog --- fooocus_version.py | 2 +- readme.md | 10 +++++----- update_log.md | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fooocus_version.py b/fooocus_version.py index 36fac3bb..a37e9c40 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.5.2 (mashb1t)' +version = '2.6.0-rc1 (mashb1t)' diff --git a/readme.md b/readme.md index dd341db6..190708a4 100644 --- a/readme.md +++ b/readme.md @@ -487,11 +487,11 @@ See the common problems [here](troubleshoot.md). Given different goals, the default models and configs of Fooocus are different: -| Task | Windows | Linux args | Main Model | Refiner | Config | -| --- | --- | --- | --- | --- |--------------------------------------------------------------------------------| -| General | run.bat | | juggernautXL_v8Rundiffusion | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/default.json) | -| Realistic | run_realistic.bat | --preset realistic | realisticStockPhoto_v20 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/realistic.json) | -| Anime | run_anime.bat | --preset anime | animaPencilXL_v100 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/anime.json) | +| Task | Windows | Linux args | Main Model | Refiner | Config | +|-----------| --- | --- |-----------------------------| --- |--------------------------------------------------------------------------------| +| General | run.bat | | juggernautXL_v8Rundiffusion | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/default.json) | +| Realistic | run_realistic.bat | --preset realistic | realisticStockPhoto_v20 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/realistic.json) | +| Anime | run_anime.bat | --preset anime | animaPencilXL_v500 | not used | [here](https://github.com/lllyasviel/Fooocus/blob/main/presets/anime.json) | Note that the download is **automatic** - you do not need to do anything if the internet connection is okay. However, you can download them manually if you (or move them from somewhere else) have your own preparation. diff --git a/update_log.md b/update_log.md index 2ba79f48..03b8b9fb 100644 --- a/update_log.md +++ b/update_log.md @@ -1,3 +1,17 @@ +# [2.6.0-rc1](https://github.com/mashb1t/Fooocus/releases/tag/v2.6.0-rc1) + +* Update default models to latest versions + * animaPencilXL_v400 => animaPencilXL_v500 + * DreamShaperXL_Turbo_dpmppSdeKarras => DreamShaperXL_Turbo_v2_1 + * SDXL_FILM_PHOTOGRAPHY_STYLE_BetaV0.4 => SDXL_FILM_PHOTOGRAPHY_STYLE_V1 +* Add preset for pony_v6 (using ponyDiffusionV6XL) +* Add style `Fooocus Pony` +* Add restart sampler ([paper](https://arxiv.org/abs/2306.14878)) +* Add config option for default_inpaint_engine_version, sets inpaint engine for pony_v6 and playground_v2.5 to None for improved results (incompatible with inpaint engine) +* Add image editor functionality to mask upload (same as for inpaint, now correctly resizes and allows more detailed mask creation) +* Add persistent model cache for metadata. Use `--rebuild-hash-cache` to manually rebuild the cache for all non-cached hashes +* Rename `--enable-describe-uov-image` to `--enable-auto-describe-image` to better reflect its purpose (now also works for enhance image upload) + # [2.5.2](https://github.com/mashb1t/Fooocus/releases/tag/v2.5.2) * Add missing prompt return values for `Upscale (Fast 2x)` in enhance