Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,10 @@ from PIL import Image
|
|
4 |
import io
|
5 |
|
6 |
def background_remover(input_image):
|
7 |
-
input_bytes = input_image.read()
|
8 |
input_img = Image.open(io.BytesIO(input_bytes))
|
9 |
-
output_img = remove(input_img)
|
10 |
-
|
11 |
buf = io.BytesIO()
|
12 |
output_img.save(buf, format='PNG')
|
13 |
buf.seek(0)
|
@@ -18,22 +18,16 @@ This app uses the rembg library to remove the background from uploaded images.
|
|
18 |
Simply upload your image and let the model do its work. Download the result immediately after!
|
19 |
"""
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
with gr.Row():
|
32 |
-
gr.Button("Remove Background").click(
|
33 |
-
fn=background_remover,
|
34 |
-
inputs=input_image,
|
35 |
-
outputs=output_image
|
36 |
-
)
|
37 |
|
38 |
-
|
39 |
-
|
|
|
4 |
import io
|
5 |
|
6 |
def background_remover(input_image):
|
7 |
+
input_bytes = input_image.read()
|
8 |
input_img = Image.open(io.BytesIO(input_bytes))
|
9 |
+
output_img = remove(input_img)
|
10 |
+
|
11 |
buf = io.BytesIO()
|
12 |
output_img.save(buf, format='PNG')
|
13 |
buf.seek(0)
|
|
|
18 |
Simply upload your image and let the model do its work. Download the result immediately after!
|
19 |
"""
|
20 |
|
21 |
+
# Create the Gradio interface
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=background_remover,
|
24 |
+
inputs=gr.Image(type='pil', label="Upload Image"),
|
25 |
+
outputs="image",
|
26 |
+
examples=["woman.jpg", "groot.jpg"],
|
27 |
+
title="Background Remover",
|
28 |
+
description=description,
|
29 |
+
theme="soft"
|
30 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
# Launch the interface
|
33 |
+
iface.launch(share=True)
|