Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -109,11 +109,19 @@ def normalize_and_save_video(input_video_path, output_video_path):
|
|
109 |
print(f"NORMALIZE DONE!")
|
110 |
return output_video_path
|
111 |
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
115 |
|
116 |
seed = math.floor(seed)
|
|
|
|
|
117 |
|
118 |
# Get FPS of original video input
|
119 |
target_fps = get_video_dimension(video_path)[2]
|
@@ -126,7 +134,9 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
|
126 |
total_frames = get_video_dimension(video_path)[3]
|
127 |
|
128 |
# Resize the video
|
129 |
-
|
|
|
|
|
130 |
|
131 |
# normalize pixels
|
132 |
#normalized = normalize_and_save_video(resized, 'normalized.mp4')
|
@@ -141,9 +151,9 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
|
141 |
|
142 |
print(f"RUNNING INFERENCE ...")
|
143 |
if video_length > 12:
|
144 |
-
command = f"python inference.py --prompt '{prompt}' --inference_steps {steps} --condition '{condition}' --video_path '{
|
145 |
else:
|
146 |
-
command = f"python inference.py --prompt '{prompt}' --inference_steps {steps} --condition '{condition}' --video_path '{
|
147 |
|
148 |
try:
|
149 |
subprocess.run(command, shell=True)
|
@@ -156,9 +166,9 @@ def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
|
156 |
video_path_output = os.path.join(output_path, f"result.mp4")
|
157 |
|
158 |
# Resize to original video input size
|
159 |
-
o_width = get_video_dimension(video_path)[0]
|
160 |
-
o_height = get_video_dimension(video_path)[1]
|
161 |
-
resize_video(video_path_output, 'resized_final.mp4', o_width, o_height, target_fps)
|
162 |
|
163 |
print(f"FINISHED !")
|
164 |
return "done", 'resized_final.mp4'
|
|
|
109 |
print(f"NORMALIZE DONE!")
|
110 |
return output_video_path
|
111 |
|
112 |
+
def make_nearest_multiple_of_32(number):
|
113 |
+
remainder = number % 32
|
114 |
+
if remainder <= 16:
|
115 |
+
number -= remainder
|
116 |
+
else:
|
117 |
+
number += 32 - remainder
|
118 |
+
return number
|
119 |
|
120 |
def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
121 |
|
122 |
seed = math.floor(seed)
|
123 |
+
o_width = get_video_dimension(video_path)[0]
|
124 |
+
o_height = get_video_dimension(video_path)[1]
|
125 |
|
126 |
# Get FPS of original video input
|
127 |
target_fps = get_video_dimension(video_path)[2]
|
|
|
134 |
total_frames = get_video_dimension(video_path)[3]
|
135 |
|
136 |
# Resize the video
|
137 |
+
r_width = make_nearest_multiple_of_32(o_width)
|
138 |
+
r_height = make_nearest_multiple_of_32(o_height)
|
139 |
+
resized = resize_video(video_path, 'resized.mp4', r_width, r_height, target_fps)
|
140 |
|
141 |
# normalize pixels
|
142 |
#normalized = normalize_and_save_video(resized, 'normalized.mp4')
|
|
|
151 |
|
152 |
print(f"RUNNING INFERENCE ...")
|
153 |
if video_length > 12:
|
154 |
+
command = f"python inference.py --prompt '{prompt}' --inference_steps {steps} --condition '{condition}' --video_path '{resized}' --output_path '{output_path}' --temp_chunk_path 'result' --width {r_width} --height {r_height} --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 19 20 --is_long_video"
|
155 |
else:
|
156 |
+
command = f"python inference.py --prompt '{prompt}' --inference_steps {steps} --condition '{condition}' --video_path '{resized}' --output_path '{output_path}' --temp_chunk_path 'result' --width {r_width} --height {r_width} --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 19 20"
|
157 |
|
158 |
try:
|
159 |
subprocess.run(command, shell=True)
|
|
|
166 |
video_path_output = os.path.join(output_path, f"result.mp4")
|
167 |
|
168 |
# Resize to original video input size
|
169 |
+
#o_width = get_video_dimension(video_path)[0]
|
170 |
+
#o_height = get_video_dimension(video_path)[1]
|
171 |
+
#resize_video(video_path_output, 'resized_final.mp4', o_width, o_height, target_fps)
|
172 |
|
173 |
print(f"FINISHED !")
|
174 |
return "done", 'resized_final.mp4'
|