prithivMLmods commited on
Commit
4c318f0
·
verified ·
1 Parent(s): c29f2de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +93 -80
app.py CHANGED
@@ -27,7 +27,6 @@ from docling_core.types.doc import DoclingDocument, DocTagsDocument
27
  import re
28
  import ast
29
  import html
30
- import urllib.parse
31
 
32
  # Constants for text generation
33
  MAX_MAX_NEW_TOKENS = 2048
@@ -226,7 +225,7 @@ def generate_video(model_name: str, text: str, video_path: str,
226
  yield "Invalid model selected.", "Invalid model selected."
227
  return
228
 
229
- if video_path is None:
230
  yield "Please upload a video.", "Please upload a video."
231
  return
232
 
@@ -298,84 +297,99 @@ video_examples = [
298
  ["Explain the video in detail.", "videos/2.mp4"]
299
  ]
300
 
301
- # SVG data URL for the button icon
302
- svg_code = '''
303
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5">
304
- <polyline points="13.18 1.37 13.18 9.64 21.45 9.64 10.82 22.63 10.82 14.36 2.55 14.36 13.18 1.37"></polyline>
305
- </svg>
306
- '''
307
- svg_data_url = 'data:image/svg+xml,' + urllib.parse.quote(svg_code)
308
-
309
- # Updated CSS with fancy-button styles
310
- css = f"""
311
- .fancy-button {{
312
- --round: 0.75rem;
313
  cursor: pointer;
314
  position: relative;
315
- display: inline-flex;
316
- align-items: center;
317
- justify-content: center;
318
- overflow: hidden;
319
- transition: all 0.25s ease;
320
- background: radial-gradient(
321
- 65.28% 65.28% at 50% 100%,
322
- rgba(223, 113, 255, 0.8) 0%,
323
- rgba(223, 113, 255, 0) 100%
324
- ),
325
- linear-gradient(0deg, #7a5af8, #7a5af8);
326
- border-radius: var(--round);
327
- border: none;
328
- outline: none;
329
- padding: 12px 18px 12px 40px;
330
- color: white;
331
- font-size: 16px;
332
- font-weight: 500;
333
- }}
334
-
335
- .fancy-button::before {{
336
- content: '';
337
- position: absolute;
338
- left: 10px;
339
- top: 50%;
340
- transform: translateY(-50%);
341
- width: 18px;
342
- height: 18px;
343
- background: url('{svg_data_url}') no-repeat center;
344
- background-size: contain;
345
- }}
346
-
347
- .fancy-button::after {{
348
- content: '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  position: absolute;
350
- top: 0;
351
- right: 0;
352
- width: 1rem;
353
- height: 1rem;
354
- background: radial-gradient(
355
- 100% 75% at 55%,
356
- rgba(223, 113, 255, 0.8) 0%,
357
- rgba(223, 113, 255, 0) 100%
358
- );
359
- box-shadow: 0 0 3px black;
360
- border-bottom-left-radius: 0.5rem;
361
- border-top-right-radius: var(--round);
362
- transition: all 0.5s ease-in-out;
363
- }}
364
-
365
- .fancy-button:hover::after {{
366
- margin-top: -1rem;
367
- margin-right: -1rem;
368
- }}
369
-
370
- .fancy-button:active {{
371
- transform: scale(0.95);
372
- }}
373
-
374
- .canvas-output {{
375
- border: 2px solid #4682B4;
376
- border-radius: 10px;
377
- padding: 20px;
378
- }}
 
 
 
 
 
379
  """
380
 
381
  # Create the Gradio Interface
@@ -387,7 +401,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
387
  with gr.TabItem("Image Inference"):
388
  image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
389
  image_upload = gr.Image(type="pil", label="Image")
390
- image_submit = gr.Button("Submit", elem_classes="fancy-button")
391
  gr.Examples(
392
  examples=image_examples,
393
  inputs=[image_query, image_upload]
@@ -395,7 +409,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
395
  with gr.TabItem("Video Inference"):
396
  video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
397
  video_upload = gr.Video(label="Video")
398
- video_submit = gr.Button("Submit", elem_classes="fancy-button")
399
  gr.Examples(
400
  examples=video_examples,
401
  inputs=[video_query, video_upload]
@@ -411,7 +425,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
411
  with gr.Column(elem_classes="canvas-output"):
412
  gr.Markdown("## Output")
413
  raw_output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=2)
414
-
415
  with gr.Accordion("(Result.md)", open=False):
416
  formatted_output = gr.Markdown(label="(Result.md)")
417
 
 
27
  import re
28
  import ast
29
  import html
 
30
 
31
  # Constants for text generation
32
  MAX_MAX_NEW_TOKENS = 2048
 
225
  yield "Invalid model selected.", "Invalid model selected."
226
  return
227
 
228
+ Nm if video_path is None:
229
  yield "Please upload a video.", "Please upload a video."
230
  return
231
 
 
297
  ["Explain the video in detail.", "videos/2.mp4"]
298
  ]
299
 
300
+ # Updated CSS with the new Submit button theme
301
+ css = """
302
+ .submit-btn {
303
+ --stone-50: #fafaf9;
304
+ --stone-800: #292524;
305
+ --yellow-400: #facc15;
306
+
307
+ font-size: 1rem;
 
 
 
 
308
  cursor: pointer;
309
  position: relative;
310
+ font-family: "Rubik", sans-serif;
311
+ font-weight: bold;
312
+ line-height: 1;
313
+ padding: 0.75rem 1.25rem;
314
+ transform: translate(-4px, -4px);
315
+ outline: 2px solid transparent;
316
+ outline-offset: 5px;
317
+ border-radius: 9999px;
318
+ background-color: var(--yellow-400);
319
+ color: var(--stone-800);
320
+ transition:
321
+ transform 150ms ease,
322
+ box-shadow 150ms ease;
323
+ text-align: center;
324
+ box-shadow:
325
+ 0.5px 0.5px 0 0 var(--stone-800),
326
+ 1px 1px 0 0 var(--stone-800),
327
+ 1.5px 1.5px 0 0 var(--stone-800),
328
+ 2px 2px 0 0 var(--stone-800),
329
+ 2.5px 2.5px 0 0 var(--stone-800),
330
+ 3px 3px 0 0 var(--stone-800),
331
+ 0 0 0 2px var(--stone-50),
332
+ 0.5px 0.5px 0 2px var(--stone-50),
333
+ 1px 1px 0 2px var(--stone-50),
334
+ 1.5px 1.5px 0 2px var(--stone-50),
335
+ 2px 2px 0 2px var(--stone-50),
336
+ 2.5px 2.5px 0 2px var(--stone-50),
337
+ 3px 3px 0 2px var(--stone-50),
338
+ 3.5px 3.5px 0 2px var(--stone-50),
339
+ 4px 4px 0 2px var(--stone-50);
340
+ }
341
+
342
+ .submit-btn:hover {
343
+ transform: translate(0, 0);
344
+ box-shadow: 0 0 0 2px var(--stone-50);
345
+ }
346
+
347
+ .submit-btn:active {
348
+ transform: translate(0, 2px);
349
+ }
350
+
351
+ .submit-btn:focus-visible {
352
+ outline-color: var(--yellow-400);
353
+ outline-style: dashed;
354
+ }
355
+
356
+ .submit-btn::before {
357
+ content: "";
358
  position: absolute;
359
+ inset: 0;
360
+ border-radius: 9999px;
361
+ opacity: 0.5;
362
+ background-image: radial-gradient(
363
+ rgb(255 255 255 / 80%) 20%,
364
+ transparent 20%
365
+ ),
366
+ radial-gradient(rgb(255 255 255 / 100%) 20%, transparent 20%);
367
+ background-position:
368
+ 0 0,
369
+ 4px 4px;
370
+ background-size: 8px 8px;
371
+ mix-blend-mode: hard-light;
372
+ animation: dots 0.5s infinite linear;
373
+ }
374
+
375
+ @keyframes dots {
376
+ 0% {
377
+ background-position:
378
+ 0 0,
379
+ 4px 4px;
380
+ }
381
+ 100% {
382
+ background-position:
383
+ 8px 0,
384
+ 12px 4px;
385
+ }
386
+ }
387
+
388
+ .canvas-output {
389
+ border: 2px solid #4682B4;
390
+ border-radius: 10px;
391
+ padding: 20px;
392
+ }
393
  """
394
 
395
  # Create the Gradio Interface
 
401
  with gr.TabItem("Image Inference"):
402
  image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
403
  image_upload = gr.Image(type="pil", label="Image")
404
+ image Timage_submit = gr.Button("Submit", elem_classes="submit-btn")
405
  gr.Examples(
406
  examples=image_examples,
407
  inputs=[image_query, image_upload]
 
409
  with gr.TabItem("Video Inference"):
410
  video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
411
  video_upload = gr.Video(label="Video")
412
+ video_submit = gr.Button("Submit", elem_classes="submit-btn")
413
  gr.Examples(
414
  examples=video_examples,
415
  inputs=[video_query, video_upload]
 
425
  with gr.Column(elem_classes="canvas-output"):
426
  gr.Markdown("## Output")
427
  raw_output = gr.Textbox(label="Raw Output Stream", interactive=False, lines=2)
 
428
  with gr.Accordion("(Result.md)", open=False):
429
  formatted_output = gr.Markdown(label="(Result.md)")
430