import gradio as gr import os import sys os.system("mkdir pose2pose") os.system("cd pose2pose") os.system("mkdir -p datasets/DeepFashion") os.system("mkdir -p output/DeepFashion/ckpt/pretrained") os.system("git clone https://github.com/prasunroy/pose-transfer.git") os.system("cd pose-transfer") os.system("pip install -r requirements.txt") sys.path.append("pose-transfer") import torch from api import Pose2Pose from PIL import Image p2p = Pose2Pose(pretrained=True) def infer(con_im,ref_im): condition = Image.open(con_im) reference = Image.open(ref_im) generated = p2p.transfer_as(condition, reference) #generated.show() return generated def transf(inp): return inp with gr.Blocks() as app: gr.Markdown("

Pose Transfer Demo


repo: https://github.com/prasunroy/pose-transfer

") with gr.Row(): condition_im = gr.Image(type='filepath',label='Style Image') reference_im = gr.Image(type='filepath',label='Pose Image') with gr.Accordion("Pose Maker",open=False): trans_box=gr.Textbox(label="Paste Generated Pose Image URL> HERE") pose_maker=gr.HTML("") btn=gr.Button() output_im = gr.Image() trans_box.change(transf,trans_box,reference_im) btn.click(infer,[condition_im,reference_im], output_im) app.launch()