Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,6 @@ from docling_core.types.doc import DoclingDocument, DocTagsDocument
|
|
| 27 |
import re
|
| 28 |
import ast
|
| 29 |
import html
|
| 30 |
-
import urllib.parse
|
| 31 |
|
| 32 |
# Constants for text generation
|
| 33 |
MAX_MAX_NEW_TOKENS = 2048
|
|
@@ -226,7 +225,7 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 226 |
yield "Invalid model selected.", "Invalid model selected."
|
| 227 |
return
|
| 228 |
|
| 229 |
-
if video_path is None:
|
| 230 |
yield "Please upload a video.", "Please upload a video."
|
| 231 |
return
|
| 232 |
|
|
@@ -298,84 +297,99 @@ video_examples = [
|
|
| 298 |
["Explain the video in detail.", "videos/2.mp4"]
|
| 299 |
]
|
| 300 |
|
| 301 |
-
#
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
# Updated CSS with fancy-button styles
|
| 310 |
-
css = f"""
|
| 311 |
-
.fancy-button {{
|
| 312 |
-
--round: 0.75rem;
|
| 313 |
cursor: pointer;
|
| 314 |
position: relative;
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
}
|
| 346 |
-
|
| 347 |
-
.
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
position: absolute;
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
"""
|
| 380 |
|
| 381 |
# Create the Gradio Interface
|
|
@@ -387,7 +401,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 387 |
with gr.TabItem("Image Inference"):
|
| 388 |
image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
|
| 389 |
image_upload = gr.Image(type="pil", label="Image")
|
| 390 |
-
|
| 391 |
gr.Examples(
|
| 392 |
examples=image_examples,
|
| 393 |
inputs=[image_query, image_upload]
|
|
@@ -395,7 +409,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 395 |
with gr.TabItem("Video Inference"):
|
| 396 |
video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
|
| 397 |
video_upload = gr.Video(label="Video")
|
| 398 |
-
video_submit = gr.Button("Submit", elem_classes="
|
| 399 |
gr.Examples(
|
| 400 |
examples=video_examples,
|
| 401 |
inputs=[video_query, video_upload]
|
|
@@ -411,7 +425,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 411 |
with gr.Column(elem_classes="canvas-output"):
|
| 412 |
gr.Markdown("## Output")
|
| 413 |
raw_output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=2)
|
| 414 |
-
|
| 415 |
with gr.Accordion("(Result.md)", open=False):
|
| 416 |
formatted_output = gr.Markdown(label="(Result.md)")
|
| 417 |
|
|
|
|
| 27 |
import re
|
| 28 |
import ast
|
| 29 |
import html
|
|
|
|
| 30 |
|
| 31 |
# Constants for text generation
|
| 32 |
MAX_MAX_NEW_TOKENS = 2048
|
|
|
|
| 225 |
yield "Invalid model selected.", "Invalid model selected."
|
| 226 |
return
|
| 227 |
|
| 228 |
+
Nm if video_path is None:
|
| 229 |
yield "Please upload a video.", "Please upload a video."
|
| 230 |
return
|
| 231 |
|
|
|
|
| 297 |
["Explain the video in detail.", "videos/2.mp4"]
|
| 298 |
]
|
| 299 |
|
| 300 |
+
# Updated CSS with the new Submit button theme
|
| 301 |
+
css = """
|
| 302 |
+
.submit-btn {
|
| 303 |
+
--stone-50: #fafaf9;
|
| 304 |
+
--stone-800: #292524;
|
| 305 |
+
--yellow-400: #facc15;
|
| 306 |
+
|
| 307 |
+
font-size: 1rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
cursor: pointer;
|
| 309 |
position: relative;
|
| 310 |
+
font-family: "Rubik", sans-serif;
|
| 311 |
+
font-weight: bold;
|
| 312 |
+
line-height: 1;
|
| 313 |
+
padding: 0.75rem 1.25rem;
|
| 314 |
+
transform: translate(-4px, -4px);
|
| 315 |
+
outline: 2px solid transparent;
|
| 316 |
+
outline-offset: 5px;
|
| 317 |
+
border-radius: 9999px;
|
| 318 |
+
background-color: var(--yellow-400);
|
| 319 |
+
color: var(--stone-800);
|
| 320 |
+
transition:
|
| 321 |
+
transform 150ms ease,
|
| 322 |
+
box-shadow 150ms ease;
|
| 323 |
+
text-align: center;
|
| 324 |
+
box-shadow:
|
| 325 |
+
0.5px 0.5px 0 0 var(--stone-800),
|
| 326 |
+
1px 1px 0 0 var(--stone-800),
|
| 327 |
+
1.5px 1.5px 0 0 var(--stone-800),
|
| 328 |
+
2px 2px 0 0 var(--stone-800),
|
| 329 |
+
2.5px 2.5px 0 0 var(--stone-800),
|
| 330 |
+
3px 3px 0 0 var(--stone-800),
|
| 331 |
+
0 0 0 2px var(--stone-50),
|
| 332 |
+
0.5px 0.5px 0 2px var(--stone-50),
|
| 333 |
+
1px 1px 0 2px var(--stone-50),
|
| 334 |
+
1.5px 1.5px 0 2px var(--stone-50),
|
| 335 |
+
2px 2px 0 2px var(--stone-50),
|
| 336 |
+
2.5px 2.5px 0 2px var(--stone-50),
|
| 337 |
+
3px 3px 0 2px var(--stone-50),
|
| 338 |
+
3.5px 3.5px 0 2px var(--stone-50),
|
| 339 |
+
4px 4px 0 2px var(--stone-50);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
.submit-btn:hover {
|
| 343 |
+
transform: translate(0, 0);
|
| 344 |
+
box-shadow: 0 0 0 2px var(--stone-50);
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
.submit-btn:active {
|
| 348 |
+
transform: translate(0, 2px);
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
.submit-btn:focus-visible {
|
| 352 |
+
outline-color: var(--yellow-400);
|
| 353 |
+
outline-style: dashed;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
.submit-btn::before {
|
| 357 |
+
content: "";
|
| 358 |
position: absolute;
|
| 359 |
+
inset: 0;
|
| 360 |
+
border-radius: 9999px;
|
| 361 |
+
opacity: 0.5;
|
| 362 |
+
background-image: radial-gradient(
|
| 363 |
+
rgb(255 255 255 / 80%) 20%,
|
| 364 |
+
transparent 20%
|
| 365 |
+
),
|
| 366 |
+
radial-gradient(rgb(255 255 255 / 100%) 20%, transparent 20%);
|
| 367 |
+
background-position:
|
| 368 |
+
0 0,
|
| 369 |
+
4px 4px;
|
| 370 |
+
background-size: 8px 8px;
|
| 371 |
+
mix-blend-mode: hard-light;
|
| 372 |
+
animation: dots 0.5s infinite linear;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
@keyframes dots {
|
| 376 |
+
0% {
|
| 377 |
+
background-position:
|
| 378 |
+
0 0,
|
| 379 |
+
4px 4px;
|
| 380 |
+
}
|
| 381 |
+
100% {
|
| 382 |
+
background-position:
|
| 383 |
+
8px 0,
|
| 384 |
+
12px 4px;
|
| 385 |
+
}
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
.canvas-output {
|
| 389 |
+
border: 2px solid #4682B4;
|
| 390 |
+
border-radius: 10px;
|
| 391 |
+
padding: 20px;
|
| 392 |
+
}
|
| 393 |
"""
|
| 394 |
|
| 395 |
# Create the Gradio Interface
|
|
|
|
| 401 |
with gr.TabItem("Image Inference"):
|
| 402 |
image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
|
| 403 |
image_upload = gr.Image(type="pil", label="Image")
|
| 404 |
+
image Timage_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 405 |
gr.Examples(
|
| 406 |
examples=image_examples,
|
| 407 |
inputs=[image_query, image_upload]
|
|
|
|
| 409 |
with gr.TabItem("Video Inference"):
|
| 410 |
video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
|
| 411 |
video_upload = gr.Video(label="Video")
|
| 412 |
+
video_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 413 |
gr.Examples(
|
| 414 |
examples=video_examples,
|
| 415 |
inputs=[video_query, video_upload]
|
|
|
|
| 425 |
with gr.Column(elem_classes="canvas-output"):
|
| 426 |
gr.Markdown("## Output")
|
| 427 |
raw_output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=2)
|
|
|
|
| 428 |
with gr.Accordion("(Result.md)", open=False):
|
| 429 |
formatted_output = gr.Markdown(label="(Result.md)")
|
| 430 |
|