Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,7 +111,7 @@ def normalize_and_save_video(input_video_path, output_video_path):
|
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
-
def run_inference(prompt, video_path, condition, video_length, seed):
|
| 115 |
|
| 116 |
seed = math.floor(seed)
|
| 117 |
|
|
@@ -141,21 +141,24 @@ def run_inference(prompt, video_path, condition, video_length, seed):
|
|
| 141 |
|
| 142 |
print(f"RUNNING INFERENCE ...")
|
| 143 |
if video_length > 12:
|
| 144 |
-
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{normalized}' --output_path '{output_path}' --temp_chunk_path 'result' --width 512 --height 512 --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 10 12 --is_long_video"
|
| 145 |
else:
|
| 146 |
-
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{normalized}' --output_path '{output_path}' --temp_chunk_path 'result' --width 512 --height 512 --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 19 20"
|
| 147 |
-
|
|
|
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
|
|
@@ -177,6 +180,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 177 |
with gr.Row():
|
| 178 |
condition = gr.Dropdown(label="Condition", choices=["depth", "canny", "pose"], value="depth")
|
| 179 |
seed = gr.Number(label="seed", value=42)
|
|
|
|
| 180 |
submit_btn = gr.Button("Submit")
|
| 181 |
with gr.Column():
|
| 182 |
video_res = gr.Video(label="result")
|
|
@@ -191,7 +195,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 191 |
video_path,
|
| 192 |
condition,
|
| 193 |
video_length,
|
| 194 |
-
seed
|
|
|
|
| 195 |
],
|
| 196 |
outputs=[status, video_res])
|
| 197 |
|
|
|
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
+
def run_inference(prompt, video_path, condition, video_length, seed, steps):
|
| 115 |
|
| 116 |
seed = math.floor(seed)
|
| 117 |
|
|
|
|
| 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 '{normalized}' --output_path '{output_path}' --temp_chunk_path 'result' --width 512 --height 512 --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 10 12 --is_long_video"
|
| 145 |
else:
|
| 146 |
+
command = f"python inference.py --prompt '{prompt}' --inference_steps {steps} --condition '{condition}' --video_path '{normalized}' --output_path '{output_path}' --temp_chunk_path 'result' --width 512 --height 512 --fps {target_fps} --seed {seed} --video_length {video_length} --smoother_steps 19 20"
|
| 147 |
+
try:
|
| 148 |
+
subprocess.run(command, shell=True)
|
| 149 |
|
| 150 |
+
# Construct the video path
|
| 151 |
+
video_path_output = os.path.join(output_path, f"result.mp4")
|
| 152 |
+
|
| 153 |
+
# Resize to original video input size
|
| 154 |
+
o_width = get_video_dimension(video_path)[0]
|
| 155 |
+
o_height = get_video_dimension(video_path)[1]
|
| 156 |
+
resize_video(video_path_output, 'resized_final.mp4', o_width, o_height, target_fps)
|
| 157 |
+
|
| 158 |
+
print(f"FINISHED !")
|
| 159 |
+
return "done", 'resized_final.mp4'
|
| 160 |
+
except:
|
| 161 |
+
return "error", None
|
| 162 |
|
| 163 |
|
| 164 |
|
|
|
|
| 180 |
with gr.Row():
|
| 181 |
condition = gr.Dropdown(label="Condition", choices=["depth", "canny", "pose"], value="depth")
|
| 182 |
seed = gr.Number(label="seed", value=42)
|
| 183 |
+
inference_steps = gr.Slider(label="Inference steps", minimum=12, maximum=50, step=1, value=25)
|
| 184 |
submit_btn = gr.Button("Submit")
|
| 185 |
with gr.Column():
|
| 186 |
video_res = gr.Video(label="result")
|
|
|
|
| 195 |
video_path,
|
| 196 |
condition,
|
| 197 |
video_length,
|
| 198 |
+
seed,
|
| 199 |
+
inference_steps
|
| 200 |
],
|
| 201 |
outputs=[status, video_res])
|
| 202 |
|