mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git
synced 2026-04-29 02:31:22 +00:00
use InputAccordion from 1.6.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from modules import scripts_postprocessing
|
||||
from modules import scripts_postprocessing, ui_components
|
||||
import gradio as gr
|
||||
|
||||
from modules.ui_components import FormRow
|
||||
@@ -21,23 +21,25 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
|
||||
model = None
|
||||
|
||||
def ui(self):
|
||||
with FormRow():
|
||||
model = gr.Dropdown(label="Remove background", choices=models, value="None")
|
||||
return_mask = gr.Checkbox(label="Return mask", value=False)
|
||||
alpha_matting = gr.Checkbox(label="Alpha matting", value=False)
|
||||
with ui_components.InputAccordion(False, label="Remove background") as enable:
|
||||
with gr.Row():
|
||||
model = gr.Dropdown(label="Remove background", choices=models, value="None")
|
||||
return_mask = gr.Checkbox(label="Return mask", value=False)
|
||||
alpha_matting = gr.Checkbox(label="Alpha matting", value=False)
|
||||
|
||||
with FormRow(visible=False) as alpha_mask_row:
|
||||
alpha_matting_erode_size = gr.Slider(label="Erode size", minimum=0, maximum=40, step=1, value=10)
|
||||
alpha_matting_foreground_threshold = gr.Slider(label="Foreground threshold", minimum=0, maximum=255, step=1, value=240)
|
||||
alpha_matting_background_threshold = gr.Slider(label="Background threshold", minimum=0, maximum=255, step=1, value=10)
|
||||
with gr.Row(visible=False) as alpha_mask_row:
|
||||
alpha_matting_erode_size = gr.Slider(label="Erode size", minimum=0, maximum=40, step=1, value=10)
|
||||
alpha_matting_foreground_threshold = gr.Slider(label="Foreground threshold", minimum=0, maximum=255, step=1, value=240)
|
||||
alpha_matting_background_threshold = gr.Slider(label="Background threshold", minimum=0, maximum=255, step=1, value=10)
|
||||
|
||||
alpha_matting.change(
|
||||
fn=lambda x: gr.update(visible=x),
|
||||
inputs=[alpha_matting],
|
||||
outputs=[alpha_mask_row],
|
||||
)
|
||||
alpha_matting.change(
|
||||
fn=lambda x: gr.update(visible=x),
|
||||
inputs=[alpha_matting],
|
||||
outputs=[alpha_mask_row],
|
||||
)
|
||||
|
||||
return {
|
||||
"enable": enable,
|
||||
"model": model,
|
||||
"return_mask": return_mask,
|
||||
"alpha_matting": alpha_matting,
|
||||
@@ -46,7 +48,10 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
|
||||
"alpha_matting_erode_size": alpha_matting_erode_size,
|
||||
}
|
||||
|
||||
def process(self, pp: scripts_postprocessing.PostprocessedImage, model, return_mask, alpha_matting, alpha_matting_foreground_threshold, alpha_matting_background_threshold, alpha_matting_erode_size):
|
||||
def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, model, return_mask, alpha_matting, alpha_matting_foreground_threshold, alpha_matting_background_threshold, alpha_matting_erode_size):
|
||||
if not enable:
|
||||
return
|
||||
|
||||
if not model or model == "None":
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user