import gradio as gr import os.path import torch import cv2 import numpy as np from PIL import Image def output(image_path): pil_image = Image.open(image_path).convert("RGB") image = np.array(pil_image)[:, :, [2, 1, 0]] output_path = 'output' caption = 'person . mask' flag = False save_image_path = os.path.join(output_path,os.path.split(image_path)[-1]) return save_image_path with gr.Blocks() as demo: gr.Markdown("

Demo

") img_obj = gr.Image(value ='image/test.jpg',type = "filepath",label='object_img') btn = gr.Button("Submit",variant="primary") img_output = gr.Image(type = "filepath",label='output_img') btn.click(fn=output,inputs=[img_obj], outputs=[img_output], ) demo.launch(share=True)