Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image, ImageOps
|
|
|
4 |
|
5 |
# Initialize Segmentation Pipeline
|
6 |
segformer_b2_clothes_pipe = pipeline("image-segmentation", model="mattmdjaga/segformer_b2_clothes")
|
@@ -13,11 +14,15 @@ def segformer_b2_clothes(img):
|
|
13 |
return img
|
14 |
|
15 |
def remove_background(img):
|
|
|
16 |
segformer_b2_clothes_result = segformer_b2_clothes(img)
|
|
|
|
|
17 |
|
18 |
-
return segformer_b2_clothes_result
|
19 |
|
20 |
iface = gr.Interface(fn=remove_background,
|
21 |
inputs=gr.Image(type='pil'),
|
22 |
-
outputs=gr.
|
|
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image, ImageOps
|
4 |
+
import time
|
5 |
|
6 |
# Initialize Segmentation Pipeline
|
7 |
segformer_b2_clothes_pipe = pipeline("image-segmentation", model="mattmdjaga/segformer_b2_clothes")
|
|
|
14 |
return img
|
15 |
|
16 |
def remove_background(img):
|
17 |
+
start = time.time()
|
18 |
segformer_b2_clothes_result = segformer_b2_clothes(img)
|
19 |
+
end = time.time()
|
20 |
+
segformer_b2_clothes_text = "[mattmdjaga/segformer_b2_clothes](https://huggingface.co/mattmdjaga/segformer_b2_clothes) in " + str(end-start) + " seconds"
|
21 |
|
22 |
+
return segformer_b2_clothes_text, segformer_b2_clothes_result
|
23 |
|
24 |
iface = gr.Interface(fn=remove_background,
|
25 |
inputs=gr.Image(type='pil'),
|
26 |
+
outputs=[gr.Markdown(),
|
27 |
+
gr.Image(label='segformer_b2_clothes', type='pil')])
|
28 |
iface.launch()
|