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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Lumina Text-to-Audio
|
| 6 |
+
|
| 7 |
+
`Lumina Text-to-Audio` is a music generation model developed based on FlagDiT. It uses [T5-v1.1-XXL](https://huggingface.co/google/t5-v1_1-xxl) as the text encoder and [Vocoder](https://github.com/NVIDIA/BigVGAN) as the decoder.
|
| 8 |
+
|
| 9 |
+
>[!Warning]
|
| 10 |
+
>The current version of Lumina Text-to-Audio requires the use of structure caption for audio generation. We will soon release a version that does not require structure caption.
|
| 11 |
+
|
| 12 |
+
- Generation Model: Flag-DiT
|
| 13 |
+
- Text Encoder: [T5-v1.1-XXL](https://huggingface.co/google/t5-v1_1-xxl)
|
| 14 |
+
- VAE: Make an Audio 2, finetuned from [Make an Audio](https://github.com/Text-to-Audio/Make-An-Audio)
|
| 15 |
+
- Decoder: [Vocoder](https://github.com/NVIDIA/BigVGAN)
|
| 16 |
+
- `Lumina-T2Audio` Checkpoints: [huggingface](https://huggingface.co/Alpha-VLLM/Lumina-T2Audio)
|
| 17 |
+
|
| 18 |
+
## 📰 News
|
| 19 |
+
|
| 20 |
+
- [2024-06-19] 🚀🚀🚀 We release the initial version of `Lumina-T2Audio` for text-to-audio generation.
|
| 21 |
+
|
| 22 |
+
## Installation
|
| 23 |
+
|
| 24 |
+
Before installation, ensure that you have a working ``nvcc``
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
# The command should work and show the same version number as in our case. (12.1 in our case).
|
| 28 |
+
nvcc --version
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
On some outdated distros (e.g., CentOS 7), you may also want to check that a late enough version of
|
| 32 |
+
``gcc`` is available
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
# The command should work and show a version of at least 6.0.
|
| 36 |
+
# If not, consult distro-specific tutorials to obtain a newer version or build manually.
|
| 37 |
+
gcc --version
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Downloading Lumina-T2X repo from github:
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
git clone https://github.com/Alpha-VLLM/Lumina-T2X
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### 1. Create a conda environment and install PyTorch
|
| 47 |
+
|
| 48 |
+
Note: You may want to adjust the CUDA version [according to your driver version](https://docs.nvidia.com/deploy/cuda-compatibility/#default-to-minor-version).
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
conda create -n Lumina_T2X -y
|
| 52 |
+
conda activate Lumina_T2X
|
| 53 |
+
conda install python=3.11 pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia -y
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
### 2. Install dependencies
|
| 57 |
+
|
| 58 |
+
>[!Warning]
|
| 59 |
+
> The environment dependencies for Lumina-T2Audio are different from those for Lumina-T2I. Please install the appropriate environment.
|
| 60 |
+
|
| 61 |
+
Installing `Lumina-T2Audio` dependencies:
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
cd .. # If you are in the `lumina_audio` directory, execute this line.
|
| 65 |
+
pip install -e ".[audio]"
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
or you can use `requirements.txt` to install the environment.
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
cd lumina_audio # If you are not in the `lumina_audio` folder, run this line.
|
| 72 |
+
pip install -r requirements.txt
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### 3. Install ``flash-attn``
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
pip install flash-attn --no-build-isolation
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### 4. Install [nvidia apex](https://github.com/nvidia/apex) (optional)
|
| 82 |
+
|
| 83 |
+
>[!Warning]
|
| 84 |
+
> While Apex can improve efficiency, it is *not* a must to make Lumina-T2X work.
|
| 85 |
+
>
|
| 86 |
+
> Note that Lumina-T2X works smoothly with either:
|
| 87 |
+
> + Apex not installed at all; OR
|
| 88 |
+
> + Apex successfully installed with CUDA and C++ extensions.
|
| 89 |
+
>
|
| 90 |
+
> However, it will fail when:
|
| 91 |
+
> + A Python-only build of Apex is installed.
|
| 92 |
+
>
|
| 93 |
+
> If the error `No module named 'fused_layer_norm_cuda'` appears, it typically means you are using a Python-only build of Apex. To resolve this, please run `pip uninstall apex`, and Lumina-T2X should then function correctly.
|
| 94 |
+
|
| 95 |
+
You can clone the repo and install following the official guidelines (note that we expect a full
|
| 96 |
+
build, i.e., with CUDA and C++ extensions)
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
pip install ninja
|
| 100 |
+
git clone https://github.com/NVIDIA/apex
|
| 101 |
+
cd apex
|
| 102 |
+
# if pip >= 23.1 (ref: https://pip.pypa.io/en/stable/news/#v23-1) which supports multiple `--config-settings` with the same key...
|
| 103 |
+
pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" ./
|
| 104 |
+
# otherwise
|
| 105 |
+
pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## Inference
|
| 109 |
+
|
| 110 |
+
### Preparation
|
| 111 |
+
|
| 112 |
+
Prepare the pretrained checkpoints.
|
| 113 |
+
|
| 114 |
+
⭐⭐ (Recommended) you can use `huggingface-cli` downloading our model:
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
huggingface-cli download --resume-download Alpha-VLLM/Lumina-T2Audio --local-dir /path/to/ckpt
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
or using git for cloning the model you want to use:
|
| 121 |
+
|
| 122 |
+
```bash
|
| 123 |
+
git clone https://huggingface.co/Alpha-VLLM/Lumina-T2Audio
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
### Web Demo
|
| 127 |
+
|
| 128 |
+
To host a local gradio demo for interactive inference, run the following command:
|
| 129 |
+
|
| 130 |
+
1. updated `AutoencoderKL` ckpt path
|
| 131 |
+
|
| 132 |
+
you should update `configs/lumina-text2audio.yaml` to set `AutoencoderKL` checkpoint path. Please replace `/path/to/ckpt` with the path where your checkpoints are located (<real_ckpt_path>).
|
| 133 |
+
|
| 134 |
+
```diff
|
| 135 |
+
...
|
| 136 |
+
depth: 16
|
| 137 |
+
max_len: 1000
|
| 138 |
+
|
| 139 |
+
first_stage_config:
|
| 140 |
+
target: models.autoencoder1d.AutoencoderKL
|
| 141 |
+
params:
|
| 142 |
+
embed_dim: 20
|
| 143 |
+
monitor: val/rec_loss
|
| 144 |
+
- ckpt_path: /path/to/ckpt/maa2/maa2.ckpt
|
| 145 |
+
+ ckpt_path: <real_ckpt_path>/maa2/maa2.ckpt
|
| 146 |
+
ddconfig:
|
| 147 |
+
double_z: true
|
| 148 |
+
in_channels: 80
|
| 149 |
+
out_ch: 80
|
| 150 |
+
...
|
| 151 |
+
cond_stage_config:
|
| 152 |
+
target: models.encoders.modules.FrozenCLAPFLANEmbedder
|
| 153 |
+
params:
|
| 154 |
+
- weights_path: /path/to/ckpt/CLAP/CLAP_weights_2022.pth
|
| 155 |
+
+ weights_path: <real_ckpt_path>/CLAP/CLAP_weights_2022.pth
|
| 156 |
+
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
2. setting `Lumina-T2Audio` and `Vocoder` checkpoint path and run demo
|
| 160 |
+
|
| 161 |
+
Please replace `/path/to/ckpt` with the actual downloaded path.
|
| 162 |
+
|
| 163 |
+
```bash
|
| 164 |
+
# `/path/to/ckpt` should be a directory containing `audio_generation`, `maa2`, and `bigvnat`.
|
| 165 |
+
|
| 166 |
+
# default
|
| 167 |
+
python -u demo_audio.py \
|
| 168 |
+
--ckpt "/path/to/ckpt/audio_generation" \
|
| 169 |
+
--vocoder_ckpt "/path/to/ckpt/bigvnat" \
|
| 170 |
+
--config_path "configs/lumina-text2audio.yaml" \
|
| 171 |
+
--sample_rate 16000
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
or you can run `run_audio.sh` script for web demo after updating `AutoencoderKL` ckpt path on `configs/lumina-text2audio.yaml`, and updating `--ckpt`, and `--vocoder_ckpt` on `run_audio.sh`.
|
| 175 |
+
|
| 176 |
+
3. setting openai api key for generating structure caption.
|
| 177 |
+
|
| 178 |
+
Please replace the line in `n2s_openai.py`:
|
| 179 |
+
|
| 180 |
+
```diff
|
| 181 |
+
- openai_key = 'your openai api key here'
|
| 182 |
+
+ openai_key = '<your real openai api key>'
|
| 183 |
+
```
|
| 184 |
+
|
| 185 |
+
If you have other relay station APIs, please modify the `base_url` accordingly. The default setting uses OpenAI's `base_url`.
|
| 186 |
+
|
| 187 |
+
```diff
|
| 188 |
+
- base_url = ""
|
| 189 |
+
+ base_url = "<your base url>"
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
4. running the demo
|
| 193 |
+
|
| 194 |
+
```bash
|
| 195 |
+
bash run_audio.sh
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
## Disclaimer
|
| 199 |
+
|
| 200 |
+
Any organization or individual is prohibited from using any technology mentioned in this paper to generate someone's speech without his/her consent, including but not limited to government leaders, political figures, and celebrities. If you do not comply with this item, you could be in violation of copyright laws.
|