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=1rA6w77ww3u97C8lHgEdHFUkk8h45Wyfk") os.system("unzip bizarre_pose_models.zip") os.system("cp -a ./bizarre_pose_models/. .") import urllib.request from urllib.parse import urlparse import json def inference(img): os.system("python3 -m _scripts.pose_retrieval "+img) with open("./_samples/results.json") as f: result = json.load(f) html = ''' ''' chunk_size = 4 for i in range(0, len(result), chunk_size): chunk = result[i:i+chunk_size] html += '\n' for row in chunk: try: data_raw = urllib.request.urlopen(f'https://danbooru.donmai.us/posts/{row["danbooru_id"]}.json') data = json.load(data_raw) html += f'' except Exception as e: pass html += '' html += '
' return (html, "./_samples/character_pose_estim.png") title = "danbooru-pose-search" description = "Gradio demo for Danbooru search based on pose similarity" article = "

Transfer Learning for Pose Estimation of Illustrated Characters | Github Repo

" gr.Interface( inference, gr.inputs.Image(type="filepath", label="Input"), [gr.HTML(label="Result"), gr.outputs.Image(type="file", label="Estimated Pose")], title=title, description=description, article=article, allow_flagging="never", enable_queue=True ).launch()