From a5922caa69dc1511c2b81e038350e3a102394196 Mon Sep 17 00:00:00 2001 From: ototadana Date: Tue, 16 May 2023 23:56:53 +0900 Subject: [PATCH] fix extension related bugs --- README.md | 2 +- scripts/face_editor.py | 6 ++++-- scripts/face_editor_extension.py | 13 +++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b877236..79b8b66 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ This is the parameter for [step-4](#step-4). Specify whether to save the image before modification. For more information, please see: [here](https://github.com/ototadana/sd-face-editor/issues/7#issuecomment-1505091410). -### Show intermediate steps (img2img only) +### Show intermediate steps Specifies whether to display images of detected faces and masks. ### Apply scripts to faces diff --git a/scripts/face_editor.py b/scripts/face_editor.py index 269700b..3ff9fac 100644 --- a/scripts/face_editor.py +++ b/scripts/face_editor.py @@ -148,8 +148,7 @@ def ui(self, is_img2img): show_intermediate_steps = gr.Checkbox( label="Show intermediate steps", - value=False, - visible=is_img2img) + value=False) apply_scripts_to_faces = gr.Checkbox( label="Apply scripts to faces", @@ -221,6 +220,7 @@ def run( max_face_count=max_face_count, mask_size=mask_size, mask_blur=mask_blur, prompt_for_face=prompt_for_face, apply_inside_mask_only=apply_inside_mask_only, + show_intermediate_steps=show_intermediate_steps, apply_scripts_to_faces=apply_scripts_to_faces, ) @@ -239,6 +239,7 @@ def proc_images( mask_blur: int, prompt_for_face: str, apply_inside_mask_only: bool, + show_intermediate_steps: bool, apply_scripts_to_faces: bool, ): edited_images = [] @@ -265,6 +266,7 @@ def proc_images( mask_blur=mask_blur, prompt_for_face=prompt_for_face, apply_inside_mask_only=apply_inside_mask_only, pre_proc_image=image, + show_intermediate_steps=show_intermediate_steps, apply_scripts_to_faces=apply_scripts_to_faces) edited_images.extend(proc.images) res.images.extend(edited_images) diff --git a/scripts/face_editor_extension.py b/scripts/face_editor_extension.py index ec4ca3b..2831105 100644 --- a/scripts/face_editor_extension.py +++ b/scripts/face_editor_extension.py @@ -54,18 +54,23 @@ def postprocess(self, o, res, if not enabled or self.__is_running: return - o.do_not_save_samples = False - script = face_editor.Script() - mask_model, detection_model = script.get_face_models() - try: self.__is_running = True + + if o.scripts is not None: + o.scripts.postprocess(o, res) + + o.do_not_save_samples = False + script = face_editor.Script() + mask_model, detection_model = script.get_face_models() + script.proc_images(mask_model, detection_model, o, res, face_margin=face_margin, confidence=confidence, strength1=strength1, strength2=strength2, max_face_count=max_face_count, mask_size=mask_size, mask_blur=mask_blur, prompt_for_face=prompt_for_face, apply_inside_mask_only=apply_inside_mask_only, + show_intermediate_steps=show_intermediate_steps, apply_scripts_to_faces=apply_scripts_to_faces, )