Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,9 @@ def chunkify(video_path, fps, nb_frames):
|
|
100 |
return chunks_array
|
101 |
|
102 |
|
103 |
-
def
|
|
|
|
|
104 |
|
105 |
# Get FPS of original video input
|
106 |
target_fps = get_video_dimension(video_path)[2]
|
@@ -147,6 +149,43 @@ def run_inference(prompt, video_path, condition, video_length):
|
|
147 |
|
148 |
return "done", processed_chunks[0]
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
|
152 |
css="""
|
|
|
100 |
return chunks_array
|
101 |
|
102 |
|
103 |
+
def run_inference_by_chunkify(prompt, video_path, condition, video_length):
|
104 |
+
|
105 |
+
# DOESN'T WORK
|
106 |
|
107 |
# Get FPS of original video input
|
108 |
target_fps = get_video_dimension(video_path)[2]
|
|
|
149 |
|
150 |
return "done", processed_chunks[0]
|
151 |
|
152 |
+
|
153 |
+
def run_inference(prompt, video_path, condition, video_length):
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
# Get FPS of original video input
|
158 |
+
target_fps = get_video_dimension(video_path)[2]
|
159 |
+
print(f"INPUT FPS: {target_fps}")
|
160 |
+
|
161 |
+
# Count total frames according to fps
|
162 |
+
total_frames = get_video_dimension(video_path)[3]
|
163 |
+
|
164 |
+
# Resize the video
|
165 |
+
resized = resize_video(video_path, 'resized.mp4', 512, 512, target_fps)
|
166 |
+
|
167 |
+
|
168 |
+
|
169 |
+
# Check if the file already exists
|
170 |
+
if os.path.exists(os.path.join(output_path, f"result.mp4")):
|
171 |
+
# Delete the existing file
|
172 |
+
os.remove(os.path.join(output_path, f"result.mp4"))
|
173 |
+
|
174 |
+
if video_length > 12:
|
175 |
+
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{resized}' --output_path '{output_path}' --width 512 --height 512 --fps 8 --video_length {video_length} --is_long_video"
|
176 |
+
else:
|
177 |
+
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{resized}' --output_path '{output_path}' --temp_chunk_path 'result' --width 512 --height 512 --fps 8 --video_length {video_length}"
|
178 |
+
subprocess.run(command, shell=True)
|
179 |
+
|
180 |
+
# Construct the video path
|
181 |
+
video_path_output = os.path.join(output_path, f"result.mp4")
|
182 |
+
|
183 |
+
# Append processed chunk to final array
|
184 |
+
processed_chunks.append(video_path_output)
|
185 |
+
|
186 |
+
|
187 |
+
return "done", video_path_output
|
188 |
+
|
189 |
|
190 |
|
191 |
css="""
|