Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -157,290 +157,82 @@ def process_video(
|
|
157 |
return video_summary, frame_previews
|
158 |
|
159 |
# Create the Gradio interface
|
160 |
-
|
161 |
-
|
162 |
-
:
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
box-shadow: var(--apple-shadow-sm) !important;
|
237 |
-
}
|
238 |
-
|
239 |
-
.bot .message {
|
240 |
-
background: var(--apple-gray-2) !important;
|
241 |
-
color: var(--apple-text) !important;
|
242 |
-
border-radius: var(--apple-radius-lg) !important;
|
243 |
-
padding: 10px 16px !important;
|
244 |
-
box-shadow: var(--apple-shadow-sm) !important;
|
245 |
-
}
|
246 |
-
|
247 |
-
/* Buttons */
|
248 |
-
.gr-button {
|
249 |
-
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif !important;
|
250 |
-
font-weight: 500 !important;
|
251 |
-
border-radius: var(--apple-radius-sm) !important;
|
252 |
-
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
253 |
-
border: none !important;
|
254 |
-
box-shadow: var(--apple-shadow-sm) !important;
|
255 |
-
}
|
256 |
-
|
257 |
-
.gr-button-primary, .gr-button-primary:hover {
|
258 |
-
background: var(--apple-blue) !important;
|
259 |
-
color: white !important;
|
260 |
-
font-size: 16px !important;
|
261 |
-
padding: 12px 24px !important;
|
262 |
-
letter-spacing: -0.01em !important;
|
263 |
-
}
|
264 |
-
|
265 |
-
.gr-button-primary:hover {
|
266 |
-
background: var(--apple-blue-hover) !important;
|
267 |
-
transform: translateY(-1px) !important;
|
268 |
-
box-shadow: var(--apple-shadow-md) !important;
|
269 |
-
}
|
270 |
-
|
271 |
-
.gr-button-primary:active {
|
272 |
-
transform: translateY(0) !important;
|
273 |
-
}
|
274 |
-
|
275 |
-
/* Video component */
|
276 |
-
.gr-video {
|
277 |
-
border-radius: var(--apple-radius) !important;
|
278 |
-
overflow: hidden !important;
|
279 |
-
box-shadow: var(--apple-shadow-lg) !important;
|
280 |
-
border: 1px solid var(--apple-gray-3) !important;
|
281 |
-
background: var(--apple-text) !important;
|
282 |
-
}
|
283 |
-
|
284 |
-
video {
|
285 |
-
border-radius: var(--apple-radius) !important;
|
286 |
-
}
|
287 |
-
|
288 |
-
/* Sidebar */
|
289 |
-
.gr-sidebar {
|
290 |
-
background: var(--apple-bg) !important;
|
291 |
-
border-radius: var(--apple-radius) !important;
|
292 |
-
border: 1px solid var(--apple-gray-3) !important;
|
293 |
-
box-shadow: var(--apple-shadow-md) !important;
|
294 |
-
padding: 20px !important;
|
295 |
-
}
|
296 |
-
|
297 |
-
/* Accordion */
|
298 |
-
.gr-accordion {
|
299 |
-
background: var(--apple-gray-2) !important;
|
300 |
-
border-radius: var(--apple-radius-sm) !important;
|
301 |
-
border: 1px solid var(--apple-gray-3) !important;
|
302 |
-
overflow: hidden !important;
|
303 |
-
margin-top: 16px !important;
|
304 |
-
}
|
305 |
-
|
306 |
-
.gr-accordion-header {
|
307 |
-
background: var(--apple-gray-2) !important;
|
308 |
-
padding: 12px 16px !important;
|
309 |
-
font-weight: 500 !important;
|
310 |
-
color: var(--apple-text) !important;
|
311 |
-
border: none !important;
|
312 |
-
}
|
313 |
-
|
314 |
-
.gr-accordion-header:hover {
|
315 |
-
background: var(--apple-gray-3) !important;
|
316 |
-
}
|
317 |
-
|
318 |
-
/* Gallery */
|
319 |
-
.gr-gallery {
|
320 |
-
background: transparent !important;
|
321 |
-
gap: 12px !important;
|
322 |
-
}
|
323 |
-
|
324 |
-
.gr-gallery-item {
|
325 |
-
border-radius: var(--apple-radius-sm) !important;
|
326 |
-
overflow: hidden !important;
|
327 |
-
box-shadow: var(--apple-shadow-sm) !important;
|
328 |
-
border: 1px solid var(--apple-gray-3) !important;
|
329 |
-
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
330 |
-
}
|
331 |
-
|
332 |
-
.gr-gallery-item:hover {
|
333 |
-
transform: scale(1.02) !important;
|
334 |
-
box-shadow: var(--apple-shadow-md) !important;
|
335 |
-
}
|
336 |
-
|
337 |
-
/* Progress bar */
|
338 |
-
.progress-bar {
|
339 |
-
background: var(--apple-gray-3) !important;
|
340 |
-
border-radius: 100px !important;
|
341 |
-
overflow: hidden !important;
|
342 |
-
height: 4px !important;
|
343 |
-
}
|
344 |
-
|
345 |
-
.progress-bar-fill {
|
346 |
-
background: var(--apple-blue) !important;
|
347 |
-
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
348 |
-
}
|
349 |
-
|
350 |
-
/* Labels */
|
351 |
-
label {
|
352 |
-
color: var(--apple-gray-5) !important;
|
353 |
-
font-size: 13px !important;
|
354 |
-
font-weight: 500 !important;
|
355 |
-
letter-spacing: -0.01em !important;
|
356 |
-
margin-bottom: 6px !important;
|
357 |
-
}
|
358 |
-
|
359 |
-
/* Inputs and form elements */
|
360 |
-
.gr-input, .gr-textbox, .gr-dropdown {
|
361 |
-
background: var(--apple-bg) !important;
|
362 |
-
border: 1px solid var(--apple-gray-4) !important;
|
363 |
-
border-radius: var(--apple-radius-sm) !important;
|
364 |
-
padding: 10px 12px !important;
|
365 |
-
font-size: 15px !important;
|
366 |
-
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
367 |
-
}
|
368 |
-
|
369 |
-
.gr-input:focus, .gr-textbox:focus, .gr-dropdown:focus {
|
370 |
-
border-color: var(--apple-blue) !important;
|
371 |
-
box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1) !important;
|
372 |
-
outline: none !important;
|
373 |
-
}
|
374 |
-
|
375 |
-
/* Markdown content */
|
376 |
-
.gr-markdown {
|
377 |
-
color: var(--apple-text) !important;
|
378 |
-
line-height: 1.6 !important;
|
379 |
-
}
|
380 |
-
|
381 |
-
.gr-markdown h2 {
|
382 |
-
font-size: 20px !important;
|
383 |
-
font-weight: 600 !important;
|
384 |
-
margin-bottom: 12px !important;
|
385 |
-
color: var(--apple-text) !important;
|
386 |
-
}
|
387 |
-
|
388 |
-
/* Loading states */
|
389 |
-
.gr-loading {
|
390 |
-
color: var(--apple-gray-5) !important;
|
391 |
-
}
|
392 |
-
|
393 |
-
/* Scrollbars */
|
394 |
-
::-webkit-scrollbar {
|
395 |
-
width: 8px;
|
396 |
-
height: 8px;
|
397 |
-
}
|
398 |
-
|
399 |
-
::-webkit-scrollbar-track {
|
400 |
-
background: var(--apple-gray-2);
|
401 |
-
border-radius: 10px;
|
402 |
-
}
|
403 |
-
|
404 |
-
::-webkit-scrollbar-thumb {
|
405 |
-
background: var(--apple-gray-4);
|
406 |
-
border-radius: 10px;
|
407 |
-
}
|
408 |
-
|
409 |
-
::-webkit-scrollbar-thumb:hover {
|
410 |
-
background: var(--apple-gray-5);
|
411 |
-
}
|
412 |
-
|
413 |
-
/* Animations */
|
414 |
-
@keyframes fadeIn {
|
415 |
-
from {
|
416 |
-
opacity: 0;
|
417 |
-
transform: translateY(10px);
|
418 |
-
}
|
419 |
-
to {
|
420 |
-
opacity: 1;
|
421 |
-
transform: translateY(0);
|
422 |
-
}
|
423 |
-
}
|
424 |
-
|
425 |
-
.message {
|
426 |
-
animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
427 |
-
}
|
428 |
-
|
429 |
-
/* Responsive adjustments */
|
430 |
-
@media (max-width: 768px) {
|
431 |
-
h1 {
|
432 |
-
font-size: 36px;
|
433 |
-
}
|
434 |
-
|
435 |
-
.contain {
|
436 |
-
padding: 16px;
|
437 |
-
}
|
438 |
-
|
439 |
-
.message {
|
440 |
-
max-width: 90% !important;
|
441 |
-
}
|
442 |
-
}
|
443 |
-
""") as demo:
|
444 |
gr.Markdown("# 🎬 FastVLM Video Captioning")
|
445 |
|
446 |
with gr.Row():
|
|
|
157 |
return video_summary, frame_previews
|
158 |
|
159 |
# Create the Gradio interface
|
160 |
+
# Create custom Apple-inspired theme
|
161 |
+
class AppleTheme(gr.themes.Base):
|
162 |
+
def __init__(self):
|
163 |
+
super().__init__(
|
164 |
+
primary_hue=gr.themes.colors.blue,
|
165 |
+
secondary_hue=gr.themes.colors.gray,
|
166 |
+
neutral_hue=gr.themes.colors.gray,
|
167 |
+
spacing_size=gr.themes.sizes.spacing_md,
|
168 |
+
radius_size=gr.themes.sizes.radius_md,
|
169 |
+
text_size=gr.themes.sizes.text_md,
|
170 |
+
font=[
|
171 |
+
gr.themes.GoogleFont("Inter"),
|
172 |
+
"-apple-system",
|
173 |
+
"BlinkMacSystemFont",
|
174 |
+
"SF Pro Display",
|
175 |
+
"SF Pro Text",
|
176 |
+
"Helvetica Neue",
|
177 |
+
"Helvetica",
|
178 |
+
"Arial",
|
179 |
+
"sans-serif"
|
180 |
+
],
|
181 |
+
font_mono=[
|
182 |
+
gr.themes.GoogleFont("SF Mono"),
|
183 |
+
"ui-monospace",
|
184 |
+
"Consolas",
|
185 |
+
"monospace"
|
186 |
+
]
|
187 |
+
)
|
188 |
+
super().set(
|
189 |
+
# Core colors
|
190 |
+
body_background_fill="*neutral_50",
|
191 |
+
body_background_fill_dark="*neutral_950",
|
192 |
+
button_primary_background_fill="*primary_500",
|
193 |
+
button_primary_background_fill_hover="*primary_600",
|
194 |
+
button_primary_text_color="white",
|
195 |
+
button_primary_border_color="*primary_500",
|
196 |
+
|
197 |
+
# Shadows
|
198 |
+
button_shadow="0 2px 8px rgba(0, 0, 0, 0.04)",
|
199 |
+
button_shadow_hover="0 4px 12px rgba(0, 0, 0, 0.08)",
|
200 |
+
block_shadow="0 4px 12px rgba(0, 0, 0, 0.08)",
|
201 |
+
|
202 |
+
# Border radius
|
203 |
+
button_large_radius="8px",
|
204 |
+
button_small_radius="6px",
|
205 |
+
block_radius="12px",
|
206 |
+
container_radius="12px",
|
207 |
+
|
208 |
+
# Borders
|
209 |
+
block_border_width="1px",
|
210 |
+
block_border_color="*neutral_200",
|
211 |
+
input_border_width="1px",
|
212 |
+
input_border_color="*neutral_300",
|
213 |
+
input_border_color_focus="*primary_500",
|
214 |
+
|
215 |
+
# Text
|
216 |
+
block_title_text_weight="600",
|
217 |
+
block_label_text_weight="500",
|
218 |
+
block_label_text_size="13px",
|
219 |
+
block_label_text_color="*neutral_600",
|
220 |
+
body_text_color="*neutral_900",
|
221 |
+
|
222 |
+
# Spacing
|
223 |
+
layout_gap="16px",
|
224 |
+
block_padding="20px",
|
225 |
+
|
226 |
+
# Specific components
|
227 |
+
chatbot_code_background_color="*neutral_100",
|
228 |
+
slider_color="*primary_500",
|
229 |
+
|
230 |
+
# Transitions
|
231 |
+
button_transition="all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",
|
232 |
+
)
|
233 |
+
|
234 |
+
# Create the Gradio interface with the custom theme
|
235 |
+
with gr.Blocks(theme=AppleTheme()) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
gr.Markdown("# 🎬 FastVLM Video Captioning")
|
237 |
|
238 |
with gr.Row():
|