harrytarlton commited on
Commit
943c30d
Β·
1 Parent(s): 4170f4a

models and buttons

Browse files
app.py CHANGED
@@ -232,20 +232,26 @@ class NAMProcessor:
232
  def get_model_choices(self):
233
  """Get model choices for dropdown"""
234
  if not self.models:
235
- return ["No models found - Add cloud models below"]
 
 
 
236
 
237
  choices = []
238
 
239
- # Add local models
240
  local_models = [name for name, info in self.models.items() if info.get('source') == 'local']
241
  if local_models:
242
- choices.append("━━━ πŸ“ Local Models ━━━")
243
  choices.extend(sorted(local_models))
244
 
245
  # Add cloud models
246
  cloud_models = [name for name, info in self.models.items() if info.get('source') == 'cloud']
247
  if cloud_models:
248
- choices.append("━━━ ☁️ Cloud Models ━━━")
 
 
 
249
  choices.extend(sorted(cloud_models))
250
 
251
  return choices if choices else ["No models found"]
@@ -363,6 +369,8 @@ class NAMProcessor:
363
 
364
  # Initialize processor
365
  processor = NAMProcessor()
 
 
366
 
367
  # ========== CUSTOM CSS ==========
368
 
@@ -605,6 +613,23 @@ let selectedProcessedFile = null;
605
  let inputFiles = [];
606
  let processedFiles = [];
607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  function selectFile(type, index) {
609
  if (type === 'input') {
610
  document.querySelectorAll('#input-file-list .file-item').forEach(item => {
@@ -668,13 +693,27 @@ function updateWaveformForFile(fileInfo) {
668
 
669
  function saveSelectedFile() {
670
  if (selectedProcessedFile !== null && processedFiles[selectedProcessedFile]) {
671
- console.log('Saving:', processedFiles[selectedProcessedFile].name);
 
 
 
 
 
 
 
672
  }
673
  }
674
 
675
  function saveAllFiles() {
676
  if (processedFiles.length > 0) {
677
- console.log('Saving all processed files');
 
 
 
 
 
 
 
678
  }
679
  }
680
 
@@ -738,8 +777,8 @@ def create_input_file_html(files):
738
  <div class='file-panel-header'>
739
  <span style='font-size: 20px; font-weight: 600;'>Input Files</span>
740
  <div style='margin-left: auto; display: flex; gap: 8px;'>
741
- <button onclick='document.getElementById("import-btn-trigger").click()' style='
742
- background: linear-gradient(135deg, #4ecdc4 0%, #44a3aa 100%);
743
  border: none;
744
  color: #fff;
745
  padding: 8px 16px;
@@ -755,7 +794,21 @@ def create_input_file_html(files):
755
  {file_items_html}
756
  </div>
757
  </div>
758
- <script>inputFiles = {json.dumps(file_data)};</script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
  """
760
 
761
  def create_processed_file_html(files):
@@ -967,14 +1020,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
967
  elem_classes="file-panel-container"
968
  )
969
 
970
- # Hidden upload button (triggered by the Import button in the header)
971
- upload_btn = gr.Button(
972
- "Import",
973
- elem_id="import-btn-trigger",
974
- visible=False
975
- )
976
-
977
- # File upload (hidden)
978
  file_upload = gr.File(
979
  label="Upload Audio Files",
980
  file_count="multiple",
@@ -991,9 +1037,17 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
991
 
992
  # Profile/IR Selection
993
  with gr.Group(elem_classes="control-group"):
 
 
 
 
 
 
 
 
994
  model_dropdown = gr.Dropdown(
995
- choices=processor.get_model_choices(),
996
- value=processor.get_model_choices()[0] if processor.get_model_choices() else None,
997
  label="Select Profile/IR",
998
  container=False
999
  )
@@ -1001,7 +1055,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
1001
  # Cloud model loading section
1002
  with gr.Accordion("☁️ Load Cloud Models", open=False):
1003
  gr.Markdown("""
1004
- **Supported formats:**
1005
  - Direct `.nam` file URLs
1006
  - Google Drive links
1007
  - Dropbox links
@@ -1093,7 +1147,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
1093
  # Download button
1094
  download_btn = gr.Button(
1095
  "πŸ’Ύ Download Processed",
1096
- visible=False
 
1097
  )
1098
 
1099
  download_file = gr.File(
@@ -1169,11 +1224,6 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
1169
  return gr.update(choices=processor.get_model_choices()), "πŸ—‘ Cleared all cloud models"
1170
 
1171
  # Connect events
1172
- upload_btn.click(
1173
- lambda: gr.update(visible=True),
1174
- outputs=file_upload
1175
- )
1176
-
1177
  file_upload.change(
1178
  fn=handle_upload,
1179
  inputs=[file_upload],
 
232
  def get_model_choices(self):
233
  """Get model choices for dropdown"""
234
  if not self.models:
235
+ # Try loading again in case models weren't loaded
236
+ self.load_available_models()
237
+ if not self.models:
238
+ return ["No models found - Add cloud models below"]
239
 
240
  choices = []
241
 
242
+ # Add local models first
243
  local_models = [name for name, info in self.models.items() if info.get('source') == 'local']
244
  if local_models:
245
+ choices.append("━━━ 🎸 Pre-loaded Models ━━━")
246
  choices.extend(sorted(local_models))
247
 
248
  # Add cloud models
249
  cloud_models = [name for name, info in self.models.items() if info.get('source') == 'cloud']
250
  if cloud_models:
251
+ if local_models: # Add separator only if there are local models
252
+ choices.append("━━━ ☁️ Cloud Models ━━━")
253
+ else:
254
+ choices.append("━━━ ☁️ Cloud Models ━━━")
255
  choices.extend(sorted(cloud_models))
256
 
257
  return choices if choices else ["No models found"]
 
369
 
370
  # Initialize processor
371
  processor = NAMProcessor()
372
+ print(f"\nβœ… Loaded {len([m for m in processor.models.values() if m.get('source') == 'local'])} pre-loaded NAM models")
373
+ print(f"Available models: {list(processor.models.keys())}\n")
374
 
375
  # ========== CUSTOM CSS ==========
376
 
 
613
  let inputFiles = [];
614
  let processedFiles = [];
615
 
616
+ // Wait for DOM to be ready
617
+ window.addEventListener('DOMContentLoaded', (event) => {
618
+ // Setup Import button click handler
619
+ setTimeout(() => {
620
+ const importBtn = document.getElementById('import-btn-header');
621
+ if (importBtn) {
622
+ importBtn.addEventListener('click', () => {
623
+ // Click the hidden Gradio file input
624
+ const fileInput = document.querySelector('#file-upload input[type="file"]');
625
+ if (fileInput) {
626
+ fileInput.click();
627
+ }
628
+ });
629
+ }
630
+ }, 1000);
631
+ });
632
+
633
  function selectFile(type, index) {
634
  if (type === 'input') {
635
  document.querySelectorAll('#input-file-list .file-item').forEach(item => {
 
693
 
694
  function saveSelectedFile() {
695
  if (selectedProcessedFile !== null && processedFiles[selectedProcessedFile]) {
696
+ console.log('Exporting:', processedFiles[selectedProcessedFile].name);
697
+ // Trigger the download button in Gradio
698
+ const downloadBtn = document.querySelector('#download-btn button');
699
+ if (downloadBtn) {
700
+ downloadBtn.click();
701
+ }
702
+ } else {
703
+ alert('Please select a processed file to export');
704
  }
705
  }
706
 
707
  function saveAllFiles() {
708
  if (processedFiles.length > 0) {
709
+ console.log('Exporting all processed files');
710
+ // Trigger the download button in Gradio
711
+ const downloadBtn = document.querySelector('#download-btn button');
712
+ if (downloadBtn) {
713
+ downloadBtn.click();
714
+ }
715
+ } else {
716
+ alert('No processed files to export');
717
  }
718
  }
719
 
 
777
  <div class='file-panel-header'>
778
  <span style='font-size: 20px; font-weight: 600;'>Input Files</span>
779
  <div style='margin-left: auto; display: flex; gap: 8px;'>
780
+ <button id='import-btn-header' style='
781
+ background: linear-gradient(135deg, #ff6b6b 0%, #ee5a50 100%);
782
  border: none;
783
  color: #fff;
784
  padding: 8px 16px;
 
794
  {file_items_html}
795
  </div>
796
  </div>
797
+ <script>
798
+ inputFiles = {json.dumps(file_data)};
799
+ // Re-attach the click handler after HTML update
800
+ setTimeout(() => {{
801
+ const importBtn = document.getElementById('import-btn-header');
802
+ if (importBtn) {{
803
+ importBtn.onclick = () => {{
804
+ const fileInput = document.querySelector('#file-upload input[type="file"]');
805
+ if (fileInput) {{
806
+ fileInput.click();
807
+ }}
808
+ }};
809
+ }}
810
+ }}, 100);
811
+ </script>
812
  """
813
 
814
  def create_processed_file_html(files):
 
1020
  elem_classes="file-panel-container"
1021
  )
1022
 
1023
+ # File upload (hidden but accessible)
 
 
 
 
 
 
 
1024
  file_upload = gr.File(
1025
  label="Upload Audio Files",
1026
  file_count="multiple",
 
1037
 
1038
  # Profile/IR Selection
1039
  with gr.Group(elem_classes="control-group"):
1040
+ model_choices = processor.get_model_choices()
1041
+ # Select first non-header model if available
1042
+ default_model = None
1043
+ for choice in model_choices:
1044
+ if choice and "━━━" not in choice:
1045
+ default_model = choice
1046
+ break
1047
+
1048
  model_dropdown = gr.Dropdown(
1049
+ choices=model_choices,
1050
+ value=default_model,
1051
  label="Select Profile/IR",
1052
  container=False
1053
  )
 
1055
  # Cloud model loading section
1056
  with gr.Accordion("☁️ Load Cloud Models", open=False):
1057
  gr.Markdown("""
1058
+ **Add your own NAM models from cloud storage:**
1059
  - Direct `.nam` file URLs
1060
  - Google Drive links
1061
  - Dropbox links
 
1147
  # Download button
1148
  download_btn = gr.Button(
1149
  "πŸ’Ύ Download Processed",
1150
+ visible=False,
1151
+ elem_id="download-btn"
1152
  )
1153
 
1154
  download_file = gr.File(
 
1224
  return gr.update(choices=processor.get_model_choices()), "πŸ—‘ Cleared all cloud models"
1225
 
1226
  # Connect events
 
 
 
 
 
1227
  file_upload.change(
1228
  fn=handle_upload,
1229
  inputs=[file_upload],
models/1073MP - 40 dB - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 40 dB - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 50 dB - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 50 dB - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 60 dB - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 60 dB - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 60 dB Hard - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 60 dB Hard - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 70 dB - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 70 dB - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 70 dB Hard - A.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/1073MP - 70 dB Hard - B.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/Acoustic Guitar.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/SWR INTERSTELLAR.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/SWR OD.nam ADDED
The diff for this file is too large to render. See raw diff
 
models/lstm.nam ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 44, "second": 41}, "loudness": -37.8406867980957, "gain": 0.13508800804658277, "name": "Test LSTM", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": null}}, "architecture": "LSTM", "config": {"input_size": 1, "hidden_size": 3, "num_layers": 1}, "weights": [-0.21677088737487793, -0.6683622002601624, -0.2560940980911255, -0.3588429093360901, 0.17952610552310944, 0.19445613026618958, -0.01662646047770977, 0.5353694558143616, -0.2536540627479553, -0.5132213234901428, -0.020476307719945908, 0.08592455089092255, -0.6891753673553467, 0.3627359867095947, 0.008421811275184155, 0.3113192617893219, 0.14251480996608734, 0.07989779114723206, -0.18211324512958527, 0.7118963003158569, 0.41084015369415283, -0.6571938395500183, -0.13214066624641418, -0.2698603868484497, 0.49387243390083313, -0.3491725027561188, 0.6353667974472046, -0.5005152225494385, 0.2052856683731079, -0.4301638901233673, -0.15770092606544495, -0.7181791067123413, 0.056290093809366226, -0.49049463868141174, 0.6623441576957703, 0.09029324352741241, 0.34005245566368103, 0.16416560113430023, 0.15520110726356506, -0.4155678153038025, -0.36928507685661316, 0.3211132884025574, -0.6769840121269226, -0.1575538069009781, 0.05268515646457672, -0.4191459119319916, 0.599330484867096, 0.21518059074878693, -4.246325492858887, -3.315647840499878, -4.328850746154785, 4.496089458465576, 5.015639305114746, 3.6492037773132324, 0.14431169629096985, -0.6633821725845337, 0.11673200130462646, -0.1418764889240265, -0.4897872805595398, -0.8689419031143188, -0.06714004278182983, -0.4450395107269287, -0.02142983116209507, -0.15136894583702087, -2.775207996368408, -0.08681213855743408, 0.05702732503414154, 0.670292317867279, 0.31442636251449585, 0.30793967843055725], "sample_rate": 48000}
models/wavenet.nam ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version": "0.5.4", "metadata": {"date": {"year": 2024, "month": 10, "day": 9, "hour": 18, "minute": 32, "second": 27}, "loudness": -20.020729064941406, "gain": 0.19575619747898518, "name": "Test Model", "modeled_by": "Steve", "gear_type": "amp", "gear_make": "Darkglass Electronics", "gear_model": "Microtubes 900 v2", "tone_type": "clean", "input_level_dbu": 18.3, "output_level_dbu": 12.3, "training": {"settings": {"ignore_checks": false}, "data": {"latency": {"manual": null, "calibration": {"algorithm_version": 1, "delays": [-16], "safety_factor": 1, "recommended": -17, "warnings": {"matches_lookahead": false, "disagreement_too_high": false}}}, "checks": {"version": 3, "passed": true}}, "validation_esr": 0.13345033695550146}}, "architecture": "WaveNet", "config": {"layers": [{"input_size": 1, "condition_size": 1, "head_size": 2, "channels": 3, "kernel_size": 3, "dilations": [1, 2], "activation": "Tanh", "gated": false, "head_bias": false}, {"input_size": 3, "condition_size": 1, "head_size": 1, "channels": 2, "kernel_size": 3, "dilations": [8], "activation": "Tanh", "gated": false, "head_bias": true}], "head": null, "head_scale": 0.02}, "weights": [-0.6180188059806824, 1.0314024686813354, -1.0111560821533203, -0.38462021946907043, 0.35968291759490967, 0.5255971550941467, 0.19149275124073029, -0.18075695633888245, -0.33711034059524536, -0.21037575602531433, 0.2007753700017929, 0.21644853055477142, -1.3216396570205688, -0.35082393884658813, 0.43541353940963745, 0.9693092107772827, 0.2394428700208664, -0.41078877449035645, -1.193748116493225, -0.14876757562160492, 0.8413559198379517, 0.24491633474826813, 0.8857091665267944, 0.5647665858268738, 0.08301573246717453, -0.801490843296051, 0.168976828455925, -0.5413634181022644, 0.484220415353775, 0.021656272932887077, -0.15155009925365448, 0.07081033289432526, 0.00019397131109144539, -0.7408013939857483, -1.3308452367782593, -1.0403972864151, 0.016809873282909393, 0.6778652667999268, 0.28265541791915894, -0.28287461400032043, 1.0525944232940674, -0.6385797262191772, -0.2195468544960022, -0.3150196671485901, -0.8814508318901062, -0.2746180295944214, 0.15367186069488525, 0.22431065142154694, -0.056788790971040726, -0.38902369141578674, 0.5406259894371033, 0.3566059470176697, 0.14383991062641144, -0.25409433245658875, 0.16139137744903564, -0.05857989564538002, -0.18448838591575623, -0.253485769033432, -0.42405444383621216, -0.030114537104964256, 0.47283637523651123, 0.14930365979671478, -0.4410354793071747, -0.21976807713508606, -0.12736600637435913, -0.5674286484718323, -0.347588449716568, -0.3687525689601898, 0.4130803942680359, 0.8551775217056274, -0.05746064335107803, -0.38243237137794495, 0.20036561787128448, 0.25542038679122925, -0.0819990262389183, 0.19469600915908813, 0.10215214639902115, -0.26087674498558044, -0.1773151010274887, -0.09658292680978775, -0.7381710410118103, 0.7003506422042847, 0.7253592014312744, -0.07488955557346344, -0.23439547419548035, -0.5138604044914246, -0.7976311445236206, -0.8090851902961731, -0.37562188506126404, -1.163352131843567, 0.30907657742500305, 0.0564480796456337, 0.1190297082066536, 0.2310808300971985, -0.45360898971557617, -0.11524498462677002, 0.2552330493927002, 0.2913571298122406, -0.23171702027320862, -0.35578709840774536, 0.40732908248901367, 0.7458747029304504, 0.27514976263046265, -0.7503036856651306, -0.6707972884178162, -0.4248569905757904, -0.1671624332666397, -0.14162226021289825, 0.37550851702690125, -0.038120146840810776, 0.16232982277870178, -0.05173371359705925, -0.2842361629009247, 0.38820165395736694, 0.521754801273346, -0.3581869900226593, 0.21531476080417633, 0.11342520266771317, 0.01764630153775215, 0.07780527323484421, 0.9356631636619568, 0.04235581308603287, -0.3450177311897278, 0.3345951437950134, -0.678291380405426, -0.4191069006919861, -0.1770099401473999, -5.386871337890625, -5.130850791931152, -0.4049331247806549, 0.019999999552965164], "sample_rate": 48000}