Spaces:
xp3857
/
Runtime error

File size: 1,810 Bytes
2770ba4
50d98b2
2770ba4
 
 
 
f41d1be
0d800b6
2770ba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
604aa5a
2770ba4
 
 
 
 
 
 
 
 
 
 
 
168df16
2770ba4
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
from PIL import Image 
import requests
import random
r = requests.get(f'https://huggingface.co/spaces/xp3857/bin/raw/main/css.css') 
css = r.text
name2 = "xp3857/bg-rem"
spaces=[
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
    gr.Interface.load(f"spaces/{name2}"),
]
def rem_bg(input):
    if input !=None:
        rn = random.randint(0, 19)
        space=spaces[rn]        
        result=space(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(css=css) as myface:
    with gr.Row():
        gr.Column()
        with gr.Column():
            with gr.Accordion(label="Input Image",open=True) as og:
                in_win=gr.Pil(label="Input", type="filepath", interactive=True)
            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()