prithivMLmods commited on
Commit
26ba214
·
verified ·
1 Parent(s): 8d88819

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +126 -137
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
- /* 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
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(