Omnibus commited on
Commit
e90bb7a
·
1 Parent(s): f174964

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -11
app.py CHANGED
@@ -12,8 +12,10 @@ function(text_input, url_params) {
12
  }
13
  """
14
 
15
- def rem_bg():
16
-
 
 
17
  def predict(text, url_params):
18
  mod_url=""
19
  mod=gr.HTML("")
@@ -41,20 +43,29 @@ def dl(inp):
41
  except Exception as e:
42
  print (e)
43
  out = None
44
- return out
45
 
46
  with gr.Blocks() as app:
47
- inp_url = gr.Textbox()
48
- go_btn = gr.Button("Run")
49
- with gr.Row():
50
- with gr.Column():
51
- outp_vid=gr.Video()
52
- with gr.Column():
53
- outp_file=gr.Textbox()
 
 
 
 
 
 
 
 
54
  with gr.Row(visible=False):
55
  text_input=gr.Textbox()
56
  text_output=gr.Textbox()
57
  url_params=gr.JSON()
58
- go_btn.click(dl,inp_url,outp_file)
 
59
  app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,text_input],_js=load_js)
60
  app.launch()
 
12
  }
13
  """
14
 
15
+ def rem_bg(inp):
16
+ #transparent .mov
17
+ os.system(f'backgroundremover -i "{inp}" -tv -o "{inp}.mov"')
18
+ return f'{inp}.mov'
19
  def predict(text, url_params):
20
  mod_url=""
21
  mod=gr.HTML("")
 
43
  except Exception as e:
44
  print (e)
45
  out = None
46
+ return out,out,out
47
 
48
  with gr.Blocks() as app:
49
+ with gr.Tab("Load"):
50
+ inp_url = gr.Textbox()
51
+ go_btn = gr.Button("Run")
52
+ with gr.Row():
53
+ with gr.Column():
54
+ outp_vid=gr.Video()
55
+ with gr.Column():
56
+ outp_file=gr.Textbox()
57
+ with gr.Tab("Rem BG"):
58
+ with gr.Row():
59
+ with gr.Column():
60
+ rem_btn=gr.Button()
61
+ in_vid=gr.Video()
62
+ with gr.Column():
63
+ rem_vid=gr.Video()
64
  with gr.Row(visible=False):
65
  text_input=gr.Textbox()
66
  text_output=gr.Textbox()
67
  url_params=gr.JSON()
68
+ rem_btn.click(rem_bg,in_vid,rem_vid)
69
+ go_btn.click(dl,inp_url,[outp_vid,in_vid,outp_file])
70
  app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,text_input],_js=load_js)
71
  app.launch()