Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -258,179 +258,168 @@ video_examples = [["Explain the video in detail.", "videos/2.mp4"]]
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
font-
|
| 264 |
-
|
| 265 |
-
color:
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
/* Main Chat Container / Card Style */
|
| 270 |
-
.chat-container {
|
| 271 |
-
border-radius: 1.25em;
|
| 272 |
-
background: linear-gradient(135deg, rgba(39, 39, 42, 0.8), rgba(9, 9, 11, 0.9));
|
| 273 |
-
border: 1px solid rgba(113, 113, 122, 0.5);
|
| 274 |
-
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
| 275 |
-
backdrop-filter: blur(20px);
|
| 276 |
-
padding: 1em 1.5em;
|
| 277 |
-
gap: 1.5rem;
|
| 278 |
}
|
| 279 |
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
align-items: center;
|
| 284 |
-
justify-content: space-between;
|
| 285 |
-
padding-bottom: 0.5em;
|
| 286 |
-
border-bottom: 1px solid rgba(113, 113, 122, 0.5);
|
| 287 |
}
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
}
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
| 299 |
}
|
| 300 |
-
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
| 301 |
|
| 302 |
-
/* Textbox
|
| 303 |
.gr-textbox, .gr-file {
|
| 304 |
-
|
| 305 |
-
border:
|
| 306 |
-
|
| 307 |
-
|
| 308 |
}
|
| 309 |
textarea, input[type=text] {
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
font-
|
| 313 |
-
|
| 314 |
-
padding: 1em 0 !important;
|
| 315 |
-
}
|
| 316 |
-
.gr-label > .label-text {
|
| 317 |
-
color: #a1a1aa !important;
|
| 318 |
-
font-weight: 500 !important;
|
| 319 |
-
margin-bottom: 0.25rem !important;
|
| 320 |
}
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
.submit-btn {
|
| 324 |
-
padding: 0.75em !important;
|
| 325 |
-
background: linear-gradient(to right, #2563eb, #3b82f6) !important;
|
| 326 |
-
border: none !important;
|
| 327 |
-
border-radius: 0.75em !important;
|
| 328 |
-
color: white !important;
|
| 329 |
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
|
| 330 |
-
transition: all 0.2s ease !important;
|
| 331 |
}
|
| 332 |
-
.
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
}
|
| 337 |
|
| 338 |
-
/*
|
| 339 |
-
.
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
| 346 |
}
|
| 347 |
-
.
|
| 348 |
-
|
| 349 |
-
|
| 350 |
}
|
| 351 |
|
| 352 |
/* Tabs Styling */
|
| 353 |
-
.tab-nav {
|
|
|
|
|
|
|
| 354 |
.tab-nav > button {
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
font-weight: 500 !important;
|
| 359 |
-
border-bottom: 2px solid transparent !important;
|
| 360 |
-
border-radius: 0 !important;
|
| 361 |
-
padding: 0.75rem !important;
|
| 362 |
}
|
| 363 |
.tab-nav > button.selected {
|
| 364 |
-
|
| 365 |
-
|
|
|
|
|
|
|
|
|
|
| 366 |
}
|
| 367 |
|
| 368 |
-
/* Accordion Styling */
|
| 369 |
.gr-accordion {
|
| 370 |
-
border:
|
| 371 |
-
|
| 372 |
-
background:
|
|
|
|
| 373 |
}
|
| 374 |
-
.gr-
|
| 375 |
-
|
| 376 |
-
|
|
|
|
| 377 |
}
|
|
|
|
| 378 |
.page-info {
|
| 379 |
text-align: center;
|
| 380 |
-
|
| 381 |
-
font-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
}
|
| 383 |
"""
|
| 384 |
|
| 385 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
| 386 |
pdf_state = gr.State(value=get_initial_pdf_state())
|
| 387 |
-
gr.Markdown("# **Qwen3-VL-Processor**")
|
| 388 |
|
| 389 |
-
with gr.Row(equal_height=False):
|
| 390 |
# --- INPUT COLUMN ---
|
| 391 |
-
with gr.Column(scale=2, min_width=400):
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
top_p = gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
| 424 |
-
top_k = gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50)
|
| 425 |
-
repetition_penalty = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2)
|
| 426 |
|
| 427 |
# --- OUTPUT COLUMN ---
|
| 428 |
-
with gr.Column(scale=3, min_width=500):
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=15)
|
| 433 |
-
markdown_output = gr.Markdown(label="Formatted Output")
|
| 434 |
|
| 435 |
# Event handlers
|
| 436 |
image_submit.click(
|
|
|
|
| 258 |
pdf_examples = [["examples/sample-doc.pdf"]]
|
| 259 |
|
| 260 |
css = """
|
| 261 |
+
:root {
|
| 262 |
+
--input-focus: #2d8cf0;
|
| 263 |
+
--font-color: #323232;
|
| 264 |
+
--font-color-sub: #666;
|
| 265 |
+
--bg-color: beige;
|
| 266 |
+
--main-color: black;
|
| 267 |
+
--form-bg: lightblue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
+
body, .gradio-container {
|
| 271 |
+
font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
|
| 272 |
+
background-color: var(--bg-color);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
}
|
| 274 |
+
|
| 275 |
+
/* Main Form/Card Styling */
|
| 276 |
+
.retro-form {
|
| 277 |
+
padding: 20px;
|
| 278 |
+
background: var(--form-bg);
|
| 279 |
+
gap: 20px;
|
| 280 |
+
border-radius: 5px;
|
| 281 |
+
border: 2px solid var(--main-color);
|
| 282 |
+
box-shadow: 4px 4px var(--main-color);
|
| 283 |
}
|
| 284 |
+
|
| 285 |
+
/* Title Styling */
|
| 286 |
+
.form-title {
|
| 287 |
+
color: var(--font-color);
|
| 288 |
+
font-weight: 900;
|
| 289 |
+
font-size: 20px;
|
| 290 |
+
margin-bottom: 25px;
|
| 291 |
+
text-align: center;
|
| 292 |
}
|
|
|
|
| 293 |
|
| 294 |
+
/* Input/Textbox Styling */
|
| 295 |
.gr-textbox, .gr-file {
|
| 296 |
+
border-radius: 5px !important;
|
| 297 |
+
border: 2px solid var(--main-color) !important;
|
| 298 |
+
background-color: var(--bg-color) !important;
|
| 299 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 300 |
}
|
| 301 |
textarea, input[type=text] {
|
| 302 |
+
font-size: 15px !important;
|
| 303 |
+
font-weight: 600 !important;
|
| 304 |
+
color: var(--font-color) !important;
|
| 305 |
+
padding: 5px 10px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
}
|
| 307 |
+
.gr-textbox:focus-within, .gr-file:focus-within {
|
| 308 |
+
border: 2px solid var(--input-focus) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
}
|
| 310 |
+
.gr-label > .label-text {
|
| 311 |
+
font-weight: 900 !important;
|
| 312 |
+
color: var(--font-color) !important;
|
| 313 |
+
margin-bottom: 0.5rem !important;
|
| 314 |
}
|
| 315 |
|
| 316 |
+
/* Button Styling */
|
| 317 |
+
.gr-button {
|
| 318 |
+
border-radius: 5px !important;
|
| 319 |
+
border: 2px solid var(--main-color) !important;
|
| 320 |
+
background-color: var(--bg-color) !important;
|
| 321 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 322 |
+
font-size: 17px !important;
|
| 323 |
+
font-weight: 600 !important;
|
| 324 |
+
color: var(--font-color) !important;
|
| 325 |
+
cursor: pointer !important;
|
| 326 |
+
transition: all 0.1s ease-in-out !important;
|
| 327 |
}
|
| 328 |
+
.gr-button:active {
|
| 329 |
+
box-shadow: 0px 0px var(--main-color) !important;
|
| 330 |
+
transform: translate(3px, 3px) !important;
|
| 331 |
}
|
| 332 |
|
| 333 |
/* Tabs Styling */
|
| 334 |
+
.tab-nav {
|
| 335 |
+
gap: 0.5rem;
|
| 336 |
+
}
|
| 337 |
.tab-nav > button {
|
| 338 |
+
border: 2px solid var(--main-color) !important;
|
| 339 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 340 |
+
background: lightcyan !important; /* Slightly different for inactive */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
}
|
| 342 |
.tab-nav > button.selected {
|
| 343 |
+
background: var(--bg-color) !important;
|
| 344 |
+
}
|
| 345 |
+
.tab-nav > button:active {
|
| 346 |
+
box-shadow: 0px 0px var(--main-color) !important;
|
| 347 |
+
transform: translate(3px, 3px) !important;
|
| 348 |
}
|
| 349 |
|
| 350 |
+
/* Accordion & Slider Styling */
|
| 351 |
.gr-accordion {
|
| 352 |
+
border: 2px solid var(--main-color) !important;
|
| 353 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 354 |
+
background-color: lightcyan !important;
|
| 355 |
+
border-radius: 5px !important;
|
| 356 |
}
|
| 357 |
+
.gr-slider {
|
| 358 |
+
border: 2px solid var(--main-color) !important;
|
| 359 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 360 |
+
background-color: var(--bg-color) !important;
|
| 361 |
}
|
| 362 |
+
|
| 363 |
.page-info {
|
| 364 |
text-align: center;
|
| 365 |
+
font-weight: 900;
|
| 366 |
+
color: var(--font-color);
|
| 367 |
+
padding-top: 1rem;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
/* Image/Video Preview */
|
| 371 |
+
.gr-image, .gr-video {
|
| 372 |
+
border: 2px solid var(--main-color) !important;
|
| 373 |
+
background-color: var(--bg-color) !important;
|
| 374 |
+
box-shadow: 4px 4px var(--main-color) !important;
|
| 375 |
+
border-radius: 5px !important;
|
| 376 |
}
|
| 377 |
"""
|
| 378 |
|
| 379 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
| 380 |
pdf_state = gr.State(value=get_initial_pdf_state())
|
| 381 |
+
gr.Markdown("# **Qwen3-VL-Processor**", elem_classes="form-title")
|
| 382 |
|
| 383 |
+
with gr.Row(equal_height=False, variant='panel'):
|
| 384 |
# --- INPUT COLUMN ---
|
| 385 |
+
with gr.Column(scale=2, min_width=400, elem_classes="retro-form"):
|
| 386 |
+
gr.Markdown("### INPUT", elem_classes="form-title")
|
| 387 |
+
|
| 388 |
+
with gr.Tabs():
|
| 389 |
+
with gr.TabItem("Image"):
|
| 390 |
+
image_query = gr.Textbox(label="Query", placeholder="Describe the image...")
|
| 391 |
+
image_upload = gr.Image(type="pil", label="Image Upload")
|
| 392 |
+
image_submit = gr.Button("Analyze Image")
|
| 393 |
+
gr.Examples(examples=image_examples, inputs=[image_query, image_upload])
|
| 394 |
+
|
| 395 |
+
with gr.TabItem("Video"):
|
| 396 |
+
video_query = gr.Textbox(label="Query", placeholder="Summarize the video...")
|
| 397 |
+
video_upload = gr.Video(label="Video Upload")
|
| 398 |
+
video_submit = gr.Button("Analyze Video")
|
| 399 |
+
gr.Examples(examples=video_examples, inputs=[video_query, video_upload])
|
| 400 |
+
|
| 401 |
+
with gr.TabItem("PDF"):
|
| 402 |
+
pdf_query = gr.Textbox(label="Query", placeholder="Extract key points...")
|
| 403 |
+
pdf_upload = gr.File(label="PDF Upload", file_types=[".pdf"])
|
| 404 |
+
pdf_preview_img = gr.Image(label="PDF Preview")
|
| 405 |
+
with gr.Row():
|
| 406 |
+
prev_page_btn = gr.Button("◀ Prev")
|
| 407 |
+
next_page_btn = gr.Button("Next ▶")
|
| 408 |
+
page_info = gr.HTML('<div class="page-info">No file loaded</div>')
|
| 409 |
+
pdf_submit = gr.Button("Analyze PDF")
|
| 410 |
+
|
| 411 |
+
with gr.Accordion("Advanced options", open=False):
|
| 412 |
+
max_new_tokens = gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
|
| 413 |
+
temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6)
|
| 414 |
+
top_p = gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
| 415 |
+
top_k = gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50)
|
| 416 |
+
repetition_penalty = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2)
|
|
|
|
|
|
|
|
|
|
| 417 |
|
| 418 |
# --- OUTPUT COLUMN ---
|
| 419 |
+
with gr.Column(scale=3, min_width=500, elem_classes="retro-form"):
|
| 420 |
+
gr.Markdown("### RESULT", elem_classes="form-title")
|
| 421 |
+
output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=15)
|
| 422 |
+
markdown_output = gr.Markdown(label="Formatted Output")
|
|
|
|
|
|
|
| 423 |
|
| 424 |
# Event handlers
|
| 425 |
image_submit.click(
|