Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import requests
|
| 3 |
import random
|
| 4 |
r = requests.get(f'https://huggingface.co/spaces/xp3857/bin/raw/main/css.css')
|
|
@@ -28,9 +29,12 @@ spaces=[
|
|
| 28 |
]
|
| 29 |
def rem_bg(input):
|
| 30 |
if input !=None:
|
|
|
|
|
|
|
|
|
|
| 31 |
rn = random.randint(0, 19)
|
| 32 |
space=spaces[rn]
|
| 33 |
-
result=space(input)
|
| 34 |
out1 = gr.Pil.update(value=result,visible=True)
|
| 35 |
out2 = gr.Accordion.update(label="Original Image",open=False)
|
| 36 |
else:
|
|
@@ -43,7 +47,7 @@ with gr.Blocks(css=css) as myface:
|
|
| 43 |
gr.Column()
|
| 44 |
with gr.Column():
|
| 45 |
with gr.Accordion(label="Input Image",open=True) as og:
|
| 46 |
-
in_win=gr.
|
| 47 |
out_win=gr.Pil(label="Output",visible=False)
|
| 48 |
gr.Column()
|
| 49 |
in_win.change(rem_bg,in_win,[out_win,og])
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
import requests
|
| 4 |
import random
|
| 5 |
r = requests.get(f'https://huggingface.co/spaces/xp3857/bin/raw/main/css.css')
|
|
|
|
| 29 |
]
|
| 30 |
def rem_bg(input):
|
| 31 |
if input !=None:
|
| 32 |
+
#im1 = Image.open(f"input}")
|
| 33 |
+
#Image.save(input)
|
| 34 |
+
|
| 35 |
rn = random.randint(0, 19)
|
| 36 |
space=spaces[rn]
|
| 37 |
+
result=space(f'{input}')
|
| 38 |
out1 = gr.Pil.update(value=result,visible=True)
|
| 39 |
out2 = gr.Accordion.update(label="Original Image",open=False)
|
| 40 |
else:
|
|
|
|
| 47 |
gr.Column()
|
| 48 |
with gr.Column():
|
| 49 |
with gr.Accordion(label="Input Image",open=True) as og:
|
| 50 |
+
in_win=gr.Pil(label="Input", interactive=True, batch=True, max_batch_size=20)
|
| 51 |
out_win=gr.Pil(label="Output",visible=False)
|
| 52 |
gr.Column()
|
| 53 |
in_win.change(rem_bg,in_win,[out_win,og])
|