diff --git a/scripts/postprocessing_rembg.py b/scripts/postprocessing_rembg.py index 829f9f9..875fce1 100644 --- a/scripts/postprocessing_rembg.py +++ b/scripts/postprocessing_rembg.py @@ -37,7 +37,8 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing): def ui(self): with ui_components.InputAccordion(False, label="Remove background with BiRefNet") as enable: with FormRow(): - model = gr.Dropdown(label="Remove background", choices=models, value="None") + model = gr.Dropdown(label="Remove background model", choices=models, value="None", info="Choose a BiRefNet model. Each model gives a different result.") + resolution = gr.Textbox(label="Resolution", value="", placeholder="1024x1024", info="If left empty, it will take image size rounded to the nearest multiple of 32") return_foreground = gr.Checkbox(label="Return foreground", value=False) return_edge_mask = gr.Checkbox(label="Return edge mask", value=False) @@ -53,12 +54,13 @@ def ui(self): return { "enable": enable, "model": model, + "resolution": resolution, "return_foreground": return_foreground, "return_edge_mask": return_edge_mask, "edge_mask_width": edge_mask_width, } - def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, model, return_foreground, return_edge_mask, edge_mask_width): + def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, model, resolution, return_foreground, return_edge_mask, edge_mask_width): if not enable: return @@ -69,7 +71,7 @@ def process(self, pp: scripts_postprocessing.PostprocessedImage, enable, model, mask, output_image, edge_mask = birefnet.process( pp.image.convert("RGB"), - resolution='', + resolution=resolution, return_foreground=return_foreground, return_edge_mask=return_edge_mask, edge_mask_width=edge_mask_width