Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,26 +4,17 @@ from PIL import Image
|
|
| 4 |
import io
|
| 5 |
|
| 6 |
def remove_bg(image):
|
| 7 |
-
# Convert PIL image to bytes
|
| 8 |
img_bytes = io.BytesIO()
|
| 9 |
-
image.save(img_bytes, format=
|
| 10 |
-
|
| 11 |
-
# Remove background
|
| 12 |
result = remove(img_bytes.getvalue())
|
| 13 |
-
|
| 14 |
-
# Convert bytes back to PIL image
|
| 15 |
return Image.open(io.BytesIO(result))
|
| 16 |
|
| 17 |
-
# Gradio interface
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=remove_bg,
|
| 20 |
-
inputs=gr.Image(type="pil", label="
|
| 21 |
-
outputs=gr.Image(label="
|
| 22 |
-
title="
|
| 23 |
-
description="Upload
|
| 24 |
-
theme=gr.themes.Soft(primary_hue="emerald", secondary_hue="teal")
|
| 25 |
)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
demo.launch(share=True)
|
| 29 |
-
print("App running - built by Karthik")
|
|
|
|
| 4 |
import io
|
| 5 |
|
| 6 |
def remove_bg(image):
|
|
|
|
| 7 |
img_bytes = io.BytesIO()
|
| 8 |
+
image.save(img_bytes, format='PNG')
|
|
|
|
|
|
|
| 9 |
result = remove(img_bytes.getvalue())
|
|
|
|
|
|
|
| 10 |
return Image.open(io.BytesIO(result))
|
| 11 |
|
|
|
|
| 12 |
demo = gr.Interface(
|
| 13 |
fn=remove_bg,
|
| 14 |
+
inputs=gr.Image(type="pil", label="Upload an Image"),
|
| 15 |
+
outputs=gr.Image(label="Background Removed"),
|
| 16 |
+
title="AI Background Remover",
|
| 17 |
+
description="Upload any image to remove its background instantly using Rembg!"
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
+
demo.launch()
|
|
|
|
|
|