Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -258,12 +258,148 @@ video_examples = [["Explain the video in detail.", "videos/2.mp4"]]
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
| 261 |
-
.
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
"""
|
| 265 |
|
| 266 |
-
with gr.Blocks(css=css
|
| 267 |
pdf_state = gr.State(value=get_initial_pdf_state())
|
| 268 |
gr.Markdown("# **Qwen3-VL-Processor**")
|
| 269 |
with gr.Row():
|
|
@@ -286,10 +422,9 @@ with gr.Blocks(css=css, theme="Respair/Shiki@9.1.0") as demo:
|
|
| 286 |
with gr.Column(scale=1):
|
| 287 |
pdf_query = gr.Textbox(label="Query Input", placeholder="e.g., 'Summarize this document'")
|
| 288 |
pdf_upload = gr.File(label="Upload PDF", file_types=[".pdf"])
|
| 289 |
-
#gr.Examples(examples=pdf_examples, inputs=[pdf_upload])
|
| 290 |
pdf_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 291 |
with gr.Column(scale=1):
|
| 292 |
-
pdf_preview_img = gr.Image(label="PDF Preview", height=
|
| 293 |
with gr.Row():
|
| 294 |
prev_page_btn = gr.Button("◀ Previous")
|
| 295 |
page_info = gr.HTML('<div style="text-align:center;">No file loaded</div>')
|
|
@@ -305,7 +440,7 @@ with gr.Blocks(css=css, theme="Respair/Shiki@9.1.0") as demo:
|
|
| 305 |
with gr.Column(scale=3):
|
| 306 |
with gr.Column(elem_classes="canvas-output"):
|
| 307 |
gr.Markdown("## Output")
|
| 308 |
-
output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=
|
| 309 |
with gr.Accordion("(Result.md)", open=False):
|
| 310 |
markdown_output = gr.Markdown(label="(Result.Md)")
|
| 311 |
|
|
@@ -342,4 +477,4 @@ with gr.Blocks(css=css, theme="Respair/Shiki@9.1.0") as demo:
|
|
| 342 |
)
|
| 343 |
|
| 344 |
if __name__ == "__main__":
|
| 345 |
-
demo.queue(max_size=50).launch(
|
|
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
| 261 |
+
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;900&display=swap');
|
| 262 |
+
|
| 263 |
+
:root {
|
| 264 |
+
--bg-main: #ffd6e7;
|
| 265 |
+
--bg-card: #ff66a3;
|
| 266 |
+
--bg-header: #ffffff;
|
| 267 |
+
--bg-button-primary: #4ade80;
|
| 268 |
+
--bg-button-primary-hover: #1ac2ff;
|
| 269 |
+
--bg-button-secondary: #fde047;
|
| 270 |
+
--bg-button-secondary-hover: #f97316;
|
| 271 |
+
--color-border: #000000;
|
| 272 |
+
--color-text: #000000;
|
| 273 |
+
--shadow-card: 12px 12px 0 var(--color-border);
|
| 274 |
+
--shadow-button: 4px 4px 0 var(--color-border);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
body, .gradio-container {
|
| 278 |
+
font-family: 'Montserrat', sans-serif;
|
| 279 |
+
background-color: var(--bg-main);
|
| 280 |
+
color: var(--color-text);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
h1 {
|
| 284 |
+
font-size: 2.5rem !important;
|
| 285 |
+
font-weight: 900 !important;
|
| 286 |
+
text-align: center;
|
| 287 |
+
margin-bottom: 2rem !important;
|
| 288 |
+
color: var(--color-text);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
.gradio-container .gr-panel {
|
| 292 |
+
background-color: transparent !important;
|
| 293 |
+
border: none !important;
|
| 294 |
+
box-shadow: none !important;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.gr-tabs {
|
| 298 |
+
translate: -6px -6px;
|
| 299 |
+
background: var(--bg-card);
|
| 300 |
+
border: 3px solid var(--color-border);
|
| 301 |
+
box-shadow: var(--shadow-card);
|
| 302 |
+
transition: all 0.2s ease;
|
| 303 |
+
}
|
| 304 |
+
.gr-tabs:hover {
|
| 305 |
+
translate: -3px -3px;
|
| 306 |
+
box-shadow: 9px 9px 0 var(--color-border);
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
.gr-block.gr-box {
|
| 310 |
+
border: none !important;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.tabs > .tab-nav > button {
|
| 314 |
+
font-family: 'Montserrat', sans-serif;
|
| 315 |
+
font-size: 14px !important;
|
| 316 |
+
font-weight: 900 !important;
|
| 317 |
+
background: var(--bg-header) !important;
|
| 318 |
+
color: var(--color-text) !important;
|
| 319 |
+
border-bottom: 3px solid var(--color-border) !important;
|
| 320 |
+
transition: background-color 0.3s ease !important;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.tabs > .tab-nav > button.selected {
|
| 324 |
+
background: var(--bg-card) !important;
|
| 325 |
+
color: white !important;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
.gr-button {
|
| 329 |
+
padding: 8px 16px;
|
| 330 |
+
border: 3px solid var(--color-border) !important;
|
| 331 |
+
box-shadow: var(--shadow-button) !important;
|
| 332 |
+
font-weight: 900 !important;
|
| 333 |
+
transition: all 0.15s ease !important;
|
| 334 |
+
cursor: pointer;
|
| 335 |
+
font-size: 14px !important;
|
| 336 |
+
color: var(--color-text) !important;
|
| 337 |
+
background: var(--bg-button-secondary) !important;
|
| 338 |
+
}
|
| 339 |
+
.gr-button.submit-btn {
|
| 340 |
+
background: var(--bg-button-primary) !important;
|
| 341 |
+
}
|
| 342 |
+
.gr-button:hover {
|
| 343 |
+
transform: translate(2px, 2px);
|
| 344 |
+
box-shadow: 2px 2px 0 var(--color-border) !important;
|
| 345 |
+
background: var(--bg-button-primary-hover) !important;
|
| 346 |
+
}
|
| 347 |
+
.gr-button.submit-btn:hover {
|
| 348 |
+
background: var(--bg-button-primary-hover) !important;
|
| 349 |
+
}
|
| 350 |
+
.gr-button:active {
|
| 351 |
+
transform: translate(4px, 4px);
|
| 352 |
+
box-shadow: 0 0 0 var(--color-border) !important;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.canvas-output {
|
| 356 |
+
translate: -6px -6px;
|
| 357 |
+
background: var(--bg-card);
|
| 358 |
+
border: 3px solid var(--color-border);
|
| 359 |
+
box-shadow: var(--shadow-card);
|
| 360 |
+
transition: all 0.2s ease;
|
| 361 |
+
padding: 1.5rem;
|
| 362 |
+
}
|
| 363 |
+
.canvas-output:hover {
|
| 364 |
+
translate: -3px -3px;
|
| 365 |
+
box-shadow: 9px 9px 0 var(--color-border);
|
| 366 |
+
}
|
| 367 |
+
.canvas-output .gr-markdown h2 {
|
| 368 |
+
font-size: 14px;
|
| 369 |
+
font-weight: 900;
|
| 370 |
+
width: 100%;
|
| 371 |
+
background: var(--bg-header);
|
| 372 |
+
padding: 8px 12px;
|
| 373 |
+
color: var(--color-text);
|
| 374 |
+
border: 3px solid var(--color-border);
|
| 375 |
+
margin: -1.5rem -1.5rem 1.5rem -1.5rem; /* Adjust to break out of padding */
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
textarea, input[type="text"], input[type="file"] {
|
| 379 |
+
width: 100%;
|
| 380 |
+
padding: 10px;
|
| 381 |
+
border: 3px solid var(--color-border) !important;
|
| 382 |
+
background: var(--bg-header) !important;
|
| 383 |
+
color: var(--color-text) !important;
|
| 384 |
+
font-weight: 600 !important;
|
| 385 |
+
font-family: 'Montserrat', sans-serif;
|
| 386 |
+
font-size: 14px;
|
| 387 |
+
box-sizing: border-box;
|
| 388 |
+
border-radius: 0 !important;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
.gr-accordion {
|
| 392 |
+
border: 3px solid var(--color-border) !important;
|
| 393 |
+
background: rgba(255, 255, 255, 0.3) !important;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
.gr-image, .gr-video {
|
| 397 |
+
border: 3px solid var(--color-border) !important;
|
| 398 |
+
min-height: 290px;
|
| 399 |
+
}
|
| 400 |
"""
|
| 401 |
|
| 402 |
+
with gr.Blocks(css=css) as demo:
|
| 403 |
pdf_state = gr.State(value=get_initial_pdf_state())
|
| 404 |
gr.Markdown("# **Qwen3-VL-Processor**")
|
| 405 |
with gr.Row():
|
|
|
|
| 422 |
with gr.Column(scale=1):
|
| 423 |
pdf_query = gr.Textbox(label="Query Input", placeholder="e.g., 'Summarize this document'")
|
| 424 |
pdf_upload = gr.File(label="Upload PDF", file_types=[".pdf"])
|
|
|
|
| 425 |
pdf_submit = gr.Button("Submit", elem_classes="submit-btn")
|
| 426 |
with gr.Column(scale=1):
|
| 427 |
+
pdf_preview_img = gr.Image(label="PDF Preview", height=280)
|
| 428 |
with gr.Row():
|
| 429 |
prev_page_btn = gr.Button("◀ Previous")
|
| 430 |
page_info = gr.HTML('<div style="text-align:center;">No file loaded</div>')
|
|
|
|
| 440 |
with gr.Column(scale=3):
|
| 441 |
with gr.Column(elem_classes="canvas-output"):
|
| 442 |
gr.Markdown("## Output")
|
| 443 |
+
output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=15, show_copy_button=True)
|
| 444 |
with gr.Accordion("(Result.md)", open=False):
|
| 445 |
markdown_output = gr.Markdown(label="(Result.Md)")
|
| 446 |
|
|
|
|
| 477 |
)
|
| 478 |
|
| 479 |
if __name__ == "__main__":
|
| 480 |
+
demo.queue(max_size=50).launch(ssr_mode=False, show_error=True)
|