🚀 Mustango:迈向可控的文本到音乐生成
Mustango 是一款专为可控音乐生成设计的多模态大语言模型,它利用潜在扩散模型(LDM)、Flan - T5 和音乐特征实现音乐生成。该模型为音乐生成领域带来了新的活力,让用户能够通过文本提示生成特定风格的音乐。
演示 | 模型 | 网站和示例 | 论文 | 数据集

🔥 在 Replicate 和 HuggingFace 上有实时演示。
🚀 快速开始
根据文本提示生成音乐:
import IPython
import soundfile as sf
from mustango import Mustango
model = Mustango("declare-lab/mustango")
prompt = "This is a new age piece. There is a flute playing the main melody with a lot of staccato notes. The rhythmic background consists of a medium tempo electronic drum beat with percussive elements all over the spectrum. There is a playful atmosphere to the piece. This piece can be used in the soundtrack of a children's TV show or an advertisement jingle."
music = model.generate(prompt)
sf.write(f"{prompt}.wav", audio, samplerate=16000)
IPython.display.Audio(data=audio, rate=16000)
📦 安装指南
git clone https://github.com/AMAAI-Lab/mustango
cd mustango
pip install -r requirements.txt
cd diffusers
pip install -e .
📚 详细文档
数据集
MusicBench 数据集包含 52k 个音乐片段,每个片段都配有丰富的特定音乐文本描述。
主观评估
模型 |
数据集 |
预训练 |
整体匹配度 ↑ |
和弦匹配度 ↑ |
节奏匹配度 ↑ |
音频质量 ↑ |
音乐性 ↑ |
节奏存在与稳定性 ↑ |
和声与协和性 ↑ |
Tango |
MusicCaps |
✓ |
4.35 |
2.75 |
3.88 |
3.35 |
2.83 |
3.95 |
3.84 |
Tango |
MusicBench |
✓ |
4.91 |
3.61 |
3.86 |
3.88 |
3.54 |
4.01 |
4.34 |
Mustango |
MusicBench |
✓ |
5.49 |
5.76 |
4.98 |
4.30 |
4.28 |
4.65 |
5.18 |
Mustango |
MusicBench |
✗ |
5.75 |
6.06 |
5.11 |
4.80 |
4.80 |
4.75 |
5.59 |
训练
我们使用 Hugging Face 的 accelerate
包进行多 GPU 训练。在终端运行 accelerate config
并根据提示设置运行配置。
你可以使用以下命令在 MusicBench 数据集上训练 Mustango:
accelerate launch train.py \
--text_encoder_name="google/flan-t5-large" \
--scheduler_name="stabilityai/stable-diffusion-2-1" \
--unet_model_config="configs/diffusion_model_config_munet.json" \
--model_type Mustango --freeze_text_encoder --uncondition_all --uncondition_single \
--drop_sentences --random_pick_text_column --snr_gamma 5 \
--model_type
标志允许你选择使用相同代码训练 Mustango 或 Tango。但请注意,你还需要将 --unet_model_config
更改为相关配置:Mustango 使用 diffusion_model_config_munet;Tango 使用 diffusion_model_config。
参数 --uncondition_all
、--uncondition_single
、--drop_sentences
按照论文第 5.2 节控制丢弃函数。--random_pick_text_column
参数允许在两个输入文本提示之间随机选择 - 对于 MusicBench 数据集,我们在 ChatGPT 改写的描述和原始增强的 MusicCaps 提示之间进行选择,如论文图 1 所示。
在 MusicBench 上从头开始训练的建议时间至少为 40 个周期。
模型库
我们发布了以下模型:
- Mustango 预训练模型:https://huggingface.co/declare-lab/mustango-pretrained
- Mustango:https://huggingface.co/declare-lab/mustango
引用
如果您觉得我们的工作有用,请考虑引用以下文章:
@misc{melechovsky2023mustango,
title={Mustango: Toward Controllable Text-to-Music Generation},
author={Jan Melechovsky and Zixun Guo and Deepanway Ghosal and Navonil Majumder and Dorien Herremans and Soujanya Poria},
year={2023},
eprint={2311.08355},
archivePrefix={arXiv},
}
许可证
本项目采用 Apache - 2.0 许可证。