jfforero commited on
Commit
9b34f1a
·
verified ·
1 Parent(s): f469004

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -59
app.py CHANGED
@@ -514,7 +514,7 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
514
  else:
515
  audio_data_list.append(None) # Placeholder for chunks without audio
516
 
517
- # Create the HTML content with a more prominent download button
518
  html_content = f"""
519
  <!DOCTYPE html>
520
  <html lang="en">
@@ -599,42 +599,6 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
599
  border-radius: 3px;
600
  border: 1px solid #ccc;
601
  }}
602
- /* Custom styles for the download button */
603
- .download-container {{
604
- position: absolute;
605
- top: 10px;
606
- right: 10px;
607
- z-index: 1000;
608
- background: rgba(0, 0, 0, 0.7);
609
- padding: 15px;
610
- border-radius: 5px;
611
- display: flex;
612
- flex-direction: column;
613
- align-items: center;
614
- }}
615
- .download-button {{
616
- background: #27ae60;
617
- color: white;
618
- border: none;
619
- padding: 15px 25px;
620
- border-radius: 5px;
621
- cursor: pointer;
622
- font-size: 18px;
623
- font-weight: bold;
624
- display: flex;
625
- align-items: center;
626
- gap: 10px;
627
- text-decoration: none;
628
- transition: all 0.3s ease;
629
- }}
630
- .download-button:hover {{
631
- background: #219653;
632
- transform: scale(1.05);
633
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
634
- }}
635
- .download-icon {{
636
- font-size: 24px;
637
- }}
638
  </style>
639
  </head>
640
  <body>
@@ -644,14 +608,6 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
644
  </select>
645
  </div>
646
 
647
- <!-- Download button container -->
648
- <div class="download-container">
649
- <a id="download-link" class="download-button" href="#" download="360_viewer.html">
650
- <span class="download-icon">⬇️</span>
651
- <span>Download Viewer</span>
652
- </a>
653
- </div>
654
-
655
  <div id="panorama"></div>
656
 
657
  <div id="audio-controls">
@@ -701,14 +657,6 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
701
  }}
702
  }}
703
 
704
- // Set up download link
705
- document.getElementById('download-link').addEventListener('click', function() {{
706
- // Create a Blob with the HTML content
707
- const blob = new Blob([document.documentElement.outerHTML], {{ type: 'text/html' }});
708
- const url = URL.createObjectURL(blob);
709
- this.href = url;
710
- }});
711
-
712
  // Load the first image initially
713
  loadPanorama(0);
714
 
@@ -728,6 +676,7 @@ def create_360_viewer_html(image_paths, audio_paths, output_path):
728
 
729
  return output_path
730
 
 
731
  # Update the process_and_display function
732
  def process_and_display(audio_input, generate_audio, chunk_duration):
733
  # Validate chunk duration
@@ -822,6 +771,8 @@ def load_example_audio(example_name):
822
  return None
823
 
824
  # Create the Gradio interface with proper output handling
 
 
825
  with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as interface:
826
  gr.Markdown("# Affective Virtual Environments")
827
  gr.Markdown("Create an AVE using your voice. Audio is split into chunks, with separate predictions and generations for each segment.")
@@ -899,12 +850,47 @@ with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as i
899
  'music': audio_output
900
  })
901
 
902
- # Add component for 360 viewer
903
- viewer_html_output = gr.File(
904
- label="Download 360 Viewer",
905
- type="filepath",
906
- interactive=False
907
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
908
 
909
  # Add a hidden HTML component for JavaScript execution
910
  js_output = gr.HTML(visible=False)
 
514
  else:
515
  audio_data_list.append(None) # Placeholder for chunks without audio
516
 
517
+ # Create the HTML content
518
  html_content = f"""
519
  <!DOCTYPE html>
520
  <html lang="en">
 
599
  border-radius: 3px;
600
  border: 1px solid #ccc;
601
  }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  </style>
603
  </head>
604
  <body>
 
608
  </select>
609
  </div>
610
 
 
 
 
 
 
 
 
 
611
  <div id="panorama"></div>
612
 
613
  <div id="audio-controls">
 
657
  }}
658
  }}
659
 
 
 
 
 
 
 
 
 
660
  // Load the first image initially
661
  loadPanorama(0);
662
 
 
676
 
677
  return output_path
678
 
679
+
680
  # Update the process_and_display function
681
  def process_and_display(audio_input, generate_audio, chunk_duration):
682
  # Validate chunk duration
 
771
  return None
772
 
773
  # Create the Gradio interface with proper output handling
774
+
775
+ # Update the Gradio interface with a more prominent download button
776
  with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as interface:
777
  gr.Markdown("# Affective Virtual Environments")
778
  gr.Markdown("Create an AVE using your voice. Audio is split into chunks, with separate predictions and generations for each segment.")
 
850
  'music': audio_output
851
  })
852
 
853
+ # Add component for 360 viewer with a more prominent download button
854
+ with gr.Group(visible=False) as viewer_group:
855
+ gr.Markdown("### 🎯 360 Viewer Results")
856
+ gr.Markdown("Your interactive 360 viewer is ready! Download the HTML file to view your generated environments in a web browser.")
857
+
858
+ # Create a row with a prominent download button
859
+ with gr.Row():
860
+ viewer_html_output = gr.File(
861
+ label="360 Viewer HTML File",
862
+ type="filepath",
863
+ interactive=False,
864
+ elem_classes=["prominent-download"]
865
+ )
866
+
867
+ # Add a custom CSS class to make the download button more prominent
868
+ gr.HTML("""
869
+ <style>
870
+ .prominent-download .gr-button {
871
+ background: linear-gradient(45deg, #FF3366, #FF9933) !important;
872
+ color: white !important;
873
+ font-size: 18px !important;
874
+ font-weight: bold !important;
875
+ padding: 15px 25px !important;
876
+ border-radius: 8px !important;
877
+ border: none !important;
878
+ box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
879
+ transition: all 0.3s ease !important;
880
+ }
881
+ .prominent-download .gr-button:hover {
882
+ transform: scale(1.05) !important;
883
+ box-shadow: 0 6px 12px rgba(0,0,0,0.3) !important;
884
+ }
885
+ .prominent-download .gr-button:before {
886
+ content: "⬇️ " !important;
887
+ margin-right: 8px !important;
888
+ }
889
+ </style>
890
+ """)
891
+
892
+ # Add the viewer group to the group components
893
+ group_components.append(viewer_group)
894
 
895
  # Add a hidden HTML component for JavaScript execution
896
  js_output = gr.HTML(visible=False)