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)