Spaces:
Sleeping
Sleeping
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() |