anthonyrusso commited on
Commit
38b99ff
·
1 Parent(s): d646d8b

clear the ui

Browse files
Files changed (1) hide show
  1. app.py +129 -16
app.py CHANGED
@@ -204,7 +204,11 @@ def ui_full(launch_kwargs):
204
  with gr.Column():
205
  with gr.Row():
206
  text = gr.Text(label="Input Text", interactive=True)
207
-
 
 
 
 
208
  with gr.Row():
209
  submit = gr.Button("Submit")
210
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
@@ -213,32 +217,107 @@ def ui_full(launch_kwargs):
213
  model = gr.Radio(["facebook/musicgen-melody", "facebook/musicgen-medium", "facebook/musicgen-small",
214
  "facebook/musicgen-large"],
215
  label="Model", value="facebook/musicgen-melody", interactive=True)
216
- with gr.Row():
217
- decoder = gr.Radio(["Default", "MultiBand_Diffusion"],
218
- label="Decoder", value="Default", interactive=True)
219
- with gr.Row():
220
- duration = gr.Slider(minimum=1, maximum=120, value=10, label="Duration", interactive=True)
221
- with gr.Row():
222
- topk = gr.Number(label="Top-k", value=250, interactive=True)
223
- topp = gr.Number(label="Top-p", value=0, interactive=True)
224
- temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
225
- cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
 
 
226
  with gr.Column():
227
  output = gr.Video(label="Generated Music")
228
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath')
229
- diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")
230
- audio_diffusion = gr.Audio(label="MultiBand Diffusion Decoder (wav)", type='filepath')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  submit.click(toggle_diffusion, decoder, [diffusion_output, audio_diffusion], queue=False,
232
  show_progress=False).then(predict_full, inputs=[model, decoder, text, melody, duration, topk, topp,
233
  temperature, cfg_coef],
234
  outputs=[output, audio_output, diffusion_output, audio_diffusion])
235
- radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
236
- interface.queue().launch(**launch_kwargs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
 
238
 
239
  def ui_batched(launch_kwargs):
240
  with gr.Blocks() as demo:
241
-
 
 
 
 
242
  with gr.Row():
243
  with gr.Column():
244
  with gr.Row():
@@ -256,6 +335,40 @@ def ui_batched(launch_kwargs):
256
  submit.click(predict_batched, inputs=[text, melody],
257
  outputs=[output, audio_output], batch=True, max_batch_size=MAX_BATCH_SIZE)
258
  radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  demo.queue(max_size=8 * 4).launch(**launch_kwargs)
260
 
261
 
 
204
  with gr.Column():
205
  with gr.Row():
206
  text = gr.Text(label="Input Text", interactive=True)
207
+ # with gr.Column():
208
+ # radio = gr.Radio(["file", "mic"], value="file",
209
+ # label="Condition on a melody (optional) File or Mic")
210
+ # melody = gr.Audio(source="upload", type="numpy", label="File",
211
+ # interactive=True, elem_id="melody-input")
212
  with gr.Row():
213
  submit = gr.Button("Submit")
214
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
 
217
  model = gr.Radio(["facebook/musicgen-melody", "facebook/musicgen-medium", "facebook/musicgen-small",
218
  "facebook/musicgen-large"],
219
  label="Model", value="facebook/musicgen-melody", interactive=True)
220
+ # with gr.Row():
221
+ # decoder = gr.Radio(["Default", "MultiBand_Diffusion"],
222
+ # label="Decoder", value="Default", interactive=True)
223
+ # decoder = "Default"
224
+ # with gr.Row():
225
+ # duration = gr.Slider(minimum=1, maximum=120, value=10, label="Duration", interactive=True)
226
+ # with gr.Row():
227
+ # topk = gr.Number(label="Top-k", value=250, interactive=True)
228
+ # topp = gr.Number(label="Top-p", value=0, interactive=True)
229
+ # temperature = gr.Number(label="Temperature", value=1.0, interactive=True)
230
+ # cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
231
+
232
  with gr.Column():
233
  output = gr.Video(label="Generated Music")
234
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath')
235
+ # diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")
236
+ # audio_diffusion = gr.Audio(label="MultiBand Diffusion Decoder (wav)", type='filepath')
237
+
238
+ melody = gr.Audio(source= None, type="numpy", label="File",
239
+ interactive=False, visible= False, elem_id="melody-input")
240
+ decoder = gr.Radio(["Default", "MultiBand_Diffusion"],
241
+ label="Decoder", value="Default", interactive=True, visible= False)
242
+ duration = gr.Slider(minimum=1, maximum=120, value=10, label="Duration", interactive=True, visible= False)
243
+ topk = gr.Number(label="Top-k", value=250, interactive=True, visible= False)
244
+ topp = gr.Number(label="Top-p", value=0, interactive=True, visible= False)
245
+ temperature = gr.Number(label="Temperature", value=1.0, interactive=True, visible= False)
246
+ cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True, visible= False)
247
+ diffusion_output = gr.Video(label="MultiBand Diffusion Decoder" , visible=False)
248
+ audio_diffusion = gr.Audio(label="MultiBand Diffusion Decoder (wav)", type='filepath', visible= False)
249
+
250
+ print("melody", melody)
251
+ print("decoder", decoder)
252
+ print("topk", topk)
253
+ print("topp", topp)
254
+ print("cfg_coef", cfg_coef)
255
+ print("diffusion_output" , diffusion_output)
256
+ print("audio_diffusion" , audio_diffusion)
257
+
258
  submit.click(toggle_diffusion, decoder, [diffusion_output, audio_diffusion], queue=False,
259
  show_progress=False).then(predict_full, inputs=[model, decoder, text, melody, duration, topk, topp,
260
  temperature, cfg_coef],
261
  outputs=[output, audio_output, diffusion_output, audio_diffusion])
262
+ # radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
263
+
264
+ # gr.Examples(
265
+ # fn=predict_full,
266
+ # examples=[
267
+ # [
268
+ # "An 80s driving pop song with heavy drums and synth pads in the background",
269
+ # "./assets/bach.mp3",
270
+ # "facebook/musicgen-melody",
271
+ # "Default"
272
+ # ],
273
+ # [
274
+ # "A cheerful country song with acoustic guitars",
275
+ # "./assets/bolero_ravel.mp3",
276
+ # "facebook/musicgen-melody",
277
+ # "Default"
278
+ # ],
279
+ # [
280
+ # "90s rock song with electric guitar and heavy drums",
281
+ # None,
282
+ # "facebook/musicgen-medium",
283
+ # "Default"
284
+ # ],
285
+ # [
286
+ # "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
287
+ # "./assets/bach.mp3",
288
+ # "facebook/musicgen-melody",
289
+ # "Default"
290
+ # ],
291
+ # [
292
+ # "lofi slow bpm electro chill with organic samples",
293
+ # None,
294
+ # "facebook/musicgen-medium",
295
+ # "Default"
296
+ # ],
297
+ # [
298
+ # "Punk rock with loud drum and power guitar",
299
+ # None,
300
+ # "facebook/musicgen-medium",
301
+ # "MultiBand_Diffusion"
302
+ # ],
303
+ # ],
304
+ # inputs=[text, melody, model, decoder],
305
+ # outputs=[output]
306
+ # )
307
+ gr.Markdown(
308
+ """
309
+ """
310
+ )
311
 
312
+ interface.queue().launch(**launch_kwargs)
313
 
314
  def ui_batched(launch_kwargs):
315
  with gr.Blocks() as demo:
316
+ gr.Markdown(
317
+ """
318
+ This project generate Music from prompt.
319
+ """
320
+ )
321
  with gr.Row():
322
  with gr.Column():
323
  with gr.Row():
 
335
  submit.click(predict_batched, inputs=[text, melody],
336
  outputs=[output, audio_output], batch=True, max_batch_size=MAX_BATCH_SIZE)
337
  radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
338
+ gr.Examples(
339
+ fn=predict_batched,
340
+ # examples=[
341
+ # [
342
+ # "An 80s driving pop song with heavy drums and synth pads in the background",
343
+ # "./assets/bach.mp3",
344
+ # ],
345
+ # [
346
+ # "A cheerful country song with acoustic guitars",
347
+ # "./assets/bolero_ravel.mp3",
348
+ # ],
349
+ # [
350
+ # "90s rock song with electric guitar and heavy drums",
351
+ # None,
352
+ # ],
353
+ # [
354
+ # "a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
355
+ # "./assets/bach.mp3",
356
+ # ],
357
+ # [
358
+ # "lofi slow bpm electro chill with organic samples",
359
+ # None,
360
+ # ],
361
+ # ],
362
+ examples=[
363
+
364
+ ],
365
+ inputs=[text, melody],
366
+ outputs=[output]
367
+ )
368
+ gr.Markdown("""
369
+
370
+ """)
371
+
372
  demo.queue(max_size=8 * 4).launch(**launch_kwargs)
373
 
374