File size: 598 Bytes
92940db
2368dc1
92940db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import rembg
from rembg import remove
from PIL import Image
import io

def remove_background(image):
    input_data = image.read()
    output_data = remove(input_data)
    output_image = Image.open(io.BytesIO(output_data)).convert("RGBA")
    return output_image

image_input = gr.inputs.Image()
image_output = gr.outputs.Image()

title = "Remove Background from Image"
description = "Upload an image and remove its background using the rembg library."

gr.Interface(fn=remove_background, inputs=image_input, outputs=image_output, title=title, description=description).launch()