Vansh Chugh commited on
Commit
f910f14
·
1 Parent(s): 41c1e2b

cleanup: fix fidelity comment, rename opaque var, drop MMT-repo reference

Browse files
Files changed (2) hide show
  1. .gitignore +0 -1
  2. app.py +7 -5
.gitignore CHANGED
@@ -2,5 +2,4 @@ __pycache__/
2
  *.pyc
3
  .DS_Store
4
  .venv/
5
- MMT-repo/
6
  _outputs/
 
2
  *.pyc
3
  .DS_Store
4
  .venv/
 
5
  _outputs/
app.py CHANGED
@@ -49,7 +49,7 @@ def load_model():
49
  """Build the model on CPU and load the sod/ape checkpoint weights. Stays on
50
  CPU here even if GPU hardware is available -- ZeroGPU only allows touching
51
  CUDA from inside an @spaces.GPU call, not at module load time."""
52
- m = music_x_transformers.MusicXTransformer(
53
  dim=train_args["dim"],
54
  encoding=encoding,
55
  depth=train_args["layers"],
@@ -65,9 +65,9 @@ def load_model():
65
  state_dict = torch.load(
66
  CKPT_DIR / "checkpoints" / "best_model.pt", map_location="cpu"
67
  )
68
- m.load_state_dict(state_dict)
69
- m.eval()
70
- return m
71
 
72
 
73
  # Checkpoint is small (~80MB) and lives in the Space repo, so load it
@@ -224,7 +224,9 @@ def process_fn(input_midi_path, instruments_text, generation_length, temperature
224
  audio_path = None
225
  if render_audio:
226
  audio_path = get_default_path(ext=".wav")
227
- music.write(audio_path) # uses the MuseScore General soundfont muspy fetches on first use
 
 
228
 
229
  report_path = get_default_path(ext=".txt")
230
  Path(report_path).write_text(f"{report_name}\n\nInstrument Matching\n{instrument_note}\n")
 
49
  """Build the model on CPU and load the sod/ape checkpoint weights. Stays on
50
  CPU here even if GPU hardware is available -- ZeroGPU only allows touching
51
  CUDA from inside an @spaces.GPU call, not at module load time."""
52
+ model = music_x_transformers.MusicXTransformer(
53
  dim=train_args["dim"],
54
  encoding=encoding,
55
  depth=train_args["layers"],
 
65
  state_dict = torch.load(
66
  CKPT_DIR / "checkpoints" / "best_model.pt", map_location="cpu"
67
  )
68
+ model.load_state_dict(state_dict)
69
+ model.eval()
70
+ return model
71
 
72
 
73
  # Checkpoint is small (~80MB) and lives in the Space repo, so load it
 
224
  audio_path = None
225
  if render_audio:
226
  audio_path = get_default_path(ext=".wav")
227
+ # Uses the MuseScore General soundfont muspy fetches on first use. The original repo's
228
+ # polyphony option isn't supported by muspy==0.5.0's write_audio() (no passthrough kwarg).
229
+ music.write(audio_path)
230
 
231
  report_path = get_default_path(ext=".txt")
232
  Path(report_path).write_text(f"{report_name}\n\nInstrument Matching\n{instrument_note}\n")