File size: 685 Bytes
8a895a7
 
6826989
8a895a7
 
6826989
 
 
 
 
 
8a895a7
60b9091
8a895a7
6826989
 
 
 
60b9091
 
e867ce7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from rembg import remove
from PIL import Image
import io
import gradio as gr

def remove_bg(image):
    img_bytes = io.BytesIO()
    image.save(img_bytes, format="PNG")
    img_bytes = img_bytes.getvalue()
    result = remove(img_bytes)
    return Image.open(io.BytesIO(result))

app = gr.Interface(
    fn=remove_bg,
    inputs=gr.Image(type="pil", label="Upload Image"),
    outputs=gr.Image(type="pil", label="Background Removed"),
    title="🧹 Free Background Remover",
    description="Upload an image and remove the background instantly for free!",
)

# launch the gradio app normally (API will auto-exist at /api/predict/)
app.launch(server_name="0.0.0.0", server_port=7860)