Update app.py
Browse files
app.py
CHANGED
@@ -4,23 +4,24 @@ from loadimg import load_img
|
|
4 |
from transformers import pipeline
|
5 |
pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)
|
6 |
|
7 |
-
def fn(
|
8 |
-
|
9 |
-
|
10 |
-
# avoid problems when working with images that are actually RGBA
|
11 |
-
im = im[0].convert('RGB')
|
12 |
path = load_img(im,output_type="str")
|
13 |
rmbg = pipe(path)
|
14 |
-
|
15 |
-
out = (im,rmbg)
|
16 |
return out
|
17 |
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
demo.launch(debug=True)
|
|
|
4 |
from transformers import pipeline
|
5 |
pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)
|
6 |
|
7 |
+
def fn(image):
|
8 |
+
im = load_img(image)
|
9 |
+
im = im.convert('RGB')
|
|
|
|
|
10 |
path = load_img(im,output_type="str")
|
11 |
rmbg = pipe(path)
|
12 |
+
out = (rmbg , im)
|
|
|
13 |
return out
|
14 |
|
15 |
+
slider1 = ImageSlider(label="RMBG", type="pil")
|
16 |
+
slider2 = ImageSlider(label="RMBG", type="pil")
|
17 |
+
image = gr.Image(label="Upload an image")
|
18 |
+
text = gr.Textbox(label="Paste an image URL")
|
19 |
|
20 |
+
|
21 |
+
tab1 = gr.Interface(fn,inputs= image, outputs= slider1, api_name="image")
|
22 |
+
tab2 = gr.Interface(fn,inputs= text, outputs= slider2, api_name="text")
|
23 |
+
|
24 |
+
demo = gr.TabbedInterface([tab1,tab2],["image","text"],title="RMBG with image slider")
|
25 |
|
26 |
if __name__ == "__main__":
|
27 |
demo.launch(debug=True)
|