Spaces:
Running
on
A100
Running
on
A100
app.py
CHANGED
@@ -61,8 +61,8 @@ def create_ui(examples_path: str):
|
|
61 |
interactive=False
|
62 |
)
|
63 |
with gr.Accordion("Chain of thought details", open=False):
|
64 |
-
gr.Markdown(f"### Summary
|
65 |
-
gr.Markdown(f"### Highlights to search for
|
66 |
|
67 |
gr.Markdown("## Try It Yourself!")
|
68 |
with gr.Row():
|
@@ -94,6 +94,14 @@ def create_ui(examples_path: str):
|
|
94 |
|
95 |
@spaces.GPU
|
96 |
def on_process(video):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
if not video:
|
98 |
yield [
|
99 |
"Please upload a video",
|
@@ -129,7 +137,7 @@ def create_ui(examples_path: str):
|
|
129 |
detector = BatchedVideoHighlightDetector(
|
130 |
model,
|
131 |
processor,
|
132 |
-
batch_size=
|
133 |
)
|
134 |
|
135 |
yield [
|
@@ -141,7 +149,7 @@ def create_ui(examples_path: str):
|
|
141 |
]
|
142 |
|
143 |
video_desc = detector.analyze_video_content(video)
|
144 |
-
formatted_desc = f"### Summary
|
145 |
|
146 |
yield [
|
147 |
"Determining highlight types...",
|
@@ -152,7 +160,7 @@ def create_ui(examples_path: str):
|
|
152 |
]
|
153 |
|
154 |
highlights = detector.determine_highlights(video_desc)
|
155 |
-
formatted_highlights = f"### Highlights to search for
|
156 |
|
157 |
# Get all segments
|
158 |
segments = get_fixed_30s_segments(video)
|
@@ -208,6 +216,11 @@ def create_ui(examples_path: str):
|
|
208 |
gr.update(visible=False),
|
209 |
gr.update(visible=False)
|
210 |
]
|
|
|
|
|
|
|
|
|
|
|
211 |
|
212 |
process_btn.click(
|
213 |
on_process,
|
|
|
61 |
interactive=False
|
62 |
)
|
63 |
with gr.Accordion("Chain of thought details", open=False):
|
64 |
+
gr.Markdown(f"### Summary:\n{example['analysis']['video_description']}")
|
65 |
+
gr.Markdown(f"### Highlights to search for:\n{example['analysis']['highlight_types']}")
|
66 |
|
67 |
gr.Markdown("## Try It Yourself!")
|
68 |
with gr.Row():
|
|
|
94 |
|
95 |
@spaces.GPU
|
96 |
def on_process(video):
|
97 |
+
# Clear all components when starting new processing
|
98 |
+
yield [
|
99 |
+
"", # Clear status
|
100 |
+
"", # Clear video description
|
101 |
+
"", # Clear highlight types
|
102 |
+
gr.update(value=None, visible=False), # Clear video
|
103 |
+
gr.update(visible=False) # Hide accordion
|
104 |
+
]
|
105 |
if not video:
|
106 |
yield [
|
107 |
"Please upload a video",
|
|
|
137 |
detector = BatchedVideoHighlightDetector(
|
138 |
model,
|
139 |
processor,
|
140 |
+
batch_size=8
|
141 |
)
|
142 |
|
143 |
yield [
|
|
|
149 |
]
|
150 |
|
151 |
video_desc = detector.analyze_video_content(video)
|
152 |
+
formatted_desc = f"### Summary:\n {video_desc[:500] + '...' if len(video_desc) > 500 else video_desc}"
|
153 |
|
154 |
yield [
|
155 |
"Determining highlight types...",
|
|
|
160 |
]
|
161 |
|
162 |
highlights = detector.determine_highlights(video_desc)
|
163 |
+
formatted_highlights = f"### Highlights to search for:\n {highlights[:500] + '...' if len(highlights) > 500 else highlights}"
|
164 |
|
165 |
# Get all segments
|
166 |
segments = get_fixed_30s_segments(video)
|
|
|
216 |
gr.update(visible=False),
|
217 |
gr.update(visible=False)
|
218 |
]
|
219 |
+
finally:
|
220 |
+
if model is not None:
|
221 |
+
del model
|
222 |
+
torch.cuda.empty_cache()
|
223 |
+
|
224 |
|
225 |
process_btn.click(
|
226 |
on_process,
|