Tas01 commited on
Commit
4d4ee4b
·
verified ·
1 Parent(s): b0580c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +116 -37
app.py CHANGED
@@ -392,55 +392,134 @@ with gr.Blocks(title="CLIP-ViT Image Analyzer", theme=gr.themes.Soft()) as demo:
392
  # Load example images
393
  example_images_list = get_example_images()
394
 
395
- # Custom CSS to remove gallery selection frames
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  custom_css = """
 
397
  .gradio-container {
398
- max-height: 95vh !important;
399
- overflow-y: auto !important;
 
400
  }
401
-
402
  #blocks-container {
403
- max-height: 100% !important;
404
- overflow: auto !important;
405
- }
406
-
407
- .gallery .wrap.contain .grid .wrap {
408
- border: none !important;
409
- box-shadow: none !important;
410
- outline: none !important;
411
- }
412
- .gallery .wrap.contain .grid .wrap.selected {
413
- border: none !important;
414
- box-shadow: none !important;
415
- outline: none !important;
416
- }
417
- .gallery .thumbnail {
418
- border: none !important;
419
- box-shadow: none !important;
420
- outline: none !important;
421
- }
422
- .gallery .thumbnail.selected {
423
- border: none !important;
424
- box-shadow: none !important;
425
- outline: none !important;
426
- }
427
- .gallery .wrap.gradio-image {
428
- border: none !important;
429
- box-shadow: none !important;
430
- outline: none !important;
431
  }
 
 
 
 
 
 
 
432
  .gallery .wrap.gradio-image.selected {
433
  border: none !important;
434
  box-shadow: none !important;
435
  outline: none !important;
436
  }
437
- /* Prevent infinite expansion */
438
- .panel {
439
- max-height: 80vh !important;
440
- overflow-y: auto !important;
441
- }
442
  """
443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  with gr.Row():
445
  with gr.Column():
446
  input_image = gr.Image(
 
392
  # Load example images
393
  example_images_list = get_example_images()
394
 
395
+ # # Custom CSS to remove gallery selection frames
396
+ # #custom_css = """
397
+ # #.gradio-container {
398
+ # # max-height: 95vh !important;
399
+ # # overflow-y: auto !important;
400
+ # #}
401
+
402
+ # #blocks-container {
403
+ # max-height: 100% !important;
404
+ # overflow: auto !important;
405
+ # }
406
+
407
+ # #.gallery .wrap.contain .grid .wrap {
408
+ # border: none !important;
409
+ # box-shadow: none !important;
410
+ # outline: none !important;
411
+ # }
412
+ # .gallery .wrap.contain .grid .wrap.selected {
413
+ # border: none !important;
414
+ # box-shadow: none !important;
415
+ # outline: none !important;
416
+ # }
417
+ # .gallery .thumbnail {
418
+ # border: none !important;
419
+ # box-shadow: none !important;
420
+ # outline: none !important;
421
+ # }
422
+ # .gallery .thumbnail.selected {
423
+ # border: none !important;
424
+ # box-shadow: none !important;
425
+ # outline: none !important;
426
+ # }
427
+ # .gallery .wrap.gradio-image {
428
+ # border: none !important;
429
+ # box-shadow: none !important;
430
+ # outline: none !important;
431
+ # }
432
+ # .gallery .wrap.gradio-image.selected {
433
+ # border: none !important;
434
+ # box-shadow: none !important;
435
+ # outline: none !important;
436
+ # }
437
+ # /* Prevent infinite expansion */
438
+ # .panel {
439
+ # max-height: 80vh !important;
440
+ # overflow-y: auto !important;
441
+ # }
442
+ # #"""
443
+
444
+
445
  custom_css = """
446
+ <style>
447
  .gradio-container {
448
+ height: 100vh !important;
449
+ max-height: 100vh !important;
450
+ overflow: hidden !important;
451
  }
452
+
453
  #blocks-container {
454
+ height: calc(100vh - 100px) !important;
455
+ overflow-y: auto !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  }
457
+
458
+ /* Remove gallery selection frames */
459
+ .gallery .wrap.contain .grid .wrap,
460
+ .gallery .wrap.contain .grid .wrap.selected,
461
+ .gallery .thumbnail,
462
+ .gallery .thumbnail.selected,
463
+ .gallery .wrap.gradio-image,
464
  .gallery .wrap.gradio-image.selected {
465
  border: none !important;
466
  box-shadow: none !important;
467
  outline: none !important;
468
  }
469
+ </style>
 
 
 
 
470
  """
471
 
472
+ # Add this JavaScript separately
473
+ javascript = """
474
+ <script>
475
+ document.addEventListener('DOMContentLoaded', function() {
476
+ // Force container height immediately
477
+ const forceHeight = function() {
478
+ const containers = document.querySelectorAll('.gradio-container, .container, #blocks-container');
479
+ containers.forEach(container => {
480
+ container.style.height = '100vh';
481
+ container.style.maxHeight = '100vh';
482
+ container.style.overflowY = 'auto';
483
+ });
484
+ };
485
+
486
+ // Run immediately
487
+ forceHeight();
488
+
489
+ // Run again after a short delay to catch dynamic content
490
+ setTimeout(forceHeight, 100);
491
+ setTimeout(forceHeight, 500);
492
+
493
+ // Monitor for ANY DOM changes
494
+ const observer = new MutationObserver(function(mutations) {
495
+ forceHeight();
496
+ // Constrain any new elements
497
+ mutations.forEach(function(mutation) {
498
+ mutation.addedNodes.forEach(function(node) {
499
+ if (node.nodeType === 1) {
500
+ node.style.maxHeight = '100%';
501
+ if (node.querySelectorAll) {
502
+ node.querySelectorAll('*').forEach(child => {
503
+ child.style.maxHeight = '100%';
504
+ });
505
+ }
506
+ }
507
+ });
508
+ });
509
+ });
510
+
511
+ observer.observe(document.body, {
512
+ childList: true,
513
+ subtree: true,
514
+ attributes: true,
515
+ attributeFilter: ['style', 'class']
516
+ });
517
+ });
518
+ </script>
519
+ """
520
+
521
+
522
+
523
  with gr.Row():
524
  with gr.Column():
525
  input_image = gr.Image(