Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -258,58 +258,32 @@ video_examples = [["Explain the video in detail.", "videos/2.mp4"]]
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
| 261 |
-
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;900&display=swap');
|
| 262 |
-
|
| 263 |
:root {
|
| 264 |
-
--
|
| 265 |
-
--
|
| 266 |
-
--
|
| 267 |
-
--
|
| 268 |
-
--
|
| 269 |
-
--
|
| 270 |
-
--
|
| 271 |
-
--
|
| 272 |
-
--
|
| 273 |
-
--
|
| 274 |
-
--bg-button-secondary-hover: #f97316;
|
| 275 |
-
--color-border: #000000;
|
| 276 |
-
--color-text: #000000;
|
| 277 |
-
--color-text-button: #000000;
|
| 278 |
-
--color-text-header: #000000;
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
.dark {
|
| 282 |
-
--bg-main: #2c132c;
|
| 283 |
-
--bg-card: #592659;
|
| 284 |
-
--bg-header: #1a1a1a;
|
| 285 |
-
--bg-result: #2a2a2a;
|
| 286 |
-
--bg-tab-active: #7f397f;
|
| 287 |
-
--bg-advanced: rgba(0, 0, 0, 0.3);
|
| 288 |
-
--bg-uploader: rgba(0, 0, 0, 0.4);
|
| 289 |
-
--color-text: #f0f0f0;
|
| 290 |
-
--color-text-header: #f0f0f0;
|
| 291 |
}
|
| 292 |
|
| 293 |
body, .gradio-container {
|
| 294 |
-
font-family:
|
| 295 |
-
background-color:
|
| 296 |
-
color: var(--
|
| 297 |
-
transition: background-color 0.3s ease;
|
| 298 |
}
|
| 299 |
|
| 300 |
/* Header Styles */
|
| 301 |
-
#app-header {
|
| 302 |
-
background: var(--bg-header);
|
| 303 |
-
padding: 2rem;
|
| 304 |
-
border-bottom: 3px solid var(--color-border);
|
| 305 |
-
color: var(--color-text-header);
|
| 306 |
-
transition: background-color 0.3s ease, color 0.3s ease;
|
| 307 |
-
}
|
| 308 |
#app-header h1 {
|
| 309 |
font-size: 2.5rem;
|
| 310 |
-
font-weight:
|
| 311 |
-
|
| 312 |
text-align: center;
|
|
|
|
| 313 |
}
|
| 314 |
|
| 315 |
/* Main Layout Styles */
|
|
@@ -319,141 +293,137 @@ body, .gradio-container {
|
|
| 319 |
box-shadow: none !important;
|
| 320 |
}
|
| 321 |
#main-row {
|
|
|
|
| 322 |
gap: 4rem;
|
| 323 |
padding: 2rem;
|
| 324 |
}
|
| 325 |
|
| 326 |
/* Card Styles */
|
| 327 |
-
.card {
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
border:
|
| 332 |
-
box-shadow:
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
.
|
| 337 |
-
|
| 338 |
-
box-shadow: 9px 9px 0 var(--color-border);
|
| 339 |
}
|
| 340 |
-
|
| 341 |
-
.
|
| 342 |
-
|
| 343 |
-
font-weight: 900;
|
| 344 |
-
width: 100%;
|
| 345 |
-
background: var(--bg-header);
|
| 346 |
-
padding: 8px 12px;
|
| 347 |
-
color: var(--color-text-header);
|
| 348 |
-
border-bottom: 3px solid var(--color-border);
|
| 349 |
}
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
}
|
| 356 |
|
| 357 |
/* Button Styles */
|
| 358 |
.gr-button {
|
| 359 |
-
|
| 360 |
-
border:
|
| 361 |
-
|
| 362 |
-
font-weight: 900 !important;
|
| 363 |
-
transition: all 0.15s ease !important;
|
| 364 |
cursor: pointer !important;
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
}
|
| 370 |
-
.gr-button
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
box-shadow: 2px 2px 0 var(--color-border) !important;
|
| 376 |
}
|
| 377 |
-
.gr-button.submit-btn
|
| 378 |
-
background: var(--
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
-
.gr-button:active {
|
| 381 |
-
|
| 382 |
-
|
|
|
|
| 383 |
}
|
| 384 |
|
| 385 |
/* Form & Input Styles */
|
| 386 |
-
.gr-input, .gr-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
font-size: 14px !important;
|
| 393 |
-
box-sizing: border-box !important;
|
| 394 |
-
border-radius: 0 !important;
|
| 395 |
}
|
| 396 |
-
textarea, input[type=text]
|
| 397 |
-
|
| 398 |
-
|
|
|
|
|
|
|
| 399 |
}
|
| 400 |
.gr-label > .label-text {
|
| 401 |
-
font-
|
| 402 |
-
|
|
|
|
| 403 |
margin-bottom: 0.5rem !important;
|
| 404 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
/* Tabs Styles */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
.tab-nav > button {
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
font-weight:
|
| 411 |
-
background: var(--
|
| 412 |
-
color: var(--
|
| 413 |
-
|
| 414 |
-
border-right: 3px solid var(--color-border) !important;
|
| 415 |
-
border-top: none !important;
|
| 416 |
-
border-left: none !important;
|
| 417 |
-
transition: background-color 0.3s ease !important;
|
| 418 |
-
border-radius: 0 !important;
|
| 419 |
}
|
| 420 |
.tab-nav > button.selected {
|
| 421 |
-
background: var(--
|
| 422 |
-
color:
|
|
|
|
|
|
|
| 423 |
}
|
| 424 |
|
| 425 |
/* Advanced Options Accordion */
|
| 426 |
.gr-accordion {
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
border-radius: 0 !important;
|
| 432 |
}
|
| 433 |
.gr-accordion > .label-wrap {
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
}
|
| 437 |
-
|
| 438 |
-
/* Slider Styles */
|
| 439 |
-
.gr-slider {
|
| 440 |
-
background: var(--bg-uploader) !important;
|
| 441 |
-
border: 3px solid var(--color-border) !important;
|
| 442 |
-
}
|
| 443 |
-
.gr-slider input[type=range]::-webkit-slider-thumb {
|
| 444 |
-
background: var(--bg-button-secondary) !important;
|
| 445 |
-
border: 3px solid var(--color-border) !important;
|
| 446 |
-
}
|
| 447 |
-
.gr-slider input[type=range]::-moz-range-thumb {
|
| 448 |
-
background: var(--bg-button-secondary) !important;
|
| 449 |
-
border: 3px solid var(--color-border) !important;
|
| 450 |
}
|
| 451 |
-
|
| 452 |
-
/* PDF Viewer Styles */
|
| 453 |
.page-info {
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
|
|
|
| 457 |
}
|
| 458 |
"""
|
| 459 |
|
|
@@ -464,49 +434,43 @@ with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
|
| 464 |
gr.Markdown("# Qwen3-VL-Processor")
|
| 465 |
|
| 466 |
with gr.Row(elem_id="main-row"):
|
| 467 |
-
with gr.Column(scale=2):
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
with gr.Group(elem_classes="card-header"):
|
| 505 |
-
gr.Markdown("### RESULT")
|
| 506 |
-
with gr.Group(elem_classes="card-content"):
|
| 507 |
-
output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=15, show_copy_button=True)
|
| 508 |
-
with gr.Accordion("(Result.md)", open=False):
|
| 509 |
-
markdown_output = gr.Markdown(label="(Result.Md)")
|
| 510 |
|
| 511 |
# Event handlers
|
| 512 |
image_submit.click(
|
|
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
|
|
|
|
|
|
| 261 |
:root {
|
| 262 |
+
--ui-blue: #5c99e2;
|
| 263 |
+
--ui-blue-shadow: #3b76c0;
|
| 264 |
+
--ui-green: #61c470;
|
| 265 |
+
--ui-green-shadow: #45a253;
|
| 266 |
+
--ui-red: #e65e5e;
|
| 267 |
+
--ui-red-shadow: #c14242;
|
| 268 |
+
--ui-cream: #f5f1e8;
|
| 269 |
+
--ui-cream-shadow: #c7c1b5;
|
| 270 |
+
--ui-dark: #4d4c4a;
|
| 271 |
+
--button-press-depth: 0.15em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
}
|
| 273 |
|
| 274 |
body, .gradio-container {
|
| 275 |
+
font-family: "Arial Rounded MT Bold", "Helvetica Rounded", Arial, sans-serif;
|
| 276 |
+
background-color: #f0e4d4;
|
| 277 |
+
color: var(--ui-dark);
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
/* Header Styles */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
#app-header h1 {
|
| 282 |
font-size: 2.5rem;
|
| 283 |
+
font-weight: 700;
|
| 284 |
+
color: var(--ui-dark);
|
| 285 |
text-align: center;
|
| 286 |
+
padding: 1.5rem 0;
|
| 287 |
}
|
| 288 |
|
| 289 |
/* Main Layout Styles */
|
|
|
|
| 293 |
box-shadow: none !important;
|
| 294 |
}
|
| 295 |
#main-row {
|
| 296 |
+
justify-content: center;
|
| 297 |
gap: 4rem;
|
| 298 |
padding: 2rem;
|
| 299 |
}
|
| 300 |
|
| 301 |
/* Card Styles */
|
| 302 |
+
.pixar-card {
|
| 303 |
+
background-color: var(--ui-cream);
|
| 304 |
+
border-radius: 1.5em;
|
| 305 |
+
padding: 1.2em;
|
| 306 |
+
border: 0.2em solid var(--ui-dark);
|
| 307 |
+
box-shadow: 0.6em 0.6em 0 var(--ui-dark);
|
| 308 |
+
display: flex;
|
| 309 |
+
flex-direction: column;
|
| 310 |
+
transition:
|
| 311 |
+
transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
|
| 312 |
+
box-shadow 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
|
|
| 313 |
}
|
| 314 |
+
.pixar-card:hover {
|
| 315 |
+
transform: translateY(-0.5em) rotate(-1deg);
|
| 316 |
+
box-shadow: 0.8em 0.8em 0 var(--ui-dark);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
}
|
| 318 |
+
#input-card { min-width: 400px; max-width: 500px; }
|
| 319 |
+
#output-card { min-width: 400px; max-width: 600px; }
|
| 320 |
+
|
| 321 |
+
.card-title {
|
| 322 |
+
font-size: 1.5em;
|
| 323 |
+
font-weight: 700;
|
| 324 |
+
color: var(--ui-dark);
|
| 325 |
+
margin-bottom: 1em;
|
| 326 |
+
text-align: center;
|
| 327 |
}
|
| 328 |
|
| 329 |
/* Button Styles */
|
| 330 |
.gr-button {
|
| 331 |
+
border: 0.2em solid var(--ui-dark) !important;
|
| 332 |
+
border-radius: 1em !important;
|
| 333 |
+
padding: 0.5em !important;
|
|
|
|
|
|
|
| 334 |
cursor: pointer !important;
|
| 335 |
+
box-shadow:
|
| 336 |
+
0 var(--button-press-depth) 0 var(--ui-blue-shadow),
|
| 337 |
+
0 0.4em 0 var(--ui-dark) !important;
|
| 338 |
+
transition:
|
| 339 |
+
transform 0.1s ease,
|
| 340 |
+
box-shadow 0.1s ease !important;
|
| 341 |
+
font-family: inherit !important;
|
| 342 |
+
font-weight: 700 !important;
|
| 343 |
+
font-size: 1.1em !important;
|
| 344 |
+
color: var(--ui-dark) !important;
|
| 345 |
+
background: var(--ui-blue) !important;
|
| 346 |
}
|
| 347 |
+
.gr-button:active {
|
| 348 |
+
transform: translateY(var(--button-press-depth));
|
| 349 |
+
box-shadow:
|
| 350 |
+
0 0 0 var(--ui-blue-shadow),
|
| 351 |
+
0 var(--button-press-depth) 0 var(--ui-dark) !important;
|
|
|
|
| 352 |
}
|
| 353 |
+
.gr-button.submit-btn {
|
| 354 |
+
background: var(--ui-green) !important;
|
| 355 |
+
box-shadow:
|
| 356 |
+
0 var(--button-press-depth) 0 var(--ui-green-shadow),
|
| 357 |
+
0 0.4em 0 var(--ui-dark) !important;
|
| 358 |
}
|
| 359 |
+
.gr-button.submit-btn:active {
|
| 360 |
+
box-shadow:
|
| 361 |
+
0 0 0 var(--ui-green-shadow),
|
| 362 |
+
0 var(--button-press-depth) 0 var(--ui-dark) !important;
|
| 363 |
}
|
| 364 |
|
| 365 |
/* Form & Input Styles */
|
| 366 |
+
.gr-input, .gr-textbox, .gr-file {
|
| 367 |
+
background-color: #d8d2c6 !important;
|
| 368 |
+
border-radius: 1em !important;
|
| 369 |
+
padding: 0.8em !important;
|
| 370 |
+
border: 0.2em solid var(--ui-dark) !important;
|
| 371 |
+
box-shadow: inset 0.2em 0.2em 0 #b3ac9f !important;
|
|
|
|
|
|
|
|
|
|
| 372 |
}
|
| 373 |
+
textarea, input[type=text] {
|
| 374 |
+
background: transparent !important;
|
| 375 |
+
color: var(--ui-dark) !important;
|
| 376 |
+
font-family: inherit !important;
|
| 377 |
+
font-weight: 600 !important;
|
| 378 |
}
|
| 379 |
.gr-label > .label-text {
|
| 380 |
+
font-size: 1.1em !important;
|
| 381 |
+
font-weight: 700 !important;
|
| 382 |
+
color: var(--ui-dark) !important;
|
| 383 |
margin-bottom: 0.5rem !important;
|
| 384 |
}
|
| 385 |
+
.gr-image, .gr-video {
|
| 386 |
+
border-radius: 0.6em !important;
|
| 387 |
+
border: 0.2em solid var(--ui-dark) !important;
|
| 388 |
+
}
|
| 389 |
|
| 390 |
/* Tabs Styles */
|
| 391 |
+
.tab-nav {
|
| 392 |
+
justify-content: center;
|
| 393 |
+
gap: 0.5rem;
|
| 394 |
+
margin-bottom: 1rem;
|
| 395 |
+
}
|
| 396 |
.tab-nav > button {
|
| 397 |
+
border: 0.2em solid var(--ui-dark) !important;
|
| 398 |
+
border-radius: 1em !important;
|
| 399 |
+
font-weight: 700 !important;
|
| 400 |
+
background: var(--ui-cream-shadow) !important;
|
| 401 |
+
color: var(--ui-dark) !important;
|
| 402 |
+
transition: all 0.2s ease !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
}
|
| 404 |
.tab-nav > button.selected {
|
| 405 |
+
background: var(--ui-blue) !important;
|
| 406 |
+
color: var(--ui-cream) !important;
|
| 407 |
+
box-shadow: 0.2em 0.2em 0 var(--ui-dark);
|
| 408 |
+
transform: translateY(-0.1em);
|
| 409 |
}
|
| 410 |
|
| 411 |
/* Advanced Options Accordion */
|
| 412 |
.gr-accordion {
|
| 413 |
+
border: 0.2em solid var(--ui-dark) !important;
|
| 414 |
+
border-radius: 1em !important;
|
| 415 |
+
background: #d8d2c6 !important;
|
| 416 |
+
box-shadow: inset 0.2em 0.2em 0 #b3ac9f !important;
|
|
|
|
| 417 |
}
|
| 418 |
.gr-accordion > .label-wrap {
|
| 419 |
+
color: var(--ui-dark) !important;
|
| 420 |
+
font-weight: 700 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
}
|
|
|
|
|
|
|
| 422 |
.page-info {
|
| 423 |
+
text-align: center;
|
| 424 |
+
font-weight: 700;
|
| 425 |
+
font-size: 1.1em;
|
| 426 |
+
margin-top: 1rem;
|
| 427 |
}
|
| 428 |
"""
|
| 429 |
|
|
|
|
| 434 |
gr.Markdown("# Qwen3-VL-Processor")
|
| 435 |
|
| 436 |
with gr.Row(elem_id="main-row"):
|
| 437 |
+
with gr.Column(scale=2, elem_id="input-card", elem_classes="pixar-card"):
|
| 438 |
+
gr.Markdown("### INPUT", elem_classes="card-title")
|
| 439 |
+
with gr.Tabs():
|
| 440 |
+
with gr.TabItem("Image"):
|
| 441 |
+
image_query = gr.Textbox(label="Query", placeholder="What do you see?...")
|
| 442 |
+
image_upload = gr.Image(type="pil", label="Image Input", height=290)
|
| 443 |
+
image_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 444 |
+
gr.Examples(examples=image_examples, inputs=[image_query, image_upload])
|
| 445 |
+
|
| 446 |
+
with gr.TabItem("Video"):
|
| 447 |
+
video_query = gr.Textbox(label="Query", placeholder="Explain this video...")
|
| 448 |
+
video_upload = gr.Video(label="Video Input", height=290)
|
| 449 |
+
video_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 450 |
+
gr.Examples(examples=video_examples, inputs=[video_query, video_upload])
|
| 451 |
+
|
| 452 |
+
with gr.TabItem("PDF"):
|
| 453 |
+
pdf_query = gr.Textbox(label="Query", placeholder="Summarize this document...")
|
| 454 |
+
pdf_upload = gr.File(label="Upload PDF", file_types=[".pdf"])
|
| 455 |
+
pdf_preview_img = gr.Image(label="PDF Preview", height=280)
|
| 456 |
+
with gr.Row():
|
| 457 |
+
prev_page_btn = gr.Button("◀ Prev")
|
| 458 |
+
next_page_btn = gr.Button("Next ▶")
|
| 459 |
+
page_info = gr.HTML('<div class="page-info">No file loaded</div>')
|
| 460 |
+
pdf_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 461 |
+
|
| 462 |
+
with gr.Accordion("Advanced Options", open=False):
|
| 463 |
+
max_new_tokens = gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
|
| 464 |
+
temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6)
|
| 465 |
+
top_p = gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
| 466 |
+
top_k = gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50)
|
| 467 |
+
repetition_penalty = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2)
|
| 468 |
+
|
| 469 |
+
with gr.Column(scale=3, elem_id="output-card", elem_classes="pixar-card"):
|
| 470 |
+
gr.Markdown("### RESULT", elem_classes="card-title")
|
| 471 |
+
output = gr.Textbox(label="Raw Output", interactive=False, lines=15)
|
| 472 |
+
with gr.Accordion("Formatted Markdown", open=True):
|
| 473 |
+
markdown_output = gr.Markdown(label="Formatted Output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 474 |
|
| 475 |
# Event handlers
|
| 476 |
image_submit.click(
|