juanelot commited on
Commit
f6c4736
·
verified ·
1 Parent(s): 04afab2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -10,10 +10,10 @@ remove_bg_models = {
10
  "U2NET Cloth Seg": "u2net_cloth_seg"
11
  }
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:
@@ -25,13 +25,12 @@ 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
- 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)
 
10
  "U2NET Cloth Seg": "u2net_cloth_seg"
11
  }
12
 
13
+ default_model = "U2NET"
14
 
15
+ def predict(image):
16
+ session = new_session(remove_bg_models[default_model])
17
  try:
18
  return remove(session, image, False, None, None)
19
  except ValueError as err:
 
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], outputs=[output_img])
34
  clear_btn.click(lambda: (None, None), inputs=None, outputs=[input_img, output_img])
35
 
36
  app.launch(share=False, debug=True, enable_queue=True, show_error=True)