Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,16 +66,23 @@ def save_uploaded_file(uploaded_file):
|
|
66 |
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes")
|
67 |
return file_path
|
68 |
|
69 |
-
def display_results(video_file, description):
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
video_file_path = save_uploaded_file(video_file)
|
72 |
if video_file_path:
|
73 |
final_clip_path = process_video(video_file_path, description, is_url=False)
|
74 |
-
return final_clip_path, gr.Video.update(value=final_clip_path)
|
75 |
else:
|
76 |
-
return "
|
|
|
|
|
|
|
77 |
else:
|
78 |
-
return "No
|
79 |
|
80 |
css = """
|
81 |
body {
|
@@ -128,15 +135,15 @@ h3 {
|
|
128 |
|
129 |
with gr.Blocks() as demo:
|
130 |
with gr.Column():
|
131 |
-
|
|
|
132 |
description = gr.Textbox(label="Describe your clip")
|
133 |
submit_button = gr.Button("Process Video")
|
134 |
video_output = gr.Video(label="Processed Video")
|
135 |
download_output = gr.File(label="Download Processed Video")
|
136 |
-
|
137 |
submit_button.click(
|
138 |
fn=display_results,
|
139 |
-
inputs=[
|
140 |
outputs=[video_output, download_output]
|
141 |
)
|
142 |
|
|
|
66 |
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes")
|
67 |
return file_path
|
68 |
|
69 |
+
def display_results(video_url, video_file, description):
|
70 |
+
"""Process video from URL or file upload and return the results."""
|
71 |
+
final_clip_path = None
|
72 |
+
|
73 |
+
if video_url:
|
74 |
+
final_clip_path = process_video(video_url, description, is_url=True)
|
75 |
+
elif video_file:
|
76 |
video_file_path = save_uploaded_file(video_file)
|
77 |
if video_file_path:
|
78 |
final_clip_path = process_video(video_file_path, description, is_url=False)
|
|
|
79 |
else:
|
80 |
+
return "No file provided or file save error", None
|
81 |
+
|
82 |
+
if final_clip_path:
|
83 |
+
return final_clip_path, final_clip_path # Returning the path twice, for both video and download components
|
84 |
else:
|
85 |
+
return "No matching scene found", None
|
86 |
|
87 |
css = """
|
88 |
body {
|
|
|
135 |
|
136 |
with gr.Blocks() as demo:
|
137 |
with gr.Column():
|
138 |
+
video_url = gr.Textbox(label="Video URL")
|
139 |
+
video_file = gr.UploadButton(label="Upload Video File", type="bytes", file_types=["video"])
|
140 |
description = gr.Textbox(label="Describe your clip")
|
141 |
submit_button = gr.Button("Process Video")
|
142 |
video_output = gr.Video(label="Processed Video")
|
143 |
download_output = gr.File(label="Download Processed Video")
|
|
|
144 |
submit_button.click(
|
145 |
fn=display_results,
|
146 |
+
inputs=[video_url, video_file, description],
|
147 |
outputs=[video_output, download_output]
|
148 |
)
|
149 |
|