admin commited on
Commit
1104333
Β·
1 Parent(s): 17d9fd3

add tutorial

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -55,8 +55,7 @@ def get_args(parser: argparse.ArgumentParser):
55
  default=1.2,
56
  help="the temperature of the sampling operation",
57
  )
58
- parser.add_argument("-seed", type=int, default=None,
59
- help="seed for randomstate")
60
  parser.add_argument(
61
  "-show_control_code",
62
  type=bool,
@@ -150,10 +149,9 @@ def generate_music(
150
 
151
  else:
152
  prefix = patchilizer.decode(input_patches[0])
153
- remaining_tokens = prompt[len(prefix):]
154
  tokens = torch.tensor(
155
- [patchilizer.bos_token_id] +
156
- [ord(c) for c in remaining_tokens],
157
  device=DEVICE,
158
  )
159
 
@@ -224,8 +222,7 @@ def generate_music(
224
  tunes = tunes.replace(f"\nK:{K_val}\n", f"\nK:{K_val.split('m')[0]}\n")
225
 
226
  elif (mode == "minor") and (not "m" in K_val):
227
- tunes = tunes.replace(
228
- f"\nK:{K_val}\n", f"\nK:{K_val.replace('dor', '')}min\n")
229
 
230
  print("Generation time: {:.2f} seconds".format(time.time() - start_time))
231
  timestamp = time.strftime("%a_%d_%b_%Y_%H_%M_%S", time.localtime())
@@ -402,7 +399,8 @@ if __name__ == "__main__":
402
 
403
  with gr.Blocks() as demo:
404
  gr.Markdown(
405
- "## The current CPU-based version on HuggingFace has slow inference, you can access the GPU-based mirror on [ModelScope](https://www.modelscope.cn/studios/monetjoe/EMusicGen)")
 
406
  with gr.Row():
407
  with gr.Column():
408
  dataset_option = gr.Dropdown(
@@ -411,7 +409,7 @@ if __name__ == "__main__":
411
  value="Rough4Q",
412
  )
413
  gr.Markdown(
414
- "# Generate by emotion condition<br><img width='100%' src='https://www.modelscope.cn/studio/monetjoe/EMusicGen/resolve/master/4q.jpg'>"
415
  )
416
  valence_radio = gr.Radio(
417
  ["Low", "High"],
@@ -488,6 +486,11 @@ url = {https://github.com/monetjoe/EMusicGen}
488
  )
489
 
490
  with gr.Column():
 
 
 
 
 
491
  wav_audio = gr.Audio(label="Audio", type="filepath")
492
  midi_file = gr.File(label="Download MIDI")
493
  pdf_file = gr.File(label="Download PDF score")
 
55
  default=1.2,
56
  help="the temperature of the sampling operation",
57
  )
58
+ parser.add_argument("-seed", type=int, default=None, help="seed for randomstate")
 
59
  parser.add_argument(
60
  "-show_control_code",
61
  type=bool,
 
149
 
150
  else:
151
  prefix = patchilizer.decode(input_patches[0])
152
+ remaining_tokens = prompt[len(prefix) :]
153
  tokens = torch.tensor(
154
+ [patchilizer.bos_token_id] + [ord(c) for c in remaining_tokens],
 
155
  device=DEVICE,
156
  )
157
 
 
222
  tunes = tunes.replace(f"\nK:{K_val}\n", f"\nK:{K_val.split('m')[0]}\n")
223
 
224
  elif (mode == "minor") and (not "m" in K_val):
225
+ tunes = tunes.replace(f"\nK:{K_val}\n", f"\nK:{K_val.replace('dor', '')}min\n")
 
226
 
227
  print("Generation time: {:.2f} seconds".format(time.time() - start_time))
228
  timestamp = time.strftime("%a_%d_%b_%Y_%H_%M_%S", time.localtime())
 
399
 
400
  with gr.Blocks() as demo:
401
  gr.Markdown(
402
+ "## The current CPU-based version on HuggingFace has slow inference, you can access the GPU-based mirror on [ModelScope](https://www.modelscope.cn/studios/monetjoe/EMusicGen)"
403
+ )
404
  with gr.Row():
405
  with gr.Column():
406
  dataset_option = gr.Dropdown(
 
409
  value="Rough4Q",
410
  )
411
  gr.Markdown(
412
+ "# Generate by emotion condition<br><img width='100%' src='https://www.modelscope.cn/studio/monetjoe/EMusicGen/resolve/master/src/4q.jpg'>"
413
  )
414
  valence_radio = gr.Radio(
415
  ["Low", "High"],
 
486
  )
487
 
488
  with gr.Column():
489
+ gr.Markdown(
490
+ """## Tutorial
491
+ <video src='https://www.modelscope.cn/studio/monetjoe/EMusicGen/resolve/master/src/tutorial.mp4' controls></video>
492
+ """
493
+ )
494
  wav_audio = gr.Audio(label="Audio", type="filepath")
495
  midi_file = gr.File(label="Download MIDI")
496
  pdf_file = gr.File(label="Download PDF score")