File size: 489 Bytes
8070ffb
 
29d5141
8070ffb
 
29d5141
 
 
8070ffb
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from PIL import Image
from rembg import remove

def remove_background(image):
    output = remove(image)
    white_bg = Image.new("RGBA", output.size, (255, 255, 255, 255))
    white_bg.paste(output, mask=output.split()[3])
    return white_bg.convert("RGB")

demo = gr.Interface(
    fn=remove_background,
    inputs=gr.Image(type="pil", label="Garment Image"),
    outputs=gr.Image(type="pil", label="Clean Garment"),
    api_name="remove_background"
)

demo.launch()