Update: Masking - equalize branches p1

This commit is contained in:
Art Gourieff 2024-03-13 22:17:00 +07:00
parent 348685cb06
commit da30478383
3 changed files with 29 additions and 1 deletions

View File

@ -3,3 +3,4 @@ import reactor_ui.reactor_tools_ui as ui_tools
import reactor_ui.reactor_settings_ui as ui_settings
import reactor_ui.reactor_main_ui as ui_main
import reactor_ui.reactor_detection_ui as ui_detection
import reactor_ui.reactor_masking as ui_masking

View File

@ -0,0 +1,27 @@
import gradio as gr
from scripts.reactor_swapper import MaskOption
# TAB MASKING
def show():
with gr.Tab("Masking"):
save_face_mask = gr.Checkbox(False, label="Save Face Mask", info="Save the face mask as a separate image with alpha transparency.")
use_minimal_area = gr.Checkbox(MaskOption.DEFAULT_USE_MINIMAL_AREA, label="Use Minimal Area", info="Use the least amount of area for the mask as possible. This is good for multiple faces that are close together or for preserving the most of the surrounding image.")
mask_areas = gr.CheckboxGroup(
label="Mask areas", choices=["Face", "Hair", "Hat", "Neck"], type="value", value= MaskOption.DEFAULT_FACE_AREAS
)
face_size = gr.Radio(
label = "Face Size", choices = [512,256,128],value=MaskOption.DEFAULT_FACE_SIZE,type="value", info="Size of the masked area. Use larger numbers if the face is expected to be large, smaller if small. Default is 512."
)
mask_blur = gr.Slider(label="Mask blur", minimum=0, maximum=64, step=1, value=12,info="The number of pixels from the outer edge of the mask to blur.")
mask_vignette_fallback_threshold = gr.Slider(
minimum=0.1,
maximum=1.0,
step=0.01,
value=MaskOption.DEFAULT_VIGNETTE_THRESHOLD,
label="Vignette fallback threshold",
info="Switch to a rectangular vignette mask when masked area is only this specified percentage of Face Size."
)
return save_face_mask, use_minimal_area, mask_areas, face_size, mask_blur, mask_vignette_fallback_threshold

View File

@ -74,4 +74,4 @@ def show(hash_check_block: bool = True):
label="Target Image Hash Check",
info="Affects if you use Extras tab or img2img with only 'Swap in source image' on."
)
return model, device, console_logging_level, source_hash_check, target_hash_check
return model, device, console_logging_level, source_hash_check, target_hash_check