Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from rembg import remove
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import io
|
| 5 |
+
|
| 6 |
+
def remove_bg(image):
|
| 7 |
+
if image is None:
|
| 8 |
+
return None
|
| 9 |
+
image = Image.open(io.BytesIO(image))
|
| 10 |
+
output = remove(image)
|
| 11 |
+
return output
|
| 12 |
+
|
| 13 |
+
# Creating Gradio interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=remove_bg,
|
| 16 |
+
inputs=gr.Image(type="file"),
|
| 17 |
+
outputs=gr.Image(type="pil"),
|
| 18 |
+
title="AI Background Remover",
|
| 19 |
+
description="Upload an image and remove its background automatically!",
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
iface.launch()
|