diff --git a/README.md b/README.md index 99c23d8..f1c5895 100644 --- a/README.md +++ b/README.md @@ -118,11 +118,13 @@ To remove the borders generated when pasting the image, mask all but the face an When pasting the generated image to its original location, the rectangle of the detected face area is used. If this option is not enabled, the generated image itself is pasted. In other words, enabling this option applies a smaller face image, while disabling it applies a larger face image. ##### Save original image -Specify whether to save the image before modification. +This option allows you to save the original, unmodified image. -##### Show intermediate steps -Specifies whether to display images of detected faces and masks. +##### Show original image +This option allows you to display the original, unmodified image. +##### Show intermediate steps +This option enables the display of images that depict detected faces and masks. If the generated image is unnatural, enabling it may reveal the cause. ##### Prompt for face diff --git a/scripts/entities/option.py b/scripts/entities/option.py index 33eb457..1f57cb2 100644 --- a/scripts/entities/option.py +++ b/scripts/entities/option.py @@ -9,6 +9,7 @@ class Option: DEFAULT_PROMPT_FOR_FACE = "" DEFAULT_APPLY_INSIDE_MASK_ONLY = True DEFAULT_SAVE_ORIGINAL_IMAGE = False + DEFAULT_SHOW_ORIGINAL_IMAGE = False DEFAULT_SHOW_INTERMEDIATE_STEPS = False DEFAULT_APPLY_SCRIPTS_TO_FACES = False DEFAULT_FACE_SIZE = 512 @@ -33,6 +34,7 @@ def __init__(self, *args) -> None: self.use_minimal_area = Option.DEFAULT_USE_MINIMAL_AREA self.ignore_larger_faces = Option.DEFAULT_IGNORE_LARGER_FACES self.affected_areas = Option.DEFAULT_AFFECTED_AREAS + self.show_original_image = Option.DEFAULT_SHOW_ORIGINAL_IMAGE if len(args) > 0 and isinstance(args[0], dict): self.update_by_dict(args[0]) @@ -65,6 +67,7 @@ def update_by_list(self, args: tuple) -> None: self.use_minimal_area = args[13] if arg_len > 13 and isinstance(args[13], bool) else self.use_minimal_area self.ignore_larger_faces = args[14] if arg_len > 14 and isinstance(args[14], bool) else self.ignore_larger_faces self.affected_areas = args[15] if arg_len > 15 and isinstance(args[15], list) else self.affected_areas + self.show_original_image = args[16] if arg_len > 16 and isinstance(args[16], bool) else self.show_original_image def update_by_dict(self, params: dict) -> None: self.face_margin = params.get("face_margin", self.face_margin) @@ -83,6 +86,7 @@ def update_by_dict(self, params: dict) -> None: self.use_minimal_area = params.get("use_minimal_area", self.use_minimal_area) self.ignore_larger_faces = params.get("ignore_larger_faces", self.ignore_larger_faces) self.affected_areas = params.get("affected_areas", self.affected_areas) + self.show_original_image = params.get("show_original_image", self.show_original_image) def to_dict(self) -> dict: return { diff --git a/scripts/ui/ui_builder.py b/scripts/ui/ui_builder.py index c1f98ed..eb55be5 100644 --- a/scripts/ui/ui_builder.py +++ b/scripts/ui/ui_builder.py @@ -25,13 +25,17 @@ def __build(self, is_img2img: bool): ) self.infotext_fields.append((use_minimal_area, Option.add_prefix("use_minimal_area"))) - save_original_image = gr.Checkbox(label="Save original image", value=Option.DEFAULT_SAVE_ORIGINAL_IMAGE) - self.infotext_fields.append((save_original_image, Option.add_prefix("save_original_image"))) + with gr.Row(): + save_original_image = gr.Checkbox(label="Save original image", value=Option.DEFAULT_SAVE_ORIGINAL_IMAGE) + self.infotext_fields.append((save_original_image, Option.add_prefix("save_original_image"))) - show_intermediate_steps = gr.Checkbox( - label="Show intermediate steps", value=Option.DEFAULT_SHOW_INTERMEDIATE_STEPS - ) - self.infotext_fields.append((show_intermediate_steps, Option.add_prefix("show_intermediate_steps"))) + show_original_image = gr.Checkbox(label="Show original image", value=Option.DEFAULT_SHOW_ORIGINAL_IMAGE) + self.infotext_fields.append((show_original_image, Option.add_prefix("show_original_image"))) + + show_intermediate_steps = gr.Checkbox( + label="Show intermediate steps", value=Option.DEFAULT_SHOW_INTERMEDIATE_STEPS + ) + self.infotext_fields.append((show_intermediate_steps, Option.add_prefix("show_intermediate_steps"))) prompt_for_face = gr.Textbox( show_label=False, @@ -142,4 +146,5 @@ def __build(self, is_img2img: bool): use_minimal_area, ignore_larger_faces, affected_areas, + show_original_image, ] diff --git a/scripts/use_cases/image_processor.py b/scripts/use_cases/image_processor.py index 9c11736..c1ecb3a 100644 --- a/scripts/use_cases/image_processor.py +++ b/scripts/use_cases/image_processor.py @@ -58,7 +58,10 @@ def proc_images(self, o: StableDiffusionProcessing, res: Processed, option: Opti all_prompts.extend(proc.all_prompts) infotexts.extend(proc.infotexts) - res.images.extend(edited_images) + if option.show_original_image: + res.images.extend(edited_images) + else: + res.images = edited_images res.all_seeds.extend(all_seeds) res.all_prompts.extend(all_prompts) res.infotexts.extend(infotexts)