amoooooo commited on
Commit
418d0ae
·
1 Parent(s): 3e61a4f

Add application file

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from PIL import Image
4
+ import subprocess
5
+
6
+ # Install necessary packages
7
+ os.system("pip install gradio==2.4.6")
8
+ os.system("pip install 'git+https://github.com/facebookresearch/detectron2.git'")
9
+
10
+ # Clone the repository
11
+ os.system("git clone https://github.com/ShuhongChen/bizarre-pose-estimator.git")
12
+ os.chdir("bizarre-pose-estimator")
13
+
14
+ # Download necessary files
15
+ os.system("wget https://i.imgur.com/IkJzlaE.jpeg")
16
+ os.system("gdown https://drive.google.com/uc?id=1qhnBmMdDTC_8kmNj4u2f_Htfvg6KuE14")
17
+
18
+ # Unzip and move the model files
19
+ os.system("unzip bizarre_pose_models.zip")
20
+ os.system("cp -a ./bizarre_pose_models/. .")
21
+
22
+ def inference(img):
23
+ # Save the input image
24
+ img.save("_input.png")
25
+
26
+ # Run the pose estimator
27
+ os.system("python3 -m _scripts.pose_estimator _input.png ./_train/character_pose_estim/runs/feat_concat+data.ckpt")
28
+
29
+ # Load and return the output image
30
+ return Image.open("./_samples/character_pose_estim.png")
31
+
32
+ title = "bizarre-pose-estimator"
33
+ 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."
34
+
35
+ 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>"
36
+
37
+ examples=[["IkJzlaE.jpeg"]]
38
+ gr.Interface(
39
+ inference,
40
+ gr.inputs.Image(type="file", label="Input"),
41
+ gr.outputs.Image(type="file", label="Output"),
42
+ title=title,
43
+ description=description,
44
+ article=article,
45
+ allow_flagging="never",
46
+ examples=examples,
47
+ enable_queue=True
48
+ ).launch()