Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def resize_video(input_path, output_path, width):
|
|
45 |
height = int(video.size[1] * (width / video.size[0]))
|
46 |
|
47 |
# Resize the video
|
48 |
-
resized_video = video.resize(width=width, height=
|
49 |
|
50 |
# Write the resized video to the output path
|
51 |
resized_video.write_videofile(output_path, codec='libx264')
|
@@ -86,6 +86,48 @@ def run_inference(prompt, video_path, condition, video_length):
|
|
86 |
|
87 |
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
return "done", video_path_output
|
90 |
|
91 |
css="""
|
|
|
45 |
height = int(video.size[1] * (width / video.size[0]))
|
46 |
|
47 |
# Resize the video
|
48 |
+
resized_video = video.resize(width=width, height=512)
|
49 |
|
50 |
# Write the resized video to the output path
|
51 |
resized_video.write_videofile(output_path, codec='libx264')
|
|
|
86 |
|
87 |
|
88 |
|
89 |
+
return "done", video_path_output
|
90 |
+
|
91 |
+
def run_inference_chunks(prompt, video_path, condition, video_length):
|
92 |
+
|
93 |
+
# Specify the input and output paths
|
94 |
+
input_vid = video_path
|
95 |
+
resized_vid = 'resized.mp4'
|
96 |
+
|
97 |
+
# Call the function to resize the video
|
98 |
+
video_path = resize_video(input_vid, resized_vid, width=512)
|
99 |
+
width, height, fps = get_video_dimension(video_path)
|
100 |
+
|
101 |
+
print(f"{width} x {height} | {fps}")
|
102 |
+
|
103 |
+
# Split the video into chunks mp4 of 12 frames at video fps
|
104 |
+
# Store chunks as mp4 paths in an array
|
105 |
+
|
106 |
+
# For each mp4 chunks in chunks arrays, run command
|
107 |
+
# store video result in processed chunks array
|
108 |
+
|
109 |
+
output_path = 'output/'
|
110 |
+
os.makedirs(output_path, exist_ok=True)
|
111 |
+
|
112 |
+
# Construct the final video path
|
113 |
+
video_path_output = os.path.join(output_path, f"{prompt}.mp4")
|
114 |
+
|
115 |
+
# Check if the file already exists
|
116 |
+
if os.path.exists(video_path_output):
|
117 |
+
# Delete the existing file
|
118 |
+
os.remove(video_path_output)
|
119 |
+
|
120 |
+
if video_length > 12:
|
121 |
+
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --width {width} --height {height} --fps {fps} --video_length {video_length} --is_long_video"
|
122 |
+
else:
|
123 |
+
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --width {width} --height {height} --fps {fps} --video_length {video_length}"
|
124 |
+
subprocess.run(command, shell=True)
|
125 |
+
|
126 |
+
# Construct the video path
|
127 |
+
video_path_output = os.path.join(output_path, f"{prompt}.mp4")
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
return "done", video_path_output
|
132 |
|
133 |
css="""
|