Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
|
5 |
+
def process_video(video_path, prompt):
|
6 |
+
|
7 |
+
output_folder="noise_warp_output_folder"
|
8 |
+
output_video="output.mp4"
|
9 |
+
device="cuda"
|
10 |
+
num_steps=5
|
11 |
+
|
12 |
+
try:
|
13 |
+
# Step 1: Warp the noise
|
14 |
+
warp_command = [
|
15 |
+
"python", "make_warped_noise.py", video_path,
|
16 |
+
"--output_folder", output_folder
|
17 |
+
]
|
18 |
+
subprocess.run(warp_command, check=True)
|
19 |
+
|
20 |
+
# Step 2: Run inference
|
21 |
+
inference_command = [
|
22 |
+
"python", "cut_and_drag_inference.py", output_folder,
|
23 |
+
"--prompt", prompt,
|
24 |
+
"--output_mp4_path", output_video,
|
25 |
+
"--device", device,
|
26 |
+
"--num_inference_steps", str(num_steps)
|
27 |
+
]
|
28 |
+
subprocess.run(inference_command, check=True)
|
29 |
+
|
30 |
+
# Return the path to the output video
|
31 |
+
return output_video
|
32 |
+
except subprocess.CalledProcessError as e:
|
33 |
+
|
34 |
+
raise gr.Error(f"An error occurred: {str(e)}")
|
35 |
+
|
36 |
+
with gr.Blocks() as demo:
|
37 |
+
with gr.Column():
|
38 |
+
gr.Markdown("# Go-With-The-Flow")
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
input_video = gr.Video(label="Input Video")
|
42 |
+
prompt = gr.Textbox(label="Prompt")
|
43 |
+
submit_btn = gr.Button("Submit")
|
44 |
+
with gr.Column():
|
45 |
+
output_video = gr.Video(label="Result")
|
46 |
+
|
47 |
+
submit_btn.click(
|
48 |
+
fn = process_video,
|
49 |
+
inputs = [input_video, prompt],
|
50 |
+
outputs = [output_video]
|
51 |
+
)
|
52 |
+
|