Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
from rembg import remove
|
3 |
from PIL import Image
|
4 |
-
from io import BytesIO
|
5 |
|
6 |
def remove_background(input_image):
|
|
|
7 |
input = Image.open(input_image) # load image
|
8 |
output = remove(input) # remove background
|
9 |
return output
|
10 |
|
11 |
-
def download_image(output_image):
|
12 |
-
img_bytes = output_image.getvalue()
|
13 |
-
return gradio.Interface.download(img_bytes, "output_image.png")
|
14 |
|
15 |
-
# define input and output interfaces
|
16 |
input_image = gr.inputs.Image(type="filepath", label="Input Image")
|
17 |
-
output_image = gr.
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
# create the interface
|
28 |
-
iface = gr.Interface(
|
29 |
-
fn=remove_background,
|
30 |
-
inputs=input_image,
|
31 |
-
outputs=output_image,
|
32 |
-
title='Image Background Remover',
|
33 |
-
description='Upload an image and it will remove.',
|
34 |
-
|
35 |
-
)
|
36 |
-
|
37 |
-
# combine the main interface and the download button
|
38 |
-
interface_with_download = gr.Interface([iface, download_button], "grid")
|
39 |
-
|
40 |
-
# launch the interface
|
41 |
-
interface_with_download.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from rembg import remove
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
def remove_background(input_image):
|
6 |
+
|
7 |
input = Image.open(input_image) # load image
|
8 |
output = remove(input) # remove background
|
9 |
return output
|
10 |
|
|
|
|
|
|
|
11 |
|
|
|
12 |
input_image = gr.inputs.Image(type="filepath", label="Input Image")
|
13 |
+
output_image = gr.inputs.Image(type="filepath", label="Output Image")
|
14 |
+
# Create a Gradio interface
|
15 |
+
iface = gr.Interface(remove_background,
|
16 |
+
inputs=input_image,
|
17 |
+
outputs=output_image,
|
18 |
+
title='Image Background Remover',
|
19 |
+
description='Upload an image and it will remove.')
|
20 |
+
|
21 |
+
# Launch the interface
|
22 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|