Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from rembg import remove
|
3 |
+
from PIL import Image
|
4 |
+
import io
|
5 |
+
|
6 |
+
def remove_background(image):
|
7 |
+
input_data = image.read()
|
8 |
+
output_data = remove(input_data)
|
9 |
+
output_image = Image.open(io.BytesIO(output_data)).convert("RGBA")
|
10 |
+
return output_image
|
11 |
+
|
12 |
+
image_input = gr.inputs.Image()
|
13 |
+
image_output = gr.outputs.Image()
|
14 |
+
|
15 |
+
title = "Remove Background from Image"
|
16 |
+
description = "Upload an image and remove its background using the rembg library."
|
17 |
+
|
18 |
+
gr.Interface(fn=remove_background, inputs=image_input, outputs=image_output, title=title, description=description).launch()
|