Merge pull request #1 from jhj0517/feature/add-examples
Browse files
app.py
CHANGED
@@ -22,6 +22,7 @@ class App:
|
|
22 |
|
23 |
def musepose_demo(self):
|
24 |
with gr.Blocks() as demo:
|
|
|
25 |
with gr.Tabs():
|
26 |
with gr.TabItem('Step1: Pose Alignment'):
|
27 |
with gr.Row():
|
@@ -39,9 +40,19 @@ class App:
|
|
39 |
nb_max_frame = gr.Number(label="Max Frame", value=300, precision=0)
|
40 |
|
41 |
with gr.Row():
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
inputs=[vid_dance_input, img_input, nb_detect_resolution, nb_image_resolution,
|
46 |
nb_align_frame, nb_max_frame],
|
47 |
outputs=[vid_dance_output, vid_dance_output_demo])
|
@@ -76,15 +87,49 @@ class App:
|
|
76 |
with gr.Row():
|
77 |
btn_generate = gr.Button("GENERATE", variant="primary")
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
btn_generate.click(fn=self.musepose_infer.infer_musepose,
|
80 |
inputs=[img_input, vid_pose_input, weight_dtype, nb_width, nb_height,
|
81 |
-
nb_video_frame_length,
|
82 |
-
|
83 |
-
|
84 |
-
nb_steps, nb_fps, nb_skip],
|
85 |
outputs=[vid_output, vid_output_demo])
|
86 |
return demo
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
def launch(self):
|
89 |
demo = self.musepose_demo()
|
90 |
demo.queue().launch()
|
|
|
22 |
|
23 |
def musepose_demo(self):
|
24 |
with gr.Blocks() as demo:
|
25 |
+
md_header = self.header()
|
26 |
with gr.Tabs():
|
27 |
with gr.TabItem('Step1: Pose Alignment'):
|
28 |
with gr.Row():
|
|
|
40 |
nb_max_frame = gr.Number(label="Max Frame", value=300, precision=0)
|
41 |
|
42 |
with gr.Row():
|
43 |
+
btn_align_pose = gr.Button("ALIGN POSE", variant="primary")
|
44 |
+
with gr.Column():
|
45 |
+
examples = [
|
46 |
+
[os.path.join("assets", "videos", "dance.mp4"), os.path.join("assets", "images", "ref.png"),
|
47 |
+
512, 720, 0, 300]]
|
48 |
+
ex_step1 = gr.Examples(examples=examples,
|
49 |
+
inputs=[vid_dance_input, img_input, nb_detect_resolution,
|
50 |
+
nb_image_resolution, nb_align_frame, nb_max_frame],
|
51 |
+
outputs=[vid_dance_output, vid_dance_output_demo],
|
52 |
+
fn=self.pose_alignment_infer.align_pose,
|
53 |
+
cache_examples="lazy")
|
54 |
|
55 |
+
btn_align_pose.click(fn=self.pose_alignment_infer.align_pose,
|
56 |
inputs=[vid_dance_input, img_input, nb_detect_resolution, nb_image_resolution,
|
57 |
nb_align_frame, nb_max_frame],
|
58 |
outputs=[vid_dance_output, vid_dance_output_demo])
|
|
|
87 |
with gr.Row():
|
88 |
btn_generate = gr.Button("GENERATE", variant="primary")
|
89 |
|
90 |
+
with gr.Column():
|
91 |
+
examples = [
|
92 |
+
[os.path.join("assets", "images", "ref.png"), os.path.join("assets", "videos", "pose.mp4"),
|
93 |
+
"fp16", 512, 512, 300, 48, 4, 3.5, 99, 20, -1, 1]]
|
94 |
+
ex_step2 = gr.Examples(examples=examples,
|
95 |
+
inputs=[img_input, vid_pose_input, weight_dtype, nb_width, nb_height,
|
96 |
+
nb_video_frame_length, nb_video_slice_frame_length,
|
97 |
+
nb_video_slice_overlap_frame_number, nb_cfg, nb_seed, nb_steps,
|
98 |
+
nb_fps, nb_skip],
|
99 |
+
outputs=[vid_output, vid_output_demo],
|
100 |
+
fn=self.musepose_infer.infer_musepose,
|
101 |
+
cache_examples="lazy")
|
102 |
+
|
103 |
btn_generate.click(fn=self.musepose_infer.infer_musepose,
|
104 |
inputs=[img_input, vid_pose_input, weight_dtype, nb_width, nb_height,
|
105 |
+
nb_video_frame_length, nb_video_slice_frame_length,
|
106 |
+
nb_video_slice_overlap_frame_number, nb_cfg, nb_seed, nb_steps, nb_fps,
|
107 |
+
nb_skip],
|
|
|
108 |
outputs=[vid_output, vid_output_demo])
|
109 |
return demo
|
110 |
|
111 |
+
@staticmethod
|
112 |
+
def header():
|
113 |
+
header = gr.HTML(
|
114 |
+
"""
|
115 |
+
<style>
|
116 |
+
p, li {
|
117 |
+
font-size: 16px;
|
118 |
+
}
|
119 |
+
</style>
|
120 |
+
|
121 |
+
<h2>Gradio demo for <a href="https://github.com/TMElyralab/MusePose">MusePose</a></h2>
|
122 |
+
|
123 |
+
<p>Demo list you can try in other environment:</p>
|
124 |
+
<ul>
|
125 |
+
<li><a href="https://github.com/jhj0517/MusePose-WebUI"><strong>MusePose WebUI</strong></a> (This repository, you can try in local)</li>
|
126 |
+
<li><a href="https://github.com/jhj0517/stable-diffusion-webui-MusePose.git"><strong>stable-diffusion-webui-MusePose</strong></a> (SD WebUI extension)</li>
|
127 |
+
<li><a href="https://github.com/TMElyralab/Comfyui-MusePose"><strong>Comfyui-MusePose</strong></a> (ComfyUI custom node)</li>
|
128 |
+
</ul>
|
129 |
+
"""
|
130 |
+
)
|
131 |
+
return header
|
132 |
+
|
133 |
def launch(self):
|
134 |
demo = self.musepose_demo()
|
135 |
demo.queue().launch()
|