Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import os
|
|
3 |
import shutil
|
4 |
import yaml
|
5 |
import tempfile
|
|
|
6 |
import huggingface_hub
|
7 |
import subprocess
|
8 |
import threading
|
@@ -18,22 +19,19 @@ huggingface_hub.login(token=HF_TKN)
|
|
18 |
huggingface_hub.hf_hub_download(
|
19 |
repo_id='yzd-v/DWPose',
|
20 |
filename='yolox_l.onnx',
|
21 |
-
local_dir='./models/DWPose'
|
22 |
-
local_dir_use_symlinks=False,
|
23 |
)
|
24 |
|
25 |
huggingface_hub.hf_hub_download(
|
26 |
repo_id='yzd-v/DWPose',
|
27 |
filename='dw-ll_ucoco_384.onnx',
|
28 |
-
local_dir='./models/DWPose'
|
29 |
-
local_dir_use_symlinks=False,
|
30 |
)
|
31 |
|
32 |
huggingface_hub.hf_hub_download(
|
33 |
repo_id='ixaac/MimicMotion',
|
34 |
-
filename='MimicMotion_1
|
35 |
-
local_dir='./models'
|
36 |
-
local_dir_use_symlinks=False,
|
37 |
)
|
38 |
|
39 |
def print_directory_contents(path):
|
@@ -78,6 +76,21 @@ def check_for_mp4_in_outputs():
|
|
78 |
else:
|
79 |
return None
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
def infer(ref_image_in, ref_video_in):
|
82 |
# check if 'outputs' dir exists and empty it if necessary
|
83 |
check_outputs_folder('./outputs')
|
@@ -89,20 +102,20 @@ def infer(ref_image_in, ref_video_in):
|
|
89 |
# Define the values for the variables
|
90 |
ref_video_path = ref_video_in
|
91 |
ref_image_path = ref_image_in
|
92 |
-
num_frames =
|
93 |
resolution = 576
|
94 |
frames_overlap = 6
|
95 |
num_inference_steps = 25
|
96 |
noise_aug_strength = 0
|
97 |
guidance_scale = 2.0
|
98 |
sample_stride = 2
|
99 |
-
fps =
|
100 |
seed = 42
|
101 |
|
102 |
# Create the data structure
|
103 |
data = {
|
104 |
'base_model_path': 'stabilityai/stable-video-diffusion-img2vid-xt-1-1',
|
105 |
-
'ckpt_path': 'models/MimicMotion_1
|
106 |
'test_case': [
|
107 |
{
|
108 |
'ref_video_path': ref_video_path,
|
|
|
3 |
import shutil
|
4 |
import yaml
|
5 |
import tempfile
|
6 |
+
import cv2
|
7 |
import huggingface_hub
|
8 |
import subprocess
|
9 |
import threading
|
|
|
19 |
huggingface_hub.hf_hub_download(
|
20 |
repo_id='yzd-v/DWPose',
|
21 |
filename='yolox_l.onnx',
|
22 |
+
local_dir='./models/DWPose'
|
|
|
23 |
)
|
24 |
|
25 |
huggingface_hub.hf_hub_download(
|
26 |
repo_id='yzd-v/DWPose',
|
27 |
filename='dw-ll_ucoco_384.onnx',
|
28 |
+
local_dir='./models/DWPose'
|
|
|
29 |
)
|
30 |
|
31 |
huggingface_hub.hf_hub_download(
|
32 |
repo_id='ixaac/MimicMotion',
|
33 |
+
filename='MimicMotion_1.pth',
|
34 |
+
local_dir='./models'
|
|
|
35 |
)
|
36 |
|
37 |
def print_directory_contents(path):
|
|
|
76 |
else:
|
77 |
return None
|
78 |
|
79 |
+
def get_video_fps(video_path):
|
80 |
+
# Open the video file
|
81 |
+
video_capture = cv2.VideoCapture(video_path)
|
82 |
+
|
83 |
+
if not video_capture.isOpened():
|
84 |
+
raise ValueError("Error opening video file")
|
85 |
+
|
86 |
+
# Get the FPS value
|
87 |
+
fps = video_capture.get(cv2.CAP_PROP_FPS)
|
88 |
+
|
89 |
+
# Release the video capture object
|
90 |
+
video_capture.release()
|
91 |
+
|
92 |
+
return fps
|
93 |
+
|
94 |
def infer(ref_image_in, ref_video_in):
|
95 |
# check if 'outputs' dir exists and empty it if necessary
|
96 |
check_outputs_folder('./outputs')
|
|
|
102 |
# Define the values for the variables
|
103 |
ref_video_path = ref_video_in
|
104 |
ref_image_path = ref_image_in
|
105 |
+
num_frames = 16
|
106 |
resolution = 576
|
107 |
frames_overlap = 6
|
108 |
num_inference_steps = 25
|
109 |
noise_aug_strength = 0
|
110 |
guidance_scale = 2.0
|
111 |
sample_stride = 2
|
112 |
+
fps = get_video_fps(ref_video_in)
|
113 |
seed = 42
|
114 |
|
115 |
# Create the data structure
|
116 |
data = {
|
117 |
'base_model_path': 'stabilityai/stable-video-diffusion-img2vid-xt-1-1',
|
118 |
+
'ckpt_path': 'models/MimicMotion_1.pth',
|
119 |
'test_case': [
|
120 |
{
|
121 |
'ref_video_path': ref_video_path,
|