From abf2dd54014c20f9aa561d1007a215aa94bb83fb Mon Sep 17 00:00:00 2001 From: Bingsu Date: Fri, 26 May 2023 12:17:20 +0900 Subject: [PATCH] fix: call cn process only needed --- scripts/!adetailer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 7cc7216..3702e4d 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -434,6 +434,12 @@ class AfterDetailerScript(scripts.Script): i2i.prompt = prompt i2i.negative_prompt = negative_prompt + def is_need_call_process(self, p): + i = p._idx + n_iter = p.iteration + bs = p.batch_size + return (i == (n_iter + 1) * bs - 1) and (i != len(p.all_prompts) - 1) + def process(self, p, *args_): if getattr(p, "_disable_adetailer", False): return @@ -541,8 +547,8 @@ class AfterDetailerScript(scripts.Script): p, init_image, condition="ad_save_images_before", suffix="-ad-before" ) - if self.cn_script is not None: - self.cn_script.process(p) + if self.cn_script is not None and self.is_need_call_process(p): + self.cn_script.process(p) try: if p._idx == len(p.all_prompts) - 1: