jhj0517 commited on
Commit
a874577
1 Parent(s): 606190d

add test code

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -1,12 +1,36 @@
1
  import gradio as gr
 
 
 
2
  from musepose_inference import MusePoseInference
3
  from pose_align import PoseAlignmentInference
4
 
 
5
  class App:
6
  def __init__(self):
7
  self.pose_alignment_infer = PoseAlignmentInference()
8
  self.musepose_infer = MusePoseInference()
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def musepose_demo(self):
11
  with gr.Blocks() as demo:
12
  with gr.Tabs():
@@ -27,11 +51,13 @@ class App:
27
 
28
  with gr.Row():
29
  btn_algin_pose = gr.Button("ALIGN POSE", variant="primary")
 
30
 
31
  btn_algin_pose.click(fn=self.pose_alignment_infer.align_pose,
32
  inputs=[vid_dance_input, img_input, nb_detect_resolution, nb_image_resolution,
33
  nb_align_frame, nb_max_frame],
34
  outputs=[vid_dance_output, vid_dance_output_demo])
 
35
 
36
  with gr.TabItem('Step2: MusePose Inference'):
37
  with gr.Row():
 
1
  import gradio as gr
2
+ import os
3
+ from huggingface_hub import hf_hub_download
4
+
5
  from musepose_inference import MusePoseInference
6
  from pose_align import PoseAlignmentInference
7
 
8
+
9
  class App:
10
  def __init__(self):
11
  self.pose_alignment_infer = PoseAlignmentInference()
12
  self.musepose_infer = MusePoseInference()
13
 
14
+ @staticmethod
15
+ def download_models():
16
+ repo_id = 'jhj0517/MusePose'
17
+ model_paths = {
18
+ "det_ckpt": os.path.join("pretrained_weights", "dwpose", "yolox_l_8x8_300e_coco.pth"),
19
+ "pose_ckpt": os.path.join("pretrained_weights", "dwpose", "dw-ll_ucoco_384.pth")
20
+ }
21
+ for name, file_path in model_paths.items():
22
+
23
+ local_dir, filename = os.path.dirname(file_path), os.path.basename(file_path)
24
+ if not os.path.exists(local_dir):
25
+ os.makedirs(local_dir)
26
+
27
+ remote_filepath = os.path.join("dwpose", filename)
28
+ if not os.path.exists(file_path):
29
+ print(file_path)
30
+ hf_hub_download(repo_id=repo_id, filename=remote_filepath,
31
+ local_dir=local_dir,
32
+ local_dir_use_symlinks=False)
33
+
34
  def musepose_demo(self):
35
  with gr.Blocks() as demo:
36
  with gr.Tabs():
 
51
 
52
  with gr.Row():
53
  btn_algin_pose = gr.Button("ALIGN POSE", variant="primary")
54
+ btn_down = gr.Button("download", variant="primary")
55
 
56
  btn_algin_pose.click(fn=self.pose_alignment_infer.align_pose,
57
  inputs=[vid_dance_input, img_input, nb_detect_resolution, nb_image_resolution,
58
  nb_align_frame, nb_max_frame],
59
  outputs=[vid_dance_output, vid_dance_output_demo])
60
+ btn_down(fn=self.download_models, inputs=None, outputs=None)
61
 
62
  with gr.TabItem('Step2: MusePose Inference'):
63
  with gr.Row():