Skip to content

Commit

Permalink
Merge pull request ototadana#118 from ototadana/add-save_original_on_…
Browse files Browse the repository at this point in the history
…detection_fail-option

add save_original_on_detection_fail option
  • Loading branch information
ototadana authored Jul 4, 2023
2 parents 033cdcb + 4001cf2 commit 341d0b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions scripts/ui/ui_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def on_ui_settings():
),
)

shared.opts.add_option(
"face_editor_save_original_on_detection_fail",
shared.OptionInfo(False, "Save original image if face detection fails", gr.Checkbox, section=section),
)

shared.opts.add_option(
"face_editor_script_index",
shared.OptionInfo(
Expand Down
9 changes: 8 additions & 1 deletion scripts/use_cases/image_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ def proc_image(
output_images.append(self.__show_detected_faces(np.copy(entire_image), faces, p))

print(f"number of faces: {len(faces)}")
if len(faces) == 0 and pre_proc_image is not None:
if (
len(faces) == 0
and pre_proc_image is not None
and (
option.save_original_image
or not shared.opts.data.get("face_editor_save_original_on_detection_fail", False)
)
):
return Processed(
p, images_list=[pre_proc_image], all_prompts=[p.prompt], all_seeds=[p.seed], infotexts=[""]
)
Expand Down

0 comments on commit 341d0b4

Please sign in to comment.