Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,24 +138,22 @@ def ui_full(launch_kwargs):
|
|
| 138 |
with gr.Blocks() as interface:
|
| 139 |
gr.Markdown(
|
| 140 |
"""
|
| 141 |
-
|
| 142 |
-
This is your private demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generation
|
| 143 |
-
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284)
|
| 144 |
"""
|
| 145 |
)
|
| 146 |
with gr.Row():
|
| 147 |
with gr.Column():
|
| 148 |
with gr.Row():
|
| 149 |
-
text = gr.Text(label="
|
| 150 |
melody = gr.Audio(source="upload", type="numpy", label="Melody Condition (optional)", interactive=True)
|
| 151 |
with gr.Row():
|
| 152 |
-
submit = gr.Button("
|
| 153 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
| 154 |
-
_ = gr.Button("
|
| 155 |
with gr.Row():
|
| 156 |
-
model = gr.Radio(["melody", "medium", "small", "large"], label="
|
| 157 |
with gr.Row():
|
| 158 |
-
duration = gr.Slider(minimum=1, maximum=120, value=10, label="
|
| 159 |
with gr.Row():
|
| 160 |
topk = gr.Number(label="Top-k", value=250, interactive=True)
|
| 161 |
topp = gr.Number(label="Top-p", value=0, interactive=True)
|
|
@@ -198,24 +196,7 @@ def ui_full(launch_kwargs):
|
|
| 198 |
)
|
| 199 |
gr.Markdown(
|
| 200 |
"""
|
| 201 |
-
|
| 202 |
-
The model will generate a short music extract based on the description you provided.
|
| 203 |
-
The model can generate up to 30 seconds of audio in one pass. It is now possible
|
| 204 |
-
to extend the generation by feeding back the end of the previous chunk of audio.
|
| 205 |
-
This can take a long time, and the model might lose consistency. The model might also
|
| 206 |
-
decide at arbitrary positions that the song ends.
|
| 207 |
-
**WARNING:** Choosing long durations will take a long time to generate (2min might take ~10min). An overlap of 12 seconds
|
| 208 |
-
is kept with the previously generated chunk, and 18 "new" seconds are generated each time.
|
| 209 |
-
We present 4 model variations:
|
| 210 |
-
1. Melody -- a music generation model capable of generating music condition on text and melody inputs. **Note**, you can also use text only.
|
| 211 |
-
2. Small -- a 300M transformer decoder conditioned on text only.
|
| 212 |
-
3. Medium -- a 1.5B transformer decoder conditioned on text only.
|
| 213 |
-
4. Large -- a 3.3B transformer decoder conditioned on text only (might OOM for the longest sequences.)
|
| 214 |
-
When using `melody`, ou can optionaly provide a reference audio from
|
| 215 |
-
which a broad melody will be extracted. The model will then try to follow both the description and melody provided.
|
| 216 |
-
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
| 217 |
-
See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
|
| 218 |
-
for more details.
|
| 219 |
"""
|
| 220 |
)
|
| 221 |
|
|
@@ -226,13 +207,7 @@ def ui_batched(launch_kwargs):
|
|
| 226 |
with gr.Blocks() as demo:
|
| 227 |
gr.Markdown(
|
| 228 |
"""
|
| 229 |
-
|
| 230 |
-
This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generation
|
| 231 |
-
presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).
|
| 232 |
-
<br/>
|
| 233 |
-
<a href="https://huggingface.co/spaces/facebook/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank">
|
| 234 |
-
<img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
| 235 |
-
for longer sequences, more control and no queue.</p>
|
| 236 |
"""
|
| 237 |
)
|
| 238 |
with gr.Row():
|
|
@@ -245,42 +220,9 @@ def ui_batched(launch_kwargs):
|
|
| 245 |
with gr.Column():
|
| 246 |
output = gr.Video(label="Generated Music")
|
| 247 |
submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
| 248 |
-
|
| 249 |
-
fn=predict_batched,
|
| 250 |
-
examples=[
|
| 251 |
-
[
|
| 252 |
-
"An 80s driving pop song with heavy drums and synth pads in the background",
|
| 253 |
-
"./assets/bach.mp3",
|
| 254 |
-
],
|
| 255 |
-
[
|
| 256 |
-
"A cheerful country song with acoustic guitars",
|
| 257 |
-
"./assets/bolero_ravel.mp3",
|
| 258 |
-
],
|
| 259 |
-
[
|
| 260 |
-
"90s rock song with electric guitar and heavy drums",
|
| 261 |
-
None,
|
| 262 |
-
],
|
| 263 |
-
[
|
| 264 |
-
"a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130",
|
| 265 |
-
"./assets/bach.mp3",
|
| 266 |
-
],
|
| 267 |
-
[
|
| 268 |
-
"lofi slow bpm electro chill with organic samples",
|
| 269 |
-
None,
|
| 270 |
-
],
|
| 271 |
-
],
|
| 272 |
-
inputs=[text, melody],
|
| 273 |
-
outputs=[output]
|
| 274 |
-
)
|
| 275 |
gr.Markdown("""
|
| 276 |
-
|
| 277 |
-
The model will generate 12 seconds of audio based on the description you provided.
|
| 278 |
-
You can optionaly provide a reference audio from which a broad melody will be extracted.
|
| 279 |
-
The model will then try to follow both the description and melody provided.
|
| 280 |
-
All samples are generated with the `melody` model.
|
| 281 |
-
You can also use your own GPU or a Google Colab by following the instructions on our repo.
|
| 282 |
-
See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
|
| 283 |
-
for more details.
|
| 284 |
""")
|
| 285 |
|
| 286 |
demo.queue(max_size=8 * 4).launch(**launch_kwargs)
|
|
|
|
| 138 |
with gr.Blocks() as interface:
|
| 139 |
gr.Markdown(
|
| 140 |
"""
|
| 141 |
+
|
|
|
|
|
|
|
| 142 |
"""
|
| 143 |
)
|
| 144 |
with gr.Row():
|
| 145 |
with gr.Column():
|
| 146 |
with gr.Row():
|
| 147 |
+
text = gr.Text(label="Текст пример (bass drum cyberpunk)", interactive=True)
|
| 148 |
melody = gr.Audio(source="upload", type="numpy", label="Melody Condition (optional)", interactive=True)
|
| 149 |
with gr.Row():
|
| 150 |
+
submit = gr.Button("Создать")
|
| 151 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
| 152 |
+
_ = gr.Button("Остановить").click(fn=interrupt, queue=False)
|
| 153 |
with gr.Row():
|
| 154 |
+
model = gr.Radio(["melody", "medium", "small", "large"], label="Тип трека", value="melody", interactive=True)
|
| 155 |
with gr.Row():
|
| 156 |
+
duration = gr.Slider(minimum=1, maximum=120, value=10, label="Время трека(seconds)", interactive=True)
|
| 157 |
with gr.Row():
|
| 158 |
topk = gr.Number(label="Top-k", value=250, interactive=True)
|
| 159 |
topp = gr.Number(label="Top-p", value=0, interactive=True)
|
|
|
|
| 196 |
)
|
| 197 |
gr.Markdown(
|
| 198 |
"""
|
| 199 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
"""
|
| 201 |
)
|
| 202 |
|
|
|
|
| 207 |
with gr.Blocks() as demo:
|
| 208 |
gr.Markdown(
|
| 209 |
"""
|
| 210 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
"""
|
| 212 |
)
|
| 213 |
with gr.Row():
|
|
|
|
| 220 |
with gr.Column():
|
| 221 |
output = gr.Video(label="Generated Music")
|
| 222 |
submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
| 223 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
gr.Markdown("""
|
| 225 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
""")
|
| 227 |
|
| 228 |
demo.queue(max_size=8 * 4).launch(**launch_kwargs)
|