Spaces:
Running
on
A100
Running
on
A100
app.py
CHANGED
@@ -119,37 +119,41 @@ def create_ui(examples_path: str):
|
|
119 |
gr.Markdown(f"#Summary: {example['analysis']['video_description']}")
|
120 |
gr.Markdown(f"#Highlights to search for: {example['analysis']['highlight_types']}")
|
121 |
|
122 |
-
|
123 |
gr.Markdown("## Try It Yourself!")
|
124 |
with gr.Row():
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
def on_process(video, progress=gr.Progress()):
|
146 |
if not video:
|
147 |
return {
|
148 |
status: "Please upload a video",
|
149 |
-
video_description: gr.update(visible=False),
|
150 |
-
highlight_types: gr.update(visible=False),
|
151 |
output_video: gr.update(visible=False),
|
152 |
-
|
153 |
}
|
154 |
|
155 |
status.value = "Processing video..."
|
@@ -158,33 +162,100 @@ def create_ui(examples_path: str):
|
|
158 |
if err:
|
159 |
return {
|
160 |
status: f"Error: {err}",
|
161 |
-
video_description: gr.update(visible=False),
|
162 |
-
highlight_types: gr.update(visible=False),
|
163 |
output_video: gr.update(visible=False),
|
164 |
-
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
167 |
return {
|
168 |
status: "Processing complete!",
|
169 |
-
video_description: gr.update(value=desc, visible=True),
|
170 |
-
highlight_types: gr.update(value=highlights, visible=True),
|
171 |
output_video: gr.update(value=output_path, visible=True),
|
172 |
-
|
|
|
|
|
173 |
}
|
174 |
|
175 |
process_btn.click(
|
176 |
on_process,
|
177 |
inputs=[input_video],
|
178 |
-
outputs=[
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
)
|
186 |
|
187 |
return app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
if __name__ == "__main__":
|
190 |
# Initialize CUDA
|
|
|
119 |
gr.Markdown(f"#Summary: {example['analysis']['video_description']}")
|
120 |
gr.Markdown(f"#Highlights to search for: {example['analysis']['highlight_types']}")
|
121 |
|
122 |
+
# Main interface section
|
123 |
gr.Markdown("## Try It Yourself!")
|
124 |
with gr.Row():
|
125 |
+
# Left column: Upload and Process
|
126 |
+
with gr.Column(scale=1):
|
127 |
+
input_video = gr.Video(
|
128 |
+
label="Upload your video (max 20 minutes)",
|
129 |
+
interactive=True
|
130 |
+
)
|
131 |
+
process_btn = gr.Button("Process Video", variant="primary")
|
132 |
+
status = gr.Markdown(visible=True)
|
133 |
+
|
134 |
+
# Right column: Progress, Results and Analysis
|
135 |
+
with gr.Column(scale=1):
|
136 |
+
progress_bar = gr.Progress(elem_id="progress_bar")
|
137 |
+
|
138 |
+
# Output video (initially hidden)
|
139 |
+
output_video = gr.Video(
|
140 |
+
label="Highlight Video",
|
141 |
+
visible=False,
|
142 |
+
interactive=False,
|
143 |
+
downloadable=True # Enable download button
|
144 |
+
)
|
145 |
+
|
146 |
+
# Analysis accordion
|
147 |
+
with gr.Accordion("Model chain of thought details", open=True, visible=False) as analysis_accordion:
|
148 |
+
video_description = gr.Markdown(visible=True)
|
149 |
+
highlight_types = gr.Markdown(visible=True)
|
150 |
|
151 |
def on_process(video, progress=gr.Progress()):
|
152 |
if not video:
|
153 |
return {
|
154 |
status: "Please upload a video",
|
|
|
|
|
155 |
output_video: gr.update(visible=False),
|
156 |
+
analysis_accordion: gr.update(visible=False),
|
157 |
}
|
158 |
|
159 |
status.value = "Processing video..."
|
|
|
162 |
if err:
|
163 |
return {
|
164 |
status: f"Error: {err}",
|
|
|
|
|
165 |
output_video: gr.update(visible=False),
|
166 |
+
analysis_accordion: gr.update(visible=False),
|
167 |
}
|
168 |
|
169 |
+
# Format the analysis text
|
170 |
+
desc = f"#Summary: {desc[:500] + '...' if len(desc) > 500 else desc}"
|
171 |
+
highlights = f"#Highlights to search for: {highlights[:500] + '...' if len(highlights) > 500 else highlights}"
|
172 |
+
|
173 |
return {
|
174 |
status: "Processing complete!",
|
|
|
|
|
175 |
output_video: gr.update(value=output_path, visible=True),
|
176 |
+
analysis_accordion: gr.update(visible=True),
|
177 |
+
video_description: desc,
|
178 |
+
highlight_types: highlights,
|
179 |
}
|
180 |
|
181 |
process_btn.click(
|
182 |
on_process,
|
183 |
inputs=[input_video],
|
184 |
+
outputs=[
|
185 |
+
status,
|
186 |
+
output_video,
|
187 |
+
analysis_accordion,
|
188 |
+
video_description,
|
189 |
+
highlight_types,
|
190 |
+
]
|
191 |
)
|
192 |
|
193 |
return app
|
194 |
+
# gr.Markdown("## Try It Yourself!")
|
195 |
+
# with gr.Row():
|
196 |
+
# input_video = gr.Video(
|
197 |
+
# label="Upload your video (max 20 minutes)",
|
198 |
+
# interactive=True
|
199 |
+
# )
|
200 |
+
|
201 |
+
# gr.Progress()
|
202 |
+
# process_btn = gr.Button("Process Video", variant="primary")
|
203 |
+
|
204 |
+
# status = gr.Markdown(visible=True)
|
205 |
+
|
206 |
+
# with gr.Row() as results_row:
|
207 |
+
# with gr.Column():
|
208 |
+
# video_description = gr.Markdown(visible=False)
|
209 |
+
# with gr.Column():
|
210 |
+
# highlight_types = gr.Markdown(visible=False)
|
211 |
+
|
212 |
+
# with gr.Row() as output_row:
|
213 |
+
# output_video = gr.Video(label="Highlight Video", visible=False)
|
214 |
+
# download_btn = gr.Button("Download Highlights", visible=False)
|
215 |
+
|
216 |
+
# def on_process(video, progress=gr.Progress()):
|
217 |
+
# if not video:
|
218 |
+
# return {
|
219 |
+
# status: "Please upload a video",
|
220 |
+
# video_description: gr.update(visible=False),
|
221 |
+
# highlight_types: gr.update(visible=False),
|
222 |
+
# output_video: gr.update(visible=False),
|
223 |
+
# download_btn: gr.update(visible=False)
|
224 |
+
# }
|
225 |
+
|
226 |
+
# status.value = "Processing video..."
|
227 |
+
# output_path, desc, highlights, err = process_video(video, progress=progress)
|
228 |
+
|
229 |
+
# if err:
|
230 |
+
# return {
|
231 |
+
# status: f"Error: {err}",
|
232 |
+
# video_description: gr.update(visible=False),
|
233 |
+
# highlight_types: gr.update(visible=False),
|
234 |
+
# output_video: gr.update(visible=False),
|
235 |
+
# download_btn: gr.update(visible=False)
|
236 |
+
# }
|
237 |
+
|
238 |
+
# return {
|
239 |
+
# status: "Processing complete!",
|
240 |
+
# video_description: gr.update(value=desc, visible=True),
|
241 |
+
# highlight_types: gr.update(value=highlights, visible=True),
|
242 |
+
# output_video: gr.update(value=output_path, visible=True),
|
243 |
+
# download_btn: gr.update(visible=True)
|
244 |
+
# }
|
245 |
+
|
246 |
+
# process_btn.click(
|
247 |
+
# on_process,
|
248 |
+
# inputs=[input_video],
|
249 |
+
# outputs=[status, video_description, highlight_types, output_video, download_btn]
|
250 |
+
# )
|
251 |
+
|
252 |
+
# download_btn.click(
|
253 |
+
# lambda x: x,
|
254 |
+
# inputs=[output_video],
|
255 |
+
# outputs=[output_video]
|
256 |
+
# )
|
257 |
+
|
258 |
+
# return app
|
259 |
|
260 |
if __name__ == "__main__":
|
261 |
# Initialize CUDA
|