Spaces:
Runtime error
Runtime error
Commit
·
d646d8b
1
Parent(s):
d72e937
remove needless things in ui
Browse files
app.py
CHANGED
|
@@ -199,23 +199,12 @@ def toggle_diffusion(choice):
|
|
| 199 |
|
| 200 |
def ui_full(launch_kwargs):
|
| 201 |
with gr.Blocks() as interface:
|
| 202 |
-
|
| 203 |
-
"""
|
| 204 |
-
# MusicGen
|
| 205 |
-
This is your private demo for [MusicGen](https://github.com/facebookresearch/audiocraft),
|
| 206 |
-
a simple and controllable model for music generation
|
| 207 |
-
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284)
|
| 208 |
-
"""
|
| 209 |
-
)
|
| 210 |
with gr.Row():
|
| 211 |
with gr.Column():
|
| 212 |
with gr.Row():
|
| 213 |
text = gr.Text(label="Input Text", interactive=True)
|
| 214 |
-
|
| 215 |
-
radio = gr.Radio(["file", "mic"], value="file",
|
| 216 |
-
label="Condition on a melody (optional) File or Mic")
|
| 217 |
-
melody = gr.Audio(source="upload", type="numpy", label="File",
|
| 218 |
-
interactive=True, elem_id="melody-input")
|
| 219 |
with gr.Row():
|
| 220 |
submit = gr.Button("Submit")
|
| 221 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
|
@@ -244,105 +233,12 @@ def ui_full(launch_kwargs):
|
|
| 244 |
temperature, cfg_coef],
|
| 245 |
outputs=[output, audio_output, diffusion_output, audio_diffusion])
|
| 246 |
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
| 247 |
-
|
| 248 |
-
gr.Examples(
|
| 249 |
-
fn=predict_full,
|
| 250 |
-
examples=[
|
| 251 |
-
[
|
| 252 |
-
"An 80s driving pop song with heavy drums and synth pads in the background",
|
| 253 |
-
"./assets/bach.mp3",
|
| 254 |
-
"facebook/musicgen-melody",
|
| 255 |
-
"Default"
|
| 256 |
-
],
|
| 257 |
-
[
|
| 258 |
-
"A cheerful country song with acoustic guitars",
|
| 259 |
-
"./assets/bolero_ravel.mp3",
|
| 260 |
-
"facebook/musicgen-melody",
|
| 261 |
-
"Default"
|
| 262 |
-
],
|
| 263 |
-
[
|
| 264 |
-
"90s rock song with electric guitar and heavy drums",
|
| 265 |
-
None,
|
| 266 |
-
"facebook/musicgen-medium",
|
| 267 |
-
"Default"
|
| 268 |
-
],
|
| 269 |
-
[
|
| 270 |
-
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
|
| 271 |
-
"./assets/bach.mp3",
|
| 272 |
-
"facebook/musicgen-melody",
|
| 273 |
-
"Default"
|
| 274 |
-
],
|
| 275 |
-
[
|
| 276 |
-
"lofi slow bpm electro chill with organic samples",
|
| 277 |
-
None,
|
| 278 |
-
"facebook/musicgen-medium",
|
| 279 |
-
"Default"
|
| 280 |
-
],
|
| 281 |
-
[
|
| 282 |
-
"Punk rock with loud drum and power guitar",
|
| 283 |
-
None,
|
| 284 |
-
"facebook/musicgen-medium",
|
| 285 |
-
"MultiBand_Diffusion"
|
| 286 |
-
],
|
| 287 |
-
],
|
| 288 |
-
inputs=[text, melody, model, decoder],
|
| 289 |
-
outputs=[output]
|
| 290 |
-
)
|
| 291 |
-
gr.Markdown(
|
| 292 |
-
"""
|
| 293 |
-
### More details
|
| 294 |
-
|
| 295 |
-
The model will generate a short music extract based on the description you provided.
|
| 296 |
-
The model can generate up to 30 seconds of audio in one pass. It is now possible
|
| 297 |
-
to extend the generation by feeding back the end of the previous chunk of audio.
|
| 298 |
-
This can take a long time, and the model might lose consistency. The model might also
|
| 299 |
-
decide at arbitrary positions that the song ends.
|
| 300 |
-
|
| 301 |
-
**WARNING:** Choosing long durations will take a long time to generate (2min might take ~10min).
|
| 302 |
-
An overlap of 12 seconds is kept with the previously generated chunk, and 18 "new" seconds
|
| 303 |
-
are generated each time.
|
| 304 |
-
|
| 305 |
-
We present 4 model variations:
|
| 306 |
-
1. facebook/musicgen-melody -- a music generation model capable of generating music condition
|
| 307 |
-
on text and melody inputs. **Note**, you can also use text only.
|
| 308 |
-
2. facebook/musicgen-small -- a 300M transformer decoder conditioned on text only.
|
| 309 |
-
3. facebook/musicgen-medium -- a 1.5B transformer decoder conditioned on text only.
|
| 310 |
-
4. facebook/musicgen-large -- a 3.3B transformer decoder conditioned on text only.
|
| 311 |
-
|
| 312 |
-
We also present two way of decoding the audio tokens
|
| 313 |
-
1. Use the default GAN based compression model
|
| 314 |
-
2. Use MultiBand Diffusion from (paper linknano )
|
| 315 |
-
|
| 316 |
-
When using `facebook/musicgen-melody`, you can optionally provide a reference audio from
|
| 317 |
-
which a broad melody will be extracted. The model will then try to follow both
|
| 318 |
-
the description and melody provided.
|
| 319 |
-
|
| 320 |
-
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
| 321 |
-
See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
|
| 322 |
-
for more details.
|
| 323 |
-
"""
|
| 324 |
-
)
|
| 325 |
-
|
| 326 |
interface.queue().launch(**launch_kwargs)
|
| 327 |
|
| 328 |
|
| 329 |
def ui_batched(launch_kwargs):
|
| 330 |
with gr.Blocks() as demo:
|
| 331 |
-
|
| 332 |
-
"""
|
| 333 |
-
# MusicGen
|
| 334 |
-
|
| 335 |
-
This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft),
|
| 336 |
-
a simple and controllable model for music generation
|
| 337 |
-
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).
|
| 338 |
-
<br/>
|
| 339 |
-
<a href="https://huggingface.co/spaces/facebook/MusicGen?duplicate=true"
|
| 340 |
-
style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank">
|
| 341 |
-
<img style="margin-bottom: 0em;display: inline;margin-top: -.25em;"
|
| 342 |
-
src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
| 343 |
-
for longer sequences, more control and no queue.</p>
|
| 344 |
-
"""
|
| 345 |
-
)
|
| 346 |
with gr.Row():
|
| 347 |
with gr.Column():
|
| 348 |
with gr.Row():
|
|
@@ -360,47 +256,6 @@ def ui_batched(launch_kwargs):
|
|
| 360 |
submit.click(predict_batched, inputs=[text, melody],
|
| 361 |
outputs=[output, audio_output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
| 362 |
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
| 363 |
-
gr.Examples(
|
| 364 |
-
fn=predict_batched,
|
| 365 |
-
examples=[
|
| 366 |
-
[
|
| 367 |
-
"An 80s driving pop song with heavy drums and synth pads in the background",
|
| 368 |
-
"./assets/bach.mp3",
|
| 369 |
-
],
|
| 370 |
-
[
|
| 371 |
-
"A cheerful country song with acoustic guitars",
|
| 372 |
-
"./assets/bolero_ravel.mp3",
|
| 373 |
-
],
|
| 374 |
-
[
|
| 375 |
-
"90s rock song with electric guitar and heavy drums",
|
| 376 |
-
None,
|
| 377 |
-
],
|
| 378 |
-
[
|
| 379 |
-
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
|
| 380 |
-
"./assets/bach.mp3",
|
| 381 |
-
],
|
| 382 |
-
[
|
| 383 |
-
"lofi slow bpm electro chill with organic samples",
|
| 384 |
-
None,
|
| 385 |
-
],
|
| 386 |
-
],
|
| 387 |
-
inputs=[text, melody],
|
| 388 |
-
outputs=[output]
|
| 389 |
-
)
|
| 390 |
-
gr.Markdown("""
|
| 391 |
-
### More details
|
| 392 |
-
|
| 393 |
-
The model will generate 12 seconds of audio based on the description you provided.
|
| 394 |
-
You can optionally provide a reference audio from which a broad melody will be extracted.
|
| 395 |
-
The model will then try to follow both the description and melody provided.
|
| 396 |
-
All samples are generated with the `melody` model.
|
| 397 |
-
|
| 398 |
-
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
| 399 |
-
|
| 400 |
-
See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
|
| 401 |
-
for more details.
|
| 402 |
-
""")
|
| 403 |
-
|
| 404 |
demo.queue(max_size=8 * 4).launch(**launch_kwargs)
|
| 405 |
|
| 406 |
|
|
|
|
| 199 |
|
| 200 |
def ui_full(launch_kwargs):
|
| 201 |
with gr.Blocks() as interface:
|
| 202 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
with gr.Row():
|
| 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.
|
|
|
|
| 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 |
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 |
|