prithivMLmods commited on
Commit
8d88819
·
verified ·
1 Parent(s): 5bd4cbe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +137 -177
app.py CHANGED
@@ -258,218 +258,178 @@ video_examples = [["Explain the video in detail.", "videos/2.mp4"]]
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 */
290
- .gradio-container .gr-panel {
291
- background-color: transparent !important;
292
- border: none !important;
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
 
430
  with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
431
  pdf_state = gr.State(value=get_initial_pdf_state())
 
432
 
433
- with gr.Column(elem_id="app-header"):
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
 
258
  pdf_examples = [["examples/sample-doc.pdf"]]
259
 
260
  css = """
261
+ /* Main App Styling */
 
 
 
 
 
 
 
 
 
 
 
 
262
  body, .gradio-container {
263
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
264
+ background: #09090b;
265
+ color: #f4f4f5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
+ .gradio-container { padding: 1.5em; }
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
+ /* Header within the card */
281
+ .card-header {
 
 
 
 
 
282
  display: flex;
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
+ .card-header .title {
289
+ font-size: 1.25em;
290
+ font-weight: 600;
291
+ color: #d4d4d8;
292
  }
293
+ .status-indicator {
294
+ width: 0.6em;
295
+ height: 0.6em;
296
+ border-radius: 50%;
297
+ background-color: #22c55e;
298
+ animation: pulse 2s infinite;
 
 
 
299
  }
300
+ @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
301
 
302
+ /* Textbox and Input Areas */
303
+ .gr-textbox, .gr-file {
304
+ background: transparent !important;
305
+ border: none !important;
306
+ box-shadow: none !important;
307
+ padding: 0 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  }
309
  textarea, input[type=text] {
310
+ color: #f4f4f5 !important;
311
  background: transparent !important;
312
+ font-size: 1em !important;
313
+ line-height: 1.6 !important;
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
+ /* Primary "Submit" Button */
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
+ .submit-btn:hover {
333
+ background: linear-gradient(to right, #3b82f6, #60a5fa) !important;
334
+ transform: scale(1.05);
335
+ box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.25) !important;
336
  }
337
 
338
+ /* Secondary Buttons (PDF Nav) */
339
+ .secondary-btn {
340
+ padding: 0.625em !important;
341
+ background: rgba(39, 39, 42, 0.4) !important;
342
+ border: 1px solid rgba(63, 63, 70, 0.5) !important;
343
+ border-radius: 0.75em !important;
344
+ color: #a1a1aa !important;
345
+ transition: all 0.2s ease !important;
346
+ }
347
+ .secondary-btn:hover {
348
+ color: #d4d4d8 !important;
349
+ background-color: rgba(63, 63, 70, 0.5) !important;
350
  }
351
+
352
+ /* Tabs Styling */
353
+ .tab-nav { border-bottom: 1px solid rgba(113, 113, 122, 0.5); }
354
  .tab-nav > button {
355
+ background: transparent !important;
356
+ border: none !important;
357
+ color: #a1a1aa !important;
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
+ color: #60a5fa !important;
365
+ border-bottom: 2px solid #60a5fa !important;
 
 
366
  }
367
 
368
+ /* Accordion Styling */
369
  .gr-accordion {
370
+ border: 1px solid rgba(113, 113, 122, 0.5) !important;
371
+ border-radius: 0.75em !important;
372
+ background: rgba(39, 39, 42, 0.4) !important;
 
373
  }
374
  .gr-accordion > .label-wrap {
375
+ color: #a1a1aa !important;
376
+ font-weight: 500 !important;
377
  }
378
  .page-info {
379
  text-align: center;
380
+ color: #a1a1aa;
381
+ font-weight: 500;
 
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
+ with gr.Column(elem_classes="chat-container"):
393
+ with gr.Row(elem_classes="card-header"):
394
+ gr.Markdown("INPUT", elem_classes="title")
395
+ gr.HTML('<div class="status-indicator"></div>')
396
+
397
+ with gr.Tabs():
398
+ with gr.TabItem("Image"):
399
+ image_query = gr.Textbox(label="Query", placeholder="Describe the image...", lines=3)
400
+ image_upload = gr.Image(type="pil", label="Image Upload")
401
+ image_submit = gr.Button("Analyze Image", elem_classes="submit-btn")
402
+ gr.Examples(examples=image_examples, inputs=[image_query, image_upload])
403
+
404
+ with gr.TabItem("Video"):
405
+ video_query = gr.Textbox(label="Query", placeholder="Summarize the video...", lines=3)
406
+ video_upload = gr.Video(label="Video Upload")
407
+ video_submit = gr.Button("Analyze Video", elem_classes="submit-btn")
408
+ gr.Examples(examples=video_examples, inputs=[video_query, video_upload])
409
+
410
+ with gr.TabItem("PDF"):
411
+ pdf_query = gr.Textbox(label="Query", placeholder="Extract key points from the PDF...", lines=3)
412
+ pdf_upload = gr.File(label="PDF Upload", file_types=[".pdf"])
413
+ pdf_preview_img = gr.Image(label="PDF Preview")
414
+ with gr.Row():
415
+ prev_page_btn = gr.Button("◀ Previous", elem_classes="secondary-btn")
416
+ next_page_btn = gr.Button("Next ▶", elem_classes="secondary-btn")
417
+ page_info = gr.HTML('<div class="page-info">No file loaded</div>')
418
+ pdf_submit = gr.Button("Analyze PDF", elem_classes="submit-btn")
419
+
420
+ with gr.Accordion("Advanced options", open=False):
421
+ max_new_tokens = gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
422
+ temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6)
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
+ with gr.Column(elem_classes="chat-container"):
430
+ with gr.Row(elem_classes="card-header"):
431
+ gr.Markdown("RESULT", elem_classes="title")
432
+ output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=15)
433
  markdown_output = gr.Markdown(label="Formatted Output")
434
 
435
  # Event handlers