Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from rembg import remove as rm
|
| 3 |
+
|
| 4 |
+
def rem_bg(input):
|
| 5 |
+
if input !=None:
|
| 6 |
+
result=rm(input)
|
| 7 |
+
out1 = gr.Pil.update(value=result,visible=True)
|
| 8 |
+
out2 = gr.Accordion.update(label="Original Image",open=False)
|
| 9 |
+
else:
|
| 10 |
+
out1 = None
|
| 11 |
+
out2 = None
|
| 12 |
+
pass
|
| 13 |
+
return out1, out2
|
| 14 |
+
|
| 15 |
+
with gr.Blocks() as myface:
|
| 16 |
+
with gr.Row():
|
| 17 |
+
gr.Column()
|
| 18 |
+
with gr.Column():
|
| 19 |
+
with gr.Accordion(label="Input Image",open=True) as og:
|
| 20 |
+
in_win=gr.Pil(label="Input", interactive=True, batch=True, max_batch_size=20)
|
| 21 |
+
out_win=gr.Pil(label="Output",visible=False)
|
| 22 |
+
gr.Column()
|
| 23 |
+
|
| 24 |
+
in_win.change(rem_bg,in_win,[out_win,og])
|
| 25 |
+
myface.queue(concurrency_count=120)
|
| 26 |
+
myface.launch()
|