Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,6 +35,7 @@ def process_video(video_path, prompt, num_steps, degradation_level):
|
|
| 35 |
|
| 36 |
try:
|
| 37 |
# Step 1: Warp the noise
|
|
|
|
| 38 |
warp_command = [
|
| 39 |
"python", "make_warped_noise.py", video_path,
|
| 40 |
"--output_folder", output_folder
|
|
@@ -44,6 +45,7 @@ def process_video(video_path, prompt, num_steps, degradation_level):
|
|
| 44 |
warped_vid_path = os.path.join(output_folder, "input.mp4")
|
| 45 |
|
| 46 |
# Step 2: Run inference
|
|
|
|
| 47 |
inference_command = [
|
| 48 |
"python", "cut_and_drag_inference.py", output_folder,
|
| 49 |
"--prompt", prompt,
|
|
@@ -55,7 +57,8 @@ def process_video(video_path, prompt, num_steps, degradation_level):
|
|
| 55 |
subprocess.run(inference_command, check=True)
|
| 56 |
|
| 57 |
# Return the path to the output video
|
| 58 |
-
|
|
|
|
| 59 |
except subprocess.CalledProcessError as e:
|
| 60 |
|
| 61 |
raise gr.Error(f"An error occurred: {str(e)}")
|
|
@@ -104,12 +107,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 104 |
gr.Examples(
|
| 105 |
examples = [
|
| 106 |
["./examples/example_1.mp4", "yellow plastic duck is swimming and jumping in the water"],
|
| 107 |
-
["./examples/example_2.mp4", "
|
| 108 |
],
|
| 109 |
inputs = [input_video, prompt]
|
| 110 |
)
|
| 111 |
with gr.Column():
|
| 112 |
output_video = gr.Video(label="Result")
|
|
|
|
| 113 |
gr.HTML("""
|
| 114 |
<div id="follow-div">
|
| 115 |
<a href="https://huggingface.co/fffiloni">
|
|
@@ -121,7 +125,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 121 |
submit_btn.click(
|
| 122 |
fn = process_video,
|
| 123 |
inputs = [input_video, prompt, num_steps, degradation],
|
| 124 |
-
outputs = [output_video]
|
| 125 |
)
|
| 126 |
|
| 127 |
demo.queue().launch(show_api=False)
|
|
|
|
| 35 |
|
| 36 |
try:
|
| 37 |
# Step 1: Warp the noise
|
| 38 |
+
gr.Info("Step 1: Warp the noise...")
|
| 39 |
warp_command = [
|
| 40 |
"python", "make_warped_noise.py", video_path,
|
| 41 |
"--output_folder", output_folder
|
|
|
|
| 45 |
warped_vid_path = os.path.join(output_folder, "input.mp4")
|
| 46 |
|
| 47 |
# Step 2: Run inference
|
| 48 |
+
gr.Info("Step 2: Run inference...")
|
| 49 |
inference_command = [
|
| 50 |
"python", "cut_and_drag_inference.py", output_folder,
|
| 51 |
"--prompt", prompt,
|
|
|
|
| 57 |
subprocess.run(inference_command, check=True)
|
| 58 |
|
| 59 |
# Return the path to the output video
|
| 60 |
+
gr.Success("Done!")
|
| 61 |
+
return output_video, "noise_warp_output_folder.mp4"
|
| 62 |
except subprocess.CalledProcessError as e:
|
| 63 |
|
| 64 |
raise gr.Error(f"An error occurred: {str(e)}")
|
|
|
|
| 107 |
gr.Examples(
|
| 108 |
examples = [
|
| 109 |
["./examples/example_1.mp4", "yellow plastic duck is swimming and jumping in the water"],
|
| 110 |
+
["./examples/example_2.mp4", "a car enters the frame and goes forward to the end of the street"]
|
| 111 |
],
|
| 112 |
inputs = [input_video, prompt]
|
| 113 |
)
|
| 114 |
with gr.Column():
|
| 115 |
output_video = gr.Video(label="Result")
|
| 116 |
+
warp_output_video = gr.Video(label="Warped Noise")
|
| 117 |
gr.HTML("""
|
| 118 |
<div id="follow-div">
|
| 119 |
<a href="https://huggingface.co/fffiloni">
|
|
|
|
| 125 |
submit_btn.click(
|
| 126 |
fn = process_video,
|
| 127 |
inputs = [input_video, prompt, num_steps, degradation],
|
| 128 |
+
outputs = [output_video, warp_output_video]
|
| 129 |
)
|
| 130 |
|
| 131 |
demo.queue().launch(show_api=False)
|