File size: 1,403 Bytes
5884409
9295c92
8a8a9a5
5884409
 
 
8a8a9a5
a3c2b91
 
5884409
a3c2b91
 
5884409
a3c2b91
8a8a9a5
5884409
8a8a9a5
23021cb
 
 
 
40d30d7
 
da86198
23021cb
 
 
85b6d5f
23021cb
5cc4001
 
5884409
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
from rembg import remove as rm

def rem_bg(input):
    if input !=None:
        #pass
        result=rm(input)
        out1 = gr.Pil.update(value=result,visible=True)
        out2 = gr.Accordion.update(label="Original Image",open=False)
    else:
        out1 = None
        out2 = None
        pass
    return out1, out2

with gr.Blocks() as myface:
    gr.Markdown("""<center><h1>Fast Background Remover</h1><center>""")
    with gr.Row():
        gr.Column()
        with gr.Column():
            with gr.Accordion("Details",open=False):
                gr.Markdown("""<center><h3>Drop your image in the box, and the background will be removed.</h3><center>""")
                gr.Markdown("""<center><h5>Background Removal by:<br><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo: danielgatis/rembg</a><br><br>
                            a <a href='https://huggingface.co/spaces' target='_blank'>Huggingface Space</a> by: <br><a href='https://twitter.com/omnibusai' target='_blank'>Omnibus</h3></a><center>""")
    
            with gr.Accordion(label="Input Image",open=True) as og:
                in_win=gr.Pil(label="Input", interactive=True, batch=True, max_batch_size=20)
            out_win=gr.Pil(label="Output",visible=False)
        gr.Column()

    in_win.change(rem_bg,in_win,[out_win,og])
myface.queue(concurrency_count=120)
myface.launch()