From d6266eac55fbcf33ce49b4e4ff492bc8c62cbdde Mon Sep 17 00:00:00 2001 From: Hyeongmin Moon Date: Mon, 17 Apr 2023 12:18:18 +0900 Subject: [PATCH 1/2] fix to use the result prompt by other Extensions(e.g. Dynamic prompt) --- scripts/ddetailer.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/ddetailer.py b/scripts/ddetailer.py index 7841d8e..9d801b8 100644 --- a/scripts/ddetailer.py +++ b/scripts/ddetailer.py @@ -230,6 +230,12 @@ def run(self, p, info, masks_a = [] masks_b_pre = [] + init_prompts = init_image.info['parameters'].split('Negative prompt:') + init_pos_prompt = init_prompts[0].rstrip('\n') + init_neg_prompt = '' + if len(init_prompts) > 1: + init_neg_prompt = init_prompts[1].split('Steps:')[0].lstrip().rstrip('\n') + # Optional secondary pre-processing run if (dd_model_b != "None" and dd_preprocess_b): label_b_pre = "B" @@ -253,7 +259,11 @@ def run(self, p, info, p.image_mask = masks_b_pre[i] if ( opts.dd_save_masks): images.save_image(masks_b_pre[i], opts.outdir_ddetailer_masks, "", start_seed, p.prompt, opts.samples_format, p=p) + p.prompt = init_pos_prompt + p.negative_prompt = init_neg_prompt processed = processing.process_images(p) + p.prompt = p_txt.prompt + p.negative_prompt = p_text.negative_prompt p.seed = processed.seed + 1 p.init_images = processed.images @@ -313,7 +323,11 @@ def run(self, p, info, if ( opts.dd_save_masks): images.save_image(masks_a[i], opts.outdir_ddetailer_masks, "", start_seed, p.prompt, opts.samples_format, p=p) + p.prompt = init_pos_prompt + p.negative_prompt = init_neg_prompt processed = processing.process_images(p) + p.prompt = p_txt.prompt + p.negative_prompt = p_text.negative_prompt if initial_info is None: initial_info = processed.info p.seed = processed.seed + 1 From 357f1ed019fdb6a2b6e6d491a3c0bcd6438282b1 Mon Sep 17 00:00:00 2001 From: Hyeongmin Moon Date: Mon, 17 Apr 2023 13:48:16 +0900 Subject: [PATCH 2/2] fix typo, save metadata correctly --- scripts/ddetailer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ddetailer.py b/scripts/ddetailer.py index 9d801b8..ab16eec 100644 --- a/scripts/ddetailer.py +++ b/scripts/ddetailer.py @@ -263,7 +263,7 @@ def run(self, p, info, p.negative_prompt = init_neg_prompt processed = processing.process_images(p) p.prompt = p_txt.prompt - p.negative_prompt = p_text.negative_prompt + p.negative_prompt = p_txt.negative_prompt p.seed = processed.seed + 1 p.init_images = processed.images @@ -327,8 +327,8 @@ def run(self, p, info, p.negative_prompt = init_neg_prompt processed = processing.process_images(p) p.prompt = p_txt.prompt - p.negative_prompt = p_text.negative_prompt - if initial_info is None: + p.negative_prompt = p_txt.negative_prompt + if initial_info is None or initial_info != processed.info: initial_info = processed.info p.seed = processed.seed + 1 p.init_images = processed.images @@ -344,7 +344,7 @@ def run(self, p, info, if (initial_info is None): initial_info = "No detections found." - return Processed(p, output_images, seed, initial_info) + return Processed(p, output_images, seed, p_txt.prompt) def modeldataset(model_shortname): path = modelpath(model_shortname)