File size: 849 Bytes
f74a8bb
 
81b6033
 
 
f74a8bb
06e63b6
 
 
81b6033
 
06e63b6
81b6033
f74a8bb
06e63b6
 
 
 
f74a8bb
06e63b6
 
 
 
 
f74a8bb
 
b5a4909
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
from gradio_imageslider import ImageSlider
from loadimg import load_img
from transformers import pipeline
pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)

def fn(image):
    im = load_img(image)
    im = im.convert('RGB') 
    path = load_img(im,output_type="str")
    rmbg = pipe(path)
    out = (rmbg , im)
    return out

slider1 = ImageSlider(label="RMBG", type="pil")
slider2 = ImageSlider(label="RMBG", type="pil")
image = gr.Image(label="Upload an image")
text = gr.Textbox(label="Paste an image URL")


tab1 = gr.Interface(fn,inputs= image, outputs= slider1, api_name="image")
tab2 = gr.Interface(fn,inputs= text, outputs= slider2, api_name="text")

demo = gr.TabbedInterface([tab1,tab2],["image","text"],title="RMBG with image slider")

if __name__ == "__main__":
    demo.launch()