kivantium's picture
Show cropbox and d
38561b6 unverified
import os
os.system("pip install gradio==3.4")
import gradio as gr
os.system("pip install 'git+https://github.com/facebookresearch/detectron2.git'")
os.system("git clone https://github.com/kivantium/bizarre-pose-estimator.git")
os.chdir("bizarre-pose-estimator")
os.system("wget https://i.imgur.com/IkJzlaE.jpeg")
os.system("gdown https://drive.google.com/uc?id=1qhnBmMdDTC_8kmNj4u2f_Htfvg6KuE14")
os.system("unzip bizarre_pose_models.zip")
os.system("cp -a ./bizarre_pose_models/. .")
import urllib.request
from urllib.parse import urlparse
import numpy as np
def inference(url):
filename = os.path.basename(urlparse(url).path)
urllib.request.urlretrieve(url, filename)
os.system("python3 -m _scripts.pose_estimator "+filename+" ./_train/character_pose_estim/runs/feat_concat+data.ckpt")
keypoints, cropbox, d = np.load("./_samples/results.npy", allow_pickle=True)
return ("./_samples/character_pose_estim.png", str(keypoints), str(cropbox), str(d))
title = "bizarre-pose-estimator"
description = "Gradio demo for Transfer Learning for Pose Estimation of Illustrated Characters. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2108.01819' target='_blank'>Transfer Learning for Pose Estimation of Illustrated Characters</a> | <a href='https://github.com/ShuhongChen/bizarre-pose-estimator' target='_blank'>Github Repo</a></p>"
gr.Interface(
inference,
gr.Textbox(lines=1, placeholder="Image URL"),
[gr.outputs.Image(type="file", label="Output"), gr.Textbox(lines=10, placeholder="Keypoints"), gr.Textbox(lines=10, placeholder="cropbox"), gr.Textbox(lines=10, placeholder="d")],
title=title,
description=description,
article=article,
allow_flagging="never",
enable_queue=True
).launch()