humairawan commited on
Commit
9c12445
·
verified ·
1 Parent(s): cf1b40e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +107 -43
app.py CHANGED
@@ -166,7 +166,7 @@ class SpectrogramVisualizer:
166
  hop: Optional[int] = None,
167
  vmin: float = -100,
168
  vmax: float = 0,
169
- cmap: str = "viridis",
170
  ):
171
  """Plot a spectrogram of shape [F, T]"""
172
  spec_np = spec.cpu().numpy() if isinstance(spec, torch.Tensor) else spec
@@ -188,14 +188,18 @@ class SpectrogramVisualizer:
188
  )
189
 
190
  if title:
191
- ax.set_title(title, fontsize=14, fontweight='bold', pad=15, color='white')
192
  if xlabel:
193
- ax.set_xlabel(xlabel, fontsize=11, color='white')
194
  if ylabel:
195
- ax.set_ylabel(ylabel, fontsize=11, color='white')
196
 
197
- ax.grid(True, alpha=0.15, linestyle='--', linewidth=0.5)
198
- ax.tick_params(colors='white', labelsize=9)
 
 
 
 
199
 
200
  return im
201
 
@@ -235,8 +239,8 @@ class SpectrogramVisualizer:
235
  vmax=vmax,
236
  )
237
 
238
- figure.patch.set_facecolor('#0f0f0f')
239
- ax.set_facecolor('#0f0f0f')
240
  figure.canvas.draw()
241
 
242
  return PILImage.frombytes(
@@ -400,13 +404,18 @@ def toggle_input_mode(choice: str):
400
 
401
 
402
  # ============================================================================
403
- # Custom CSS
404
  # ============================================================================
405
 
406
  custom_css = """
407
- /* Global Styles */
408
  .gradio-container {
409
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
 
 
 
 
 
410
  }
411
 
412
  /* Hero Section */
@@ -415,16 +424,17 @@ custom_css = """
415
  padding: 50px 30px;
416
  border-radius: 20px;
417
  margin-bottom: 40px;
418
- box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
419
  text-align: center;
 
420
  }
421
 
422
  #hero-section h1 {
423
- color: white;
424
  font-size: 3.2em;
425
  font-weight: 800;
426
  margin: 0 0 15px 0;
427
- text-shadow: 2px 2px 8px rgba(0,0,0,0.2);
428
  letter-spacing: -1px;
429
  }
430
 
@@ -437,49 +447,49 @@ custom_css = """
437
  font-weight: 300;
438
  }
439
 
440
- /* Feature Cards */
441
  .feature-card {
442
- background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
443
  padding: 25px;
444
  border-radius: 15px;
445
- box-shadow: 0 4px 15px rgba(0,0,0,0.08);
446
  margin-bottom: 20px;
447
- border: 1px solid rgba(255,255,255,0.5);
448
  transition: all 0.3s ease;
449
  }
450
 
451
  .feature-card:hover {
452
  transform: translateY(-3px);
453
- box-shadow: 0 8px 25px rgba(0,0,0,0.12);
 
454
  }
455
 
456
  /* Input Controls Section */
457
  .input-controls {
458
- background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
459
  padding: 30px;
460
  border-radius: 15px;
461
- box-shadow: 0 5px 20px rgba(0,0,0,0.1);
 
462
  }
463
 
464
  /* Output Section */
465
  .output-section {
466
- background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
467
  padding: 30px;
468
  border-radius: 15px;
469
- box-shadow: 0 5px 20px rgba(0,0,0,0.1);
 
470
  }
471
 
472
  /* Section Headers */
473
  .section-header {
474
- color: #667eea;
475
  font-size: 1.8em;
476
  font-weight: 700;
477
  margin: 30px 0 20px 0;
478
  text-align: center;
479
- background: linear-gradient(135deg, #667eea, #764ba2);
480
- -webkit-background-clip: text;
481
- -webkit-text-fill-color: transparent;
482
- background-clip: text;
483
  }
484
 
485
  /* Process Button */
@@ -490,25 +500,26 @@ custom_css = """
490
  font-weight: 700 !important;
491
  padding: 20px 50px !important;
492
  border-radius: 50px !important;
493
- box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5) !important;
494
  transition: all 0.3s ease !important;
495
- color: white !important;
496
  text-transform: uppercase;
497
  letter-spacing: 1px;
498
  }
499
 
500
  .process-button:hover {
501
  transform: translateY(-3px) scale(1.02) !important;
502
- box-shadow: 0 15px 40px rgba(102, 126, 234, 0.7) !important;
503
  }
504
 
505
  /* Audio Components */
506
  .audio-wrapper {
507
- background: white;
508
  padding: 20px;
509
  border-radius: 12px;
510
- box-shadow: 0 3px 12px rgba(0,0,0,0.08);
511
  margin: 15px 0;
 
512
  }
513
 
514
  /* Tabs */
@@ -517,30 +528,37 @@ custom_css = """
517
  font-size: 1.1em !important;
518
  padding: 12px 24px !important;
519
  border-radius: 10px 10px 0 0 !important;
 
 
 
520
  }
521
 
522
  .tab-nav button[aria-selected="true"] {
523
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
524
- color: white !important;
525
  }
526
 
527
  /* Info Box */
528
  .info-box {
529
- background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
530
  padding: 25px;
531
  border-radius: 15px;
532
  margin: 25px 0;
533
  border-left: 5px solid #667eea;
534
- box-shadow: 0 4px 15px rgba(0,0,0,0.1);
535
  }
536
 
537
  .info-box h3 {
538
- color: #667eea;
539
  font-size: 1.4em;
540
  font-weight: 700;
541
  margin-top: 0;
542
  }
543
 
 
 
 
 
544
  .info-box ul {
545
  margin: 10px 0;
546
  padding-left: 25px;
@@ -553,11 +571,12 @@ custom_css = """
553
 
554
  /* Examples Section */
555
  .examples-section {
556
- background: linear-gradient(135deg, #ffeaa7 0%, #dfe6e9 100%);
557
  padding: 25px;
558
  border-radius: 15px;
559
  margin-top: 30px;
560
- box-shadow: 0 4px 15px rgba(0,0,0,0.08);
 
561
  }
562
 
563
  /* Footer */
@@ -567,7 +586,8 @@ custom_css = """
567
  margin-top: 50px;
568
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
569
  border-radius: 15px;
570
- color: white;
 
571
  }
572
 
573
  #footer h3 {
@@ -578,7 +598,7 @@ custom_css = """
578
 
579
  #footer p {
580
  margin: 5px 0;
581
- opacity: 0.9;
582
  }
583
 
584
  /* Radio Buttons */
@@ -587,6 +607,14 @@ custom_css = """
587
  border-radius: 10px !important;
588
  font-weight: 600 !important;
589
  transition: all 0.3s ease !important;
 
 
 
 
 
 
 
 
590
  }
591
 
592
  /* Dropdowns */
@@ -594,13 +622,47 @@ custom_css = """
594
  border-radius: 10px !important;
595
  padding: 12px !important;
596
  font-size: 1.05em !important;
597
- border: 2px solid #e0e0e0 !important;
 
 
598
  transition: all 0.3s ease !important;
599
  }
600
 
601
  .dropdown select:focus {
602
  border-color: #667eea !important;
603
- box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
604
  }
605
  """
606
 
@@ -608,7 +670,7 @@ custom_css = """
608
  # Gradio Interface
609
  # ============================================================================
610
 
611
- with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="indigo")) as demo:
612
 
613
  # Hero Section
614
  gr.HTML("""
@@ -685,6 +747,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="indigo")) as de
685
  elem_classes="dropdown"
686
  )
687
 
 
 
688
  process_btn = gr.Button(
689
  "🚀 Denoise Audio",
690
  elem_classes="process-button",
 
166
  hop: Optional[int] = None,
167
  vmin: float = -100,
168
  vmax: float = 0,
169
+ cmap: str = "plasma",
170
  ):
171
  """Plot a spectrogram of shape [F, T]"""
172
  spec_np = spec.cpu().numpy() if isinstance(spec, torch.Tensor) else spec
 
188
  )
189
 
190
  if title:
191
+ ax.set_title(title, fontsize=14, fontweight='bold', pad=15, color='#e0e0e0')
192
  if xlabel:
193
+ ax.set_xlabel(xlabel, fontsize=11, color='#b0b0b0')
194
  if ylabel:
195
+ ax.set_ylabel(ylabel, fontsize=11, color='#b0b0b0')
196
 
197
+ ax.grid(True, alpha=0.15, linestyle='--', linewidth=0.5, color='#555')
198
+ ax.tick_params(colors='#888', labelsize=9)
199
+ ax.spines['top'].set_color('#333')
200
+ ax.spines['bottom'].set_color('#333')
201
+ ax.spines['left'].set_color('#333')
202
+ ax.spines['right'].set_color('#333')
203
 
204
  return im
205
 
 
239
  vmax=vmax,
240
  )
241
 
242
+ figure.patch.set_facecolor('#0a0a0a')
243
+ ax.set_facecolor('#0a0a0a')
244
  figure.canvas.draw()
245
 
246
  return PILImage.frombytes(
 
404
 
405
 
406
  # ============================================================================
407
+ # Custom CSS - Dark Theme
408
  # ============================================================================
409
 
410
  custom_css = """
411
+ /* Global Dark Theme */
412
  .gradio-container {
413
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
414
+ background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%) !important;
415
+ }
416
+
417
+ body {
418
+ background: #0a0a0a !important;
419
  }
420
 
421
  /* Hero Section */
 
424
  padding: 50px 30px;
425
  border-radius: 20px;
426
  margin-bottom: 40px;
427
+ box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
428
  text-align: center;
429
+ border: 1px solid rgba(255, 255, 255, 0.1);
430
  }
431
 
432
  #hero-section h1 {
433
+ color: #ffffff;
434
  font-size: 3.2em;
435
  font-weight: 800;
436
  margin: 0 0 15px 0;
437
+ text-shadow: 2px 2px 8px rgba(0,0,0,0.4);
438
  letter-spacing: -1px;
439
  }
440
 
 
447
  font-weight: 300;
448
  }
449
 
450
+ /* Feature Cards - Dark */
451
  .feature-card {
452
+ background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
453
  padding: 25px;
454
  border-radius: 15px;
455
+ box-shadow: 0 8px 25px rgba(0,0,0,0.4);
456
  margin-bottom: 20px;
457
+ border: 1px solid rgba(102, 126, 234, 0.3);
458
  transition: all 0.3s ease;
459
  }
460
 
461
  .feature-card:hover {
462
  transform: translateY(-3px);
463
+ box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
464
+ border-color: rgba(102, 126, 234, 0.6);
465
  }
466
 
467
  /* Input Controls Section */
468
  .input-controls {
469
+ background: linear-gradient(135deg, #1a1a2e 0%, #252545 100%);
470
  padding: 30px;
471
  border-radius: 15px;
472
+ box-shadow: 0 5px 20px rgba(0,0,0,0.5);
473
+ border: 1px solid rgba(102, 126, 234, 0.2);
474
  }
475
 
476
  /* Output Section */
477
  .output-section {
478
+ background: linear-gradient(135deg, #2d1b3d 0%, #3d2952 100%);
479
  padding: 30px;
480
  border-radius: 15px;
481
+ box-shadow: 0 5px 20px rgba(0,0,0,0.5);
482
+ border: 1px solid rgba(118, 75, 162, 0.3);
483
  }
484
 
485
  /* Section Headers */
486
  .section-header {
487
+ color: #a78bfa;
488
  font-size: 1.8em;
489
  font-weight: 700;
490
  margin: 30px 0 20px 0;
491
  text-align: center;
492
+ text-shadow: 0 0 20px rgba(167, 139, 250, 0.5);
 
 
 
493
  }
494
 
495
  /* Process Button */
 
500
  font-weight: 700 !important;
501
  padding: 20px 50px !important;
502
  border-radius: 50px !important;
503
+ box-shadow: 0 10px 40px rgba(102, 126, 234, 0.7) !important;
504
  transition: all 0.3s ease !important;
505
+ color: #ffffff !important;
506
  text-transform: uppercase;
507
  letter-spacing: 1px;
508
  }
509
 
510
  .process-button:hover {
511
  transform: translateY(-3px) scale(1.02) !important;
512
+ box-shadow: 0 15px 50px rgba(102, 126, 234, 0.9) !important;
513
  }
514
 
515
  /* Audio Components */
516
  .audio-wrapper {
517
+ background: linear-gradient(135deg, #1e1e2e 0%, #2a2a40 100%);
518
  padding: 20px;
519
  border-radius: 12px;
520
+ box-shadow: 0 3px 12px rgba(0,0,0,0.6);
521
  margin: 15px 0;
522
+ border: 1px solid rgba(102, 126, 234, 0.2);
523
  }
524
 
525
  /* Tabs */
 
528
  font-size: 1.1em !important;
529
  padding: 12px 24px !important;
530
  border-radius: 10px 10px 0 0 !important;
531
+ background: #1a1a2e !important;
532
+ color: #a0a0b0 !important;
533
+ border: 1px solid rgba(102, 126, 234, 0.2) !important;
534
  }
535
 
536
  .tab-nav button[aria-selected="true"] {
537
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
538
+ color: #ffffff !important;
539
  }
540
 
541
  /* Info Box */
542
  .info-box {
543
+ background: linear-gradient(135deg, #1e1e3f 0%, #2d2d52 100%);
544
  padding: 25px;
545
  border-radius: 15px;
546
  margin: 25px 0;
547
  border-left: 5px solid #667eea;
548
+ box-shadow: 0 4px 20px rgba(0,0,0,0.5);
549
  }
550
 
551
  .info-box h3 {
552
+ color: #a78bfa;
553
  font-size: 1.4em;
554
  font-weight: 700;
555
  margin-top: 0;
556
  }
557
 
558
+ .info-box p, .info-box ul, .info-box li {
559
+ color: #c0c0d0;
560
+ }
561
+
562
  .info-box ul {
563
  margin: 10px 0;
564
  padding-left: 25px;
 
571
 
572
  /* Examples Section */
573
  .examples-section {
574
+ background: linear-gradient(135deg, #2a2a3e 0%, #35354f 100%);
575
  padding: 25px;
576
  border-radius: 15px;
577
  margin-top: 30px;
578
+ box-shadow: 0 4px 20px rgba(0,0,0,0.5);
579
+ border: 1px solid rgba(102, 126, 234, 0.2);
580
  }
581
 
582
  /* Footer */
 
586
  margin-top: 50px;
587
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
588
  border-radius: 15px;
589
+ color: #ffffff;
590
+ box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
591
  }
592
 
593
  #footer h3 {
 
598
 
599
  #footer p {
600
  margin: 5px 0;
601
+ opacity: 0.95;
602
  }
603
 
604
  /* Radio Buttons */
 
607
  border-radius: 10px !important;
608
  font-weight: 600 !important;
609
  transition: all 0.3s ease !important;
610
+ background: #1a1a2e !important;
611
+ color: #b0b0c0 !important;
612
+ border: 1px solid rgba(102, 126, 234, 0.3) !important;
613
+ }
614
+
615
+ .radio-group label:hover {
616
+ background: #252545 !important;
617
+ border-color: rgba(102, 126, 234, 0.6) !important;
618
  }
619
 
620
  /* Dropdowns */
 
622
  border-radius: 10px !important;
623
  padding: 12px !important;
624
  font-size: 1.05em !important;
625
+ background: #1a1a2e !important;
626
+ color: #c0c0d0 !important;
627
+ border: 2px solid rgba(102, 126, 234, 0.3) !important;
628
  transition: all 0.3s ease !important;
629
  }
630
 
631
  .dropdown select:focus {
632
  border-color: #667eea !important;
633
+ box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3) !important;
634
+ }
635
+
636
+ /* Labels and Text */
637
+ label, .label {
638
+ color: #b0b0c0 !important;
639
+ }
640
+
641
+ /* Markdown Text */
642
+ .markdown-text, .prose {
643
+ color: #c0c0d0 !important;
644
+ }
645
+
646
+ /* Input Fields */
647
+ input, textarea {
648
+ background: #1a1a2e !important;
649
+ color: #c0c0d0 !important;
650
+ border: 1px solid rgba(102, 126, 234, 0.3) !important;
651
+ }
652
+
653
+ /* Scrollbars */
654
+ ::-webkit-scrollbar {
655
+ width: 10px;
656
+ background: #1a1a2e;
657
+ }
658
+
659
+ ::-webkit-scrollbar-thumb {
660
+ background: linear-gradient(135deg, #667eea, #764ba2);
661
+ border-radius: 5px;
662
+ }
663
+
664
+ ::-webkit-scrollbar-thumb:hover {
665
+ background: linear-gradient(135deg, #764ba2, #667eea);
666
  }
667
  """
668
 
 
670
  # Gradio Interface
671
  # ============================================================================
672
 
673
+ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
674
 
675
  # Hero Section
676
  gr.HTML("""
 
747
  elem_classes="dropdown"
748
  )
749
 
750
+
751
+
752
  process_btn = gr.Button(
753
  "🚀 Denoise Audio",
754
  elem_classes="process-button",