Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,10 @@ remove_bg_models = {
|
|
12 |
|
13 |
model_choices = list(remove_bg_models.keys())
|
14 |
|
15 |
-
def predict(image, session
|
16 |
session = new_session(remove_bg_models[session])
|
17 |
try:
|
18 |
-
return remove(session, image,
|
19 |
except ValueError as err:
|
20 |
logging.error(err)
|
21 |
return make_label(str(err)), None
|
@@ -25,13 +25,13 @@ with gr.Blocks(title="Remove background") as app:
|
|
25 |
with gr.Row(equal_height=False):
|
26 |
with gr.Column():
|
27 |
input_img = gr.Image(type="pil", label="Input image")
|
|
|
28 |
run_btn = gr.Button(value="Remove background", variant="primary")
|
29 |
clear_btn = gr.Button(value="Clear", variant="secondary")
|
30 |
with gr.Column():
|
31 |
output_img = gr.Image(type="pil", label="Result image")
|
32 |
|
33 |
-
run_btn.click(predict, inputs=[input_img,
|
34 |
-
outputs=[output_img])
|
35 |
clear_btn.click(lambda: (None, None), inputs=None, outputs=[input_img, output_img])
|
36 |
|
37 |
app.launch(share=False, debug=True, enable_queue=True, show_error=True)
|
|
|
12 |
|
13 |
model_choices = list(remove_bg_models.keys())
|
14 |
|
15 |
+
def predict(image, session):
|
16 |
session = new_session(remove_bg_models[session])
|
17 |
try:
|
18 |
+
return remove(session, image, False, None, None)
|
19 |
except ValueError as err:
|
20 |
logging.error(err)
|
21 |
return make_label(str(err)), None
|
|
|
25 |
with gr.Row(equal_height=False):
|
26 |
with gr.Column():
|
27 |
input_img = gr.Image(type="pil", label="Input image")
|
28 |
+
drp_models = gr.Dropdown(choices=model_choices, label="Model Segment", value="U2NET")
|
29 |
run_btn = gr.Button(value="Remove background", variant="primary")
|
30 |
clear_btn = gr.Button(value="Clear", variant="secondary")
|
31 |
with gr.Column():
|
32 |
output_img = gr.Image(type="pil", label="Result image")
|
33 |
|
34 |
+
run_btn.click(predict, inputs=[input_img, drp_models], outputs=[output_img])
|
|
|
35 |
clear_btn.click(lambda: (None, None), inputs=None, outputs=[input_img, output_img])
|
36 |
|
37 |
app.launch(share=False, debug=True, enable_queue=True, show_error=True)
|