Update app.py
Browse files
app.py
CHANGED
|
@@ -22,8 +22,10 @@ class App:
|
|
| 22 |
|
| 23 |
@staticmethod
|
| 24 |
def on_step1_complete(input_img: str, input_pose_vid: str):
|
| 25 |
-
return [
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
def musepose_demo(self):
|
| 29 |
with gr.Blocks() as demo:
|
|
@@ -37,9 +39,31 @@ class App:
|
|
| 37 |
with gr.Column(scale=3):
|
| 38 |
vid_dance_output = gr.Video(label="Aligned Pose Output", scale=5, interactive=False)
|
| 39 |
vid_dance_output_demo = gr.Video(label="Aligned Pose Output Demo", scale=5)
|
| 40 |
-
# Rest of the column setup remains the same
|
| 41 |
with gr.Column(scale=3):
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
with gr.TabItem('2: MusePose Inference'):
|
| 45 |
with gr.Row():
|
|
@@ -49,8 +73,34 @@ class App:
|
|
| 49 |
with gr.Column(scale=3):
|
| 50 |
vid_output = gr.Video(label="MusePose Output", scale=5)
|
| 51 |
vid_output_demo = gr.Video(label="MusePose Output Demo", scale=5)
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
@staticmethod
|
| 56 |
def header():
|
|
@@ -60,7 +110,7 @@ class App:
|
|
| 60 |
<a href="https://github.com/jhj0517/MusePose-WebUI" target="_blank">MusePose WebUI</a>
|
| 61 |
</h1>
|
| 62 |
<p style="font-size: 18px;">
|
| 63 |
-
<strong>Note</strong>: This space
|
| 64 |
If you want longer video inputs, you have to run it locally. Click the link above and follow the README to try it locally.<br><br>
|
| 65 |
When you have completed the <strong>1: Pose Alignment</strong> process, go to <strong>2: MusePose Inference</strong> and click the "GENERATE" button.
|
| 66 |
</p>
|
|
|
|
| 22 |
|
| 23 |
@staticmethod
|
| 24 |
def on_step1_complete(input_img: str, input_pose_vid: str):
|
| 25 |
+
return [
|
| 26 |
+
gr.Image(label="Input Image", value=input_img, type="filepath", scale=5),
|
| 27 |
+
gr.Video(label="Input Aligned Pose Video", value=input_pose_vid, scale=5)
|
| 28 |
+
]
|
| 29 |
|
| 30 |
def musepose_demo(self):
|
| 31 |
with gr.Blocks() as demo:
|
|
|
|
| 39 |
with gr.Column(scale=3):
|
| 40 |
vid_dance_output = gr.Video(label="Aligned Pose Output", scale=5, interactive=False)
|
| 41 |
vid_dance_output_demo = gr.Video(label="Aligned Pose Output Demo", scale=5)
|
|
|
|
| 42 |
with gr.Column(scale=3):
|
| 43 |
+
with gr.Column():
|
| 44 |
+
nb_detect_resolution = gr.Number(label="Detect Resolution", value=512, precision=0)
|
| 45 |
+
nb_image_resolution = gr.Number(label="Image Resolution", value=720, precision=0)
|
| 46 |
+
nb_align_frame = gr.Number(label="Align Frame", value=0, precision=0)
|
| 47 |
+
nb_max_frame = gr.Number(label="Max Frame", value=300, precision=0)
|
| 48 |
+
with gr.Row():
|
| 49 |
+
btn_align_pose = gr.Button("ALIGN POSE", variant="primary")
|
| 50 |
+
|
| 51 |
+
with gr.Column():
|
| 52 |
+
examples = [
|
| 53 |
+
[os.path.join("examples", "dance.mp4"), os.path.join("examples", "ref.png"),
|
| 54 |
+
512, 720, 0, 300]
|
| 55 |
+
]
|
| 56 |
+
ex_step1 = gr.Examples(examples=examples,
|
| 57 |
+
inputs=[vid_dance_input, img_pose_input, nb_detect_resolution,
|
| 58 |
+
nb_image_resolution, nb_align_frame, nb_max_frame],
|
| 59 |
+
outputs=[vid_dance_output, vid_dance_output_demo],
|
| 60 |
+
fn=self.pose_alignment_infer.align_pose,
|
| 61 |
+
cache_examples="lazy")
|
| 62 |
+
|
| 63 |
+
btn_align_pose.click(fn=self.pose_alignment_infer.align_pose,
|
| 64 |
+
inputs=[vid_dance_input, img_pose_input, nb_detect_resolution, nb_image_resolution,
|
| 65 |
+
nb_align_frame, nb_max_frame],
|
| 66 |
+
outputs=[vid_dance_output, vid_dance_output_demo])
|
| 67 |
|
| 68 |
with gr.TabItem('2: MusePose Inference'):
|
| 69 |
with gr.Row():
|
|
|
|
| 73 |
with gr.Column(scale=3):
|
| 74 |
vid_output = gr.Video(label="MusePose Output", scale=5)
|
| 75 |
vid_output_demo = gr.Video(label="MusePose Output Demo", scale=5)
|
| 76 |
+
|
| 77 |
+
with gr.Column(scale=3):
|
| 78 |
+
with gr.Column():
|
| 79 |
+
weight_dtype = gr.Dropdown(label="Compute Type", choices=["fp16", "fp32"], value="fp16")
|
| 80 |
+
nb_width = gr.Number(label="Width", value=512, precision=0)
|
| 81 |
+
nb_height = gr.Number(label="Height", value=512, precision=0)
|
| 82 |
+
nb_video_frame_length = gr.Number(label="Video Frame Length", value=300, precision=0)
|
| 83 |
+
nb_video_slice_frame_length = gr.Number(label="Video Slice Frame Number", value=48, precision=0)
|
| 84 |
+
nb_video_slice_overlap_frame_number = gr.Number(label="Video Slice Overlap Frame Number", value=4, precision=0)
|
| 85 |
+
nb_cfg = gr.Number(label="CFG (Classifier Free Guidance)", value=3.5, precision=0)
|
| 86 |
+
nb_seed = gr.Number(label="Seed", value=99, precision=0)
|
| 87 |
+
nb_steps = gr.Number(label="DDIM Sampling Steps", value=20, precision=0)
|
| 88 |
+
nb_fps = gr.Number(label="FPS (Frames Per Second)", value=-1, precision=0, info="Set to '-1' to use same FPS with pose's")
|
| 89 |
+
nb_skip = gr.Number(label="SKIP (Frame Sample Rate = SKIP+1)", value=1, precision=0)
|
| 90 |
+
with gr.Row():
|
| 91 |
+
btn_generate = gr.Button("GENERATE", variant="primary")
|
| 92 |
+
|
| 93 |
+
btn_generate.click(fn=self.musepose_infer.infer_musepose,
|
| 94 |
+
inputs=[img_musepose_input, vid_pose_input, weight_dtype, nb_width, nb_height,
|
| 95 |
+
nb_video_frame_length, nb_video_slice_frame_length,
|
| 96 |
+
nb_video_slice_overlap_frame_number, nb_cfg, nb_seed, nb_steps, nb_fps,
|
| 97 |
+
nb_skip],
|
| 98 |
+
outputs=[vid_output, vid_output_demo])
|
| 99 |
+
vid_dance_output.change(fn=self.on_step1_complete,
|
| 100 |
+
inputs=[img_pose_input, vid_dance_output],
|
| 101 |
+
outputs=[img_musepose_input, vid_pose_input])
|
| 102 |
+
|
| 103 |
+
return demo
|
| 104 |
|
| 105 |
@staticmethod
|
| 106 |
def header():
|
|
|
|
| 110 |
<a href="https://github.com/jhj0517/MusePose-WebUI" target="_blank">MusePose WebUI</a>
|
| 111 |
</h1>
|
| 112 |
<p style="font-size: 18px;">
|
| 113 |
+
<strong>Note</strong>: This space only allows video input up to <strong>10 seconds</strong> because ZeroGPU limits the function runtime to 2 minutes.<br>
|
| 114 |
If you want longer video inputs, you have to run it locally. Click the link above and follow the README to try it locally.<br><br>
|
| 115 |
When you have completed the <strong>1: Pose Alignment</strong> process, go to <strong>2: MusePose Inference</strong> and click the "GENERATE" button.
|
| 116 |
</p>
|