Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,24 +17,23 @@ import subprocess
|
|
17 |
|
18 |
import cv2
|
19 |
|
20 |
-
def get_frame_count_in_duration(filepath
|
21 |
video = cv2.VideoCapture(filepath)
|
22 |
fps = video.get(cv2.CAP_PROP_FPS)
|
23 |
-
frame_count = int(
|
|
|
|
|
|
|
24 |
video.release()
|
25 |
-
return frame_count
|
26 |
|
27 |
|
28 |
|
29 |
def run_inference(prompt, video_path, condition, video_length):
|
30 |
-
|
31 |
-
video_length = get_frame_count_in_duration(video_path, video_length)
|
32 |
-
print(video_length)
|
33 |
-
nb_frame = int(video_length)
|
34 |
-
#video_length = int(video_length * fps)
|
35 |
output_path = 'output/'
|
36 |
os.makedirs(output_path, exist_ok=True)
|
37 |
-
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --video_length {
|
38 |
subprocess.run(command, shell=True)
|
39 |
|
40 |
# Construct the video path
|
@@ -55,7 +54,10 @@ with gr.Blocks() as demo:
|
|
55 |
submit_btn = gr.Button("Submit")
|
56 |
video_res = gr.Video(label="result")
|
57 |
status = gr.Textbox(label="result")
|
58 |
-
|
|
|
|
|
|
|
59 |
submit_btn.click(fn=run_inference,
|
60 |
inputs=[prompt,
|
61 |
video_path,
|
|
|
17 |
|
18 |
import cv2
|
19 |
|
20 |
+
def get_frame_count_in_duration(filepath):
|
21 |
video = cv2.VideoCapture(filepath)
|
22 |
fps = video.get(cv2.CAP_PROP_FPS)
|
23 |
+
frame_count = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
|
24 |
+
duration = frame_count / fps
|
25 |
+
width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
|
26 |
+
height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
27 |
video.release()
|
28 |
+
return gr.update(maximum=frame_count)
|
29 |
|
30 |
|
31 |
|
32 |
def run_inference(prompt, video_path, condition, video_length):
|
33 |
+
|
|
|
|
|
|
|
|
|
34 |
output_path = 'output/'
|
35 |
os.makedirs(output_path, exist_ok=True)
|
36 |
+
command = f"python inference.py --prompt '{prompt}' --condition '{condition}' --video_path '{video_path}' --output_path '{output_path}' --video_length {video_length} --smoother_steps 19 20"
|
37 |
subprocess.run(command, shell=True)
|
38 |
|
39 |
# Construct the video path
|
|
|
54 |
submit_btn = gr.Button("Submit")
|
55 |
video_res = gr.Video(label="result")
|
56 |
status = gr.Textbox(label="result")
|
57 |
+
video_path.change(fn=get_frame_count_in_duration,
|
58 |
+
inputs=[video_path],
|
59 |
+
outputs=[video_length]
|
60 |
+
)
|
61 |
submit_btn.click(fn=run_inference,
|
62 |
inputs=[prompt,
|
63 |
video_path,
|