Fabrice-TIERCELIN commited on
Commit
049b1c4
·
verified ·
1 Parent(s): 1da2419

Restore interrupt

Browse files
Files changed (1) hide show
  1. demos/musicgen_app.py +12 -9
demos/musicgen_app.py CHANGED
@@ -55,6 +55,7 @@ pool.__enter__()
55
 
56
 
57
  def interrupt():
 
58
  INTERRUPTING = True
59
 
60
 
@@ -178,6 +179,7 @@ def predict_batched(texts, melodies):
178
 
179
 
180
  def predict_full(model, model_path, decoder, text, melody, duration, topk, topp, temperature, cfg_coef, progress=gr.Progress()):
 
181
  global USE_DIFFUSION
182
  INTERRUPTING = False
183
  progress(0, desc="Loading model...")
@@ -257,23 +259,23 @@ def ui_full(launch_kwargs):
257
  with gr.Row():
258
  with gr.Column():
259
  with gr.Row():
260
- text = gr.Text(label="Input Text", placeholder="Describe your music here", interactive=True, autofocus = True)
261
  with gr.Column():
262
- radio = gr.Radio(["file", "mic"], value="file",
263
  label="Condition on a melody (optional) File or Microphone")
264
- melody = gr.Audio(source="upload", type="numpy", label="File",
265
- interactive=True, elem_id="melody-input")
266
  with gr.Row():
267
  duration = gr.Slider(label = "Duration", info = "(in seconds)", minimum = 1, maximum = 120, value = 30, interactive = True)
268
  with gr.Accordion("Advanced options", open = False):
269
  with gr.Row():
270
- topk = gr.Number(label="Top-k", info = "Number of tokens shortlisted", value = 250, interactive = True)
271
- topp = gr.Number(label="Top-p", info = "Percent of tokens shortlisted", value = 0, interactive = True)
272
- temperature = gr.Number(label="Temperature", info = "lower=Always similar, higher=More creative", value = 1.0, interactive = True)
273
- cfg_coef = gr.Number(label="Classifier-Free Guidance", info = "lower=Audio quality, higher=Follow the prompt", value = 3.0, interactive=True)
274
  with gr.Row():
275
  decoder = gr.Radio(["Default", "MultiBand_Diffusion"],
276
- label="Decoder", value="Default", interactive=True)
277
  with gr.Row():
278
  model = gr.Radio(["facebook/musicgen-melody", "facebook/musicgen-medium", "facebook/musicgen-small",
279
  "facebook/musicgen-large",
@@ -288,6 +290,7 @@ def ui_full(launch_kwargs):
288
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
289
  _ = gr.Button("Abort all", variant="stop").click(fn=interrupt, queue = False)
290
  with gr.Column():
 
291
  output = gr.Video(label="Generated Music", autoplay = True)
292
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath', show_download_button = True)
293
  diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")
 
55
 
56
 
57
  def interrupt():
58
+ global INTERRUPTING
59
  INTERRUPTING = True
60
 
61
 
 
179
 
180
 
181
  def predict_full(model, model_path, decoder, text, melody, duration, topk, topp, temperature, cfg_coef, progress=gr.Progress()):
182
+ global INTERRUPTING
183
  global USE_DIFFUSION
184
  INTERRUPTING = False
185
  progress(0, desc="Loading model...")
 
259
  with gr.Row():
260
  with gr.Column():
261
  with gr.Row():
262
+ text = gr.Text(label = "Input Text", placeholder = "Describe your music here", interactive = True, autofocus = True)
263
  with gr.Column():
264
+ radio = gr.Radio(["file", "mic"], value = "file",
265
  label="Condition on a melody (optional) File or Microphone")
266
+ melody = gr.Audio(source = "upload", type = "numpy", label = "File",
267
+ interactive = True, elem_id="melody-input")
268
  with gr.Row():
269
  duration = gr.Slider(label = "Duration", info = "(in seconds)", minimum = 1, maximum = 120, value = 30, interactive = True)
270
  with gr.Accordion("Advanced options", open = False):
271
  with gr.Row():
272
+ topk = gr.Number(label = "Top-k", info = "Number of tokens shortlisted", value = 250, interactive = True)
273
+ topp = gr.Number(label = "Top-p", info = "Percent of tokens shortlisted", value = 0, interactive = True)
274
+ temperature = gr.Number(label = "Temperature", info = "lower=Always similar, higher=More creative", value = 1.0, interactive = True)
275
+ cfg_coef = gr.Number(label = "Classifier-Free Guidance", info = "lower=Audio quality, higher=Follow the prompt", value = 3.0, interactive = True)
276
  with gr.Row():
277
  decoder = gr.Radio(["Default", "MultiBand_Diffusion"],
278
+ label = "Decoder", value = "Default", interactive = True)
279
  with gr.Row():
280
  model = gr.Radio(["facebook/musicgen-melody", "facebook/musicgen-medium", "facebook/musicgen-small",
281
  "facebook/musicgen-large",
 
290
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
291
  _ = gr.Button("Abort all", variant="stop").click(fn=interrupt, queue = False)
292
  with gr.Column():
293
+ output_hint = gr.Label("To download the output, right-click and click on Save as...")
294
  output = gr.Video(label="Generated Music", autoplay = True)
295
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath', show_download_button = True)
296
  diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")