Spaces:
Runtime error
Runtime error
adapting full app
Browse filesFiles changed (2)
- app.py+30-21
- app_batched.py+1-2
5 unmodified lines678910111213141535 unmodified lines51525354555657581 unmodified line6061626364656667686970717273747576777879808182838413 unmodified lines989910010110210310427 unmodified lines1321331341351365 unmodified linesLICENSE file in the root directory of this source tree."""import torchimport gradio as grfrom hf_loading import get_pretrainedMODEL = None35 unmodified lineselse:output = MODEL.generate(descriptions=[text], progress=False)output = output.detach().cpu().numpy()return MODEL.sample_rate, outputwith gr.Blocks() as demo:1 unmodified line"""# MusicGenThis is the demo for MusicGen, a simple and controllable model for music generation presented at: "Simple and Controllable Music Generation".Below we present 3 model variations:1. Melody -- a music generation model capable of generating music condition on text and melody inputs. **Note**, you can also use text only.2. Small -- a 300M transformer decoder conditioned on text only.3. Medium -- a 1.5B transformer decoder conditioned on text only.4. Large -- a 3.3B transformer decoder conditioned on text only (might OOM for the longest sequences.)When the optional melody conditioning wav is provided, the model will extracta broad melody and try to follow it in the generated samples.For skipping queue, you can duplicate this space, and upgrade to GPU in the settings.<br/><a href="https://huggingface.co/spaces/musicgen/MusicGen?duplicate=true"><img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a></p>See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)for more details.""")with gr.Row():13 unmodified linestemperature = gr.Number(label="Temperature", value=1.0, interactive=True)cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)with gr.Column():output = gr.Audio(label="Generated Music", type="numpy")submit.click(predict, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])gr.Examples(fn=predict,27 unmodified linesinputs=[text, melody, model],outputs=[output])demo.launch()5 unmodified lines678910111213141516171835 unmodified lines54555657585960616263641 unmodified line66676869707172737475767713 unmodified lines9192939495969727 unmodified lines1251261271281291301311321331341351361371381391401411421431441455 unmodified linesLICENSE file in the root directory of this source tree."""from tempfile import NamedTemporaryFileimport torchimport gradio as grfrom hf_loading import get_pretrainedfrom audiocraft.data.audio import audio_writeMODEL = None35 unmodified lineselse:output = MODEL.generate(descriptions=[text], progress=False)output = output.detach().cpu().float()[0]with NamedTemporaryFile("wb", suffix=".wav", delete=False) as file:audio_write(file.name, output, MODEL.sample_rate, strategy="loudness", add_suffix=False)waveform_video = gr.make_waveform(file.name)return waveform_videowith gr.Blocks() as demo:1 unmodified line"""# MusicGenThis is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generationpresented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).<br/><a href="https://huggingface.co/spaces/musicgen/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank"><img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>for longer sequences, more control and no queue.</p>""")with gr.Row():13 unmodified linestemperature = gr.Number(label="Temperature", value=1.0, interactive=True)cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)with gr.Column():output = gr.Video(label="Generated Music")submit.click(predict, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])gr.Examples(fn=predict,27 unmodified linesinputs=[text, melody, model],outputs=[output])gr.Markdown("""### More detailsBy typing a description of the music you want and an optional audio used for melody conditioning,We present 4 model variations:1. Melody -- a music generation model capable of generating music condition on text and melody inputs. **Note**, you can also use text only.2. Small -- a 300M transformer decoder conditioned on text only.3. Medium -- a 1.5B transformer decoder conditioned on text only.4. Large -- a 3.3B transformer decoder conditioned on text only (might OOM for the longest sequences.)When the optional melody conditioning wav is provided, the model will extracta broad melody and try to follow it in the generated samples.""")demo.launch()
59 unmodified lines606162636465665 unmodified lines7273747576777859 unmodified linesaudio_write(file.name, output, MODEL.sample_rate, strategy="loudness", add_suffix=False)waveform_video = gr.make_waveform(file.name)out_files.append(waveform_video)print(out_files)return [out_files]5 unmodified linesThis is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generationpresented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).<br/><a href="https://huggingface.co/spaces/facebook/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank"><img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>for longer sequences, more control and no queue</p>"""59 unmodified lines6061626364655 unmodified lines7172737475767759 unmodified linesaudio_write(file.name, output, MODEL.sample_rate, strategy="loudness", add_suffix=False)waveform_video = gr.make_waveform(file.name)out_files.append(waveform_video)return [out_files]5 unmodified linesThis is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generationpresented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).<br/><a href="https://huggingface.co/spaces/musicgen/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank"><img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>for longer sequences, more control and no queue</p>"""
app.py+30-21
app_batched.py+1-2