From 00a27e74008500c4b1a72891307704f8c381c5bc Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 24 Jun 2024 21:21:11 +0200 Subject: [PATCH] feat: add config and option for uov prompt type --- modules/async_worker.py | 12 +++++++----- modules/config.py | 6 ++++++ modules/flags.py | 4 ++++ webui.py | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/modules/async_worker.py b/modules/async_worker.py index ada4f284..5550eb70 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -117,6 +117,7 @@ class AsyncTask: self.enhance_checkbox = args.pop() self.enhance_uov_method = args.pop() self.enhance_uov_processing_order = args.pop() + self.enhance_uov_prompt_type = args.pop() self.enhance_ctrls = [] for _ in range(modules.config.default_enhance_tabs): enhance_enabled = args.pop() @@ -1036,7 +1037,7 @@ def worker(): exception_result = '' if len(goals_enhance) > 0: try: - current_progress, img = process_enhance( + current_progress, img, prompt, negative_prompt = process_enhance( all_steps, async_task, callback, controlnet_canny_path, controlnet_cpds_path, current_progress, current_task_id, denoising_strength, False, 'None', 0.0, 0.0, prompt, negative_prompt, final_scheduler_name, @@ -1385,10 +1386,11 @@ def worker(): preparation_steps, enhance_steps, switch, tiled, total_count, use_expansion, use_style, use_synthetic_refiner, width) - if enhance_prompt_processed != '': - last_enhance_prompt = enhance_prompt_processed - if enhance_negative_prompt_processed != '': - last_enhance_negative_prompt = enhance_negative_prompt_processed + if async_task.enhance_uov_prompt_type == flags.enhancement_uov_prompt_type_last: + if enhance_prompt_processed != '': + last_enhance_prompt = enhance_prompt_processed + if enhance_negative_prompt_processed != '': + last_enhance_negative_prompt = enhance_negative_prompt_processed except ldm_patched.modules.model_management.InterruptProcessingException: if async_task.last_stop == 'skip': diff --git a/modules/config.py b/modules/config.py index d985f118..9b4f6877 100644 --- a/modules/config.py +++ b/modules/config.py @@ -521,6 +521,12 @@ enhance_uov_processing_order = get_config_item_or_set_default( validator=lambda x: x in modules.flags.enhancement_uov_processing_order, expected_type=int ) +enhance_uov_prompt_type = get_config_item_or_set_default( + key='default_enhance_uov_prompt_type', + default_value=modules.flags.enhancement_uov_prompt_type_last, + validator=lambda x: x in modules.flags.enhancement_uov_prompt_types, + expected_type=int +) default_sam_max_detections = get_config_item_or_set_default( key='default_sam_max_detections', default_value=0, diff --git a/modules/flags.py b/modules/flags.py index 4050b21b..7c77cafe 100644 --- a/modules/flags.py +++ b/modules/flags.py @@ -21,6 +21,10 @@ enhancement_uov_processing_order = [ (enhancement_uov_after_label, enhancement_uov_after) ] +enhancement_uov_prompt_type_original = 'Original Prompts' +enhancement_uov_prompt_type_last = 'Last Filled Enhancement Prompts' +enhancement_uov_prompt_types = [enhancement_uov_prompt_type_original, enhancement_uov_prompt_type_last] + CIVITAI_NO_KARRAS = ["euler", "euler_ancestral", "heun", "dpm_fast", "dpm_adaptive", "ddim", "uni_pc"] # fooocus: a1111 (Civitai) diff --git a/webui.py b/webui.py index abaf1994..5879c2dc 100644 --- a/webui.py +++ b/webui.py @@ -359,9 +359,19 @@ with shared.gradio_root: with gr.Column(): enhance_uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled) enhance_uov_processing_order = gr.Radio(label='Order of Processing', - info='Before is slower (larger area to enhance), but might enhance the overall image quality, whereas after is faster but may apply changes to the image which were already fixed by enhance. Use after when enhancing large areas.', + info='Use before for enhancement of small details and after for large areas.', choices=flags.enhancement_uov_processing_order, value=modules.config.enhance_uov_processing_order) + enhance_uov_prompt_type = gr.Radio(label='Prompt', + info='Choose which prompt to use for Upscale or Variation.', + choices=flags.enhancement_uov_prompt_types, + value=modules.config.enhance_uov_prompt_type, + visible=modules.config.enhance_uov_prompt_type == flags.enhancement_uov_after) + + enhance_uov_processing_order.change(lambda x: gr.update(visible=x == flags.enhancement_uov_after), + inputs=enhance_uov_processing_order, + outputs=enhance_uov_prompt_type, + queue=False, show_progress=False) gr.HTML('\U0001F4D4 Document') enhance_ctrls = [] for index in range(modules.config.default_enhance_tabs): @@ -943,7 +953,8 @@ with shared.gradio_root: ctrls += ip_ctrls ctrls += [debugging_dino, dino_erode_or_dilate, debugging_enhance_masks_checkbox, - enhance_input_image, enhance_checkbox, enhance_uov_method, enhance_uov_processing_order] + enhance_input_image, enhance_checkbox, enhance_uov_method, enhance_uov_processing_order, + enhance_uov_prompt_type] ctrls += enhance_ctrls def parse_meta(raw_prompt_txt, is_generating):