File size: 664 Bytes
94d9578
f0ecd39
 
d3d01c9
f0ecd39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from PIL import Image
import gradio as gr
from .cloth_segmentation import generate_cloth_mask


def generate_cloth_mask_and_display(cloth_img):
    path = 'cloth/cloth.jpg'
    if os.path.exists(path):
        os.remove(path)
    cloth_img.save(path)
    try:
        # os.system('.\cloth_segmentation\generate_cloth_mask.py')
        generate_cloth_mask()
    except Exception as e:
        print(e)
        return
    cloth_mask_img = Image.open("cloth_mask/cloth.jpg")
    return cloth_mask_img


gr.Interface(fn=generate_cloth_mask_and_display,
             inputs=gr.Image(type="pil"),
             outputs="image"
             ).launch(debug=True)