From afb9cd0b661886a18ce8e0a9cc3ac36d4a3af7d9 Mon Sep 17 00:00:00 2001 From: whiteSkar Date: Mon, 26 Feb 2024 03:08:53 -0800 Subject: [PATCH] Fix ADetailer prompt in PNG Info showing the original prompt when ADetailer S/R script is applied (#489) --- scripts/!adetailer.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 6e4c7ea..c16d665 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -648,6 +648,16 @@ class AfterDetailerScript(scripts.Script): if self.is_ad_enabled(*args_): arg_list = self.get_args(p, *args_) self.check_skip_img2img(p, *args_) + + # The extra_generation_params has the ADetailer prompt that will be saved in the png info + # In case S/R script has been applied, we need to return the replaced prompt and not the original one + # batch_index exists on p if the p is for the Adetailer p. + # If the p is for the image before Adetailer, batch_index does not seem to exist. + if hasattr(p, "_ad_xyz_prompt_sr") and hasattr(p, "batch_index"): + replaced_positive_prompt, replaced_negative_prompt = self.get_prompt(p, arg_list[0]) + arg_list[0].ad_prompt = replaced_positive_prompt[0] + arg_list[0].ad_negative_prompt = replaced_negative_prompt[0] + extra_params = self.extra_params(arg_list) p.extra_generation_params.update(extra_params) else: