Skip to content

Commit

Permalink
Add ui_components as global import to avoid issues with dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitribarbot committed Sep 3, 2024
1 parent 0957774 commit 2896872
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions scripts/postprocessing_birefnet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from modules import scripts_postprocessing
from modules import scripts_postprocessing, ui_components
import gradio as gr

from modules.ui_components import FormRow, InputAccordion
from modules.devices import torch_gc

from internal_birefnet.pipeline import BiRefNetPipeline, BiRefNetModelName
Expand Down Expand Up @@ -35,18 +34,18 @@ class ScriptPostprocessingBiRefNet(scripts_postprocessing.ScriptPostprocessing):
model = None

def ui(self):
with InputAccordion(False, label="Remove background with BiRefNet") as enable:
with FormRow():
with ui_components.InputAccordion(False, label="Remove background with BiRefNet") as enable:
with ui_components.FormRow():
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.")

with FormRow():
with ui_components.FormRow():
return_original = gr.Checkbox(label="Return original image")
return_foreground = gr.Checkbox(True, label="Return foreground")
return_mask = gr.Checkbox(label="Return mask")
return_edge_mask = gr.Checkbox(label="Return edge mask")

with FormRow(visible=False) as edge_mask_row:
with ui_components.FormRow(visible=False) as edge_mask_row:
edge_mask_width = gr.Slider(label="Edge mask width", minimum=1, maximum=256, step=1, value=64)

return_edge_mask.change(
Expand Down

0 comments on commit 2896872

Please sign in to comment.