dhanushreddy29
commited on
Update main.py
Browse files
main.py
CHANGED
@@ -2,18 +2,18 @@ import gradio as gr
|
|
2 |
from rembg import remove
|
3 |
from PIL import Image
|
4 |
|
5 |
-
|
6 |
def remove_background(input_image):
|
|
|
|
|
|
|
|
|
7 |
output_image = remove(input_image)
|
8 |
return output_image
|
9 |
|
10 |
-
|
11 |
-
inputs = gr.inputs.Image()
|
12 |
-
outputs = gr.outputs.Image(type="pil")
|
13 |
interface = gr.Interface(
|
14 |
fn=remove_background,
|
15 |
-
inputs=
|
16 |
-
outputs=
|
17 |
title="Remove Background",
|
18 |
description="This App removes the background from an image",
|
19 |
examples=[
|
@@ -23,4 +23,6 @@ interface = gr.Interface(
|
|
23 |
],
|
24 |
cache_examples=True,
|
25 |
)
|
26 |
-
|
|
|
|
|
|
2 |
from rembg import remove
|
3 |
from PIL import Image
|
4 |
|
|
|
5 |
def remove_background(input_image):
|
6 |
+
# Convert to PIL Image if not already
|
7 |
+
if not isinstance(input_image, Image.Image):
|
8 |
+
input_image = Image.fromarray(input_image)
|
9 |
+
|
10 |
output_image = remove(input_image)
|
11 |
return output_image
|
12 |
|
|
|
|
|
|
|
13 |
interface = gr.Interface(
|
14 |
fn=remove_background,
|
15 |
+
inputs=gr.Image(type="pil"),
|
16 |
+
outputs=gr.Image(type="pil"),
|
17 |
title="Remove Background",
|
18 |
description="This App removes the background from an image",
|
19 |
examples=[
|
|
|
23 |
],
|
24 |
cache_examples=True,
|
25 |
)
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
interface.launch(enable_queue=True)
|