Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,9 @@ import io
|
|
| 7 |
# Function to remove background
|
| 8 |
# -------------------------------
|
| 9 |
def remove_bg(image: Image.Image):
|
|
|
|
|
|
|
|
|
|
| 10 |
# Convert PIL image to bytes
|
| 11 |
img_byte_arr = io.BytesIO()
|
| 12 |
image.save(img_byte_arr, format='PNG')
|
|
@@ -25,10 +28,11 @@ def remove_bg(image: Image.Image):
|
|
| 25 |
# -------------------------------
|
| 26 |
demo = gr.Interface(
|
| 27 |
fn=remove_bg,
|
| 28 |
-
inputs=gr.Image(type="pil", label="Upload
|
| 29 |
outputs=gr.Image(type="pil", label="Background Removed"),
|
| 30 |
-
title="Background Remover",
|
| 31 |
-
description="Upload
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
# -------------------------------
|
|
|
|
| 7 |
# Function to remove background
|
| 8 |
# -------------------------------
|
| 9 |
def remove_bg(image: Image.Image):
|
| 10 |
+
if image is None:
|
| 11 |
+
return None
|
| 12 |
+
|
| 13 |
# Convert PIL image to bytes
|
| 14 |
img_byte_arr = io.BytesIO()
|
| 15 |
image.save(img_byte_arr, format='PNG')
|
|
|
|
| 28 |
# -------------------------------
|
| 29 |
demo = gr.Interface(
|
| 30 |
fn=remove_bg,
|
| 31 |
+
inputs=gr.Image(type="pil", label="Upload any image"),
|
| 32 |
outputs=gr.Image(type="pil", label="Background Removed"),
|
| 33 |
+
title="Universal Background Remover",
|
| 34 |
+
description="Upload any image and the background will be automatically removed using rembg.",
|
| 35 |
+
allow_flagging="never",
|
| 36 |
)
|
| 37 |
|
| 38 |
# -------------------------------
|