reach-vb HF staff commited on
Commit
56e9ba4
1 Parent(s): 5e01a99

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +175 -0
README.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ tags:
4
+ - musicgen
5
+ license: cc-by-nc-4.0
6
+ ---
7
+
8
+ # MusicGen - Stereo - Melody - Large 3.3B
9
+
10
+ We further release a set of stereophonic capable models. Those were fine tuned for 200k updates starting
11
+ from the mono models. The training data is otherwise identical and capabilities and limitations are shared with the base modes. The stereo models work by getting 2 streams of tokens from the EnCodec model, and interleaving those using
12
+ the delay pattern.
13
+
14
+ MusicGen is a text-to-music model capable of generating high-quality music samples conditioned on text descriptions or audio prompts.
15
+ It is a single stage auto-regressive Transformer model trained over a 32kHz EnCodec tokenizer with 4 codebooks sampled at 50 Hz.
16
+ Unlike existing methods, like MusicLM, MusicGen doesn't require a self-supervised semantic representation, and it generates all 4 codebooks in one pass.
17
+ By introducing a small delay between the codebooks, we show we can predict them in parallel, thus having only 50 auto-regressive steps per second of audio.
18
+
19
+ MusicGen was published in [Simple and Controllable Music Generation](https://arxiv.org/abs/2306.05284) by *Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre Défossez*.
20
+
21
+ We provide a simple API and 10 pre-trained models. The pre trained models are:
22
+ - `facebook/musicgen-small`: 300M model, text to music only - [🤗 Hub](https://huggingface.co/facebook/musicgen-small)
23
+ - `facebook/musicgen-medium`: 1.5B model, text to music only - [🤗 Hub](https://huggingface.co/facebook/musicgen-medium)
24
+ - `facebook/musicgen-melody`: 1.5B model, text to music and text+melody to music - [🤗 Hub](https://huggingface.co/facebook/musicgen-melody)
25
+ - `facebook/musicgen-large`: 3.3B model, text to music only - [🤗 Hub](https://huggingface.co/facebook/musicgen-large)
26
+ - `facebook/musicgen-melody-large`: 3.3B model, text to music and text+melody to music - [🤗 Hub](https://huggingface.co/facebook/musicgen-melody-large)
27
+ - `facebook/musicgen-stereo-*`: All the previous models fine-tuned for stereo generation -
28
+ [small](https://huggingface.co/facebook/musicgen-stereo-small),
29
+ [medium](https://huggingface.co/facebook/musicgen-stereo-medium),
30
+ [large](https://huggingface.co/facebook/musicgen-stereo-large),
31
+ [melody](https://huggingface.co/facebook/musicgen-stereo-melody),
32
+ [melody large](https://huggingface.co/facebook/musicgen-stereo-melody-large)
33
+
34
+ ## Example
35
+
36
+ Try out MusicGen yourself!
37
+
38
+ - <a target="_blank" href="https://colab.research.google.com/drive/1fxGqfg96RBUvGxZ1XXN07s3DthrKUl4-?usp=sharing">
39
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
40
+ </a>
41
+
42
+ - <a target="_blank" href="https://huggingface.co/spaces/facebook/MusicGen">
43
+ <img src="https://huggingface.co/datasets/huggingface/badges/raw/main/open-in-hf-spaces-sm.svg" alt="Open in HugginFace"/>
44
+ </a>
45
+
46
+ - You can run MusicGen locally as well:
47
+
48
+ 1. First install the [`audiocraft` library](https://github.com/facebookresearch/audiocraft)
49
+ ```
50
+ pip install git+https://github.com/facebookresearch/audiocraft.git
51
+ ```
52
+
53
+ 2. Make sure to have [`ffmpeg`](https://ffmpeg.org/download.html) installed:
54
+ ```
55
+ apt get install ffmpeg
56
+ ```
57
+
58
+ 3. Run the following Python code:
59
+
60
+ ```py
61
+ import torchaudio
62
+ from audiocraft.models import MusicGen
63
+ from audiocraft.data.audio import audio_write
64
+
65
+ model = MusicGen.get_pretrained('melody')
66
+ model.set_generation_params(duration=8) # generate 8 seconds.
67
+
68
+ descriptions = ['happy rock', 'energetic EDM', 'sad jazz']
69
+
70
+ melody, sr = torchaudio.load('./assets/bach.mp3')
71
+ # generates using the melody from the given audio and the provided descriptions.
72
+ wav = model.generate_with_chroma(descriptions, melody[None].expand(3, -1, -1), sr)
73
+
74
+ for idx, one_wav in enumerate(wav):
75
+ # Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
76
+ audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness")
77
+ ```
78
+
79
+
80
+ ## Model details
81
+
82
+ **Organization developing the model:** The FAIR team of Meta AI.
83
+
84
+ **Model date:** MusicGen was trained between April 2023 and May 2023.
85
+
86
+ **Model version:** This is the version 1 of the model.
87
+
88
+ **Model type:** MusicGen consists of an EnCodec model for audio tokenization, an auto-regressive language model based on the transformer architecture for music modeling. The model comes in different sizes: 300M, 1.5B and 3.3B parameters ; and two variants: a model trained for text-to-music generation task and a model trained for melody-guided music generation.
89
+
90
+ **Paper or resources for more information:** More information can be found in the paper [Simple and Controllable Music Generation](https://arxiv.org/abs/2306.05284).
91
+
92
+ **Citation details:**
93
+ ```
94
+ @misc{copet2023simple,
95
+ title={Simple and Controllable Music Generation},
96
+ author={Jade Copet and Felix Kreuk and Itai Gat and Tal Remez and David Kant and Gabriel Synnaeve and Yossi Adi and Alexandre Défossez},
97
+ year={2023},
98
+ eprint={2306.05284},
99
+ archivePrefix={arXiv},
100
+ primaryClass={cs.SD}
101
+ }
102
+ ```
103
+
104
+ **License:** Code is released under MIT, model weights are released under CC-BY-NC 4.0.
105
+
106
+ **Where to send questions or comments about the model:** Questions and comments about MusicGen can be sent via the [Github repository](https://github.com/facebookresearch/audiocraft) of the project, or by opening an issue.
107
+
108
+ ## Intended use
109
+ **Primary intended use:** The primary use of MusicGen is research on AI-based music generation, including:
110
+
111
+ - Research efforts, such as probing and better understanding the limitations of generative models to further improve the state of science
112
+ - Generation of music guided by text or melody to understand current abilities of generative AI models by machine learning amateurs
113
+
114
+ **Primary intended users:** The primary intended users of the model are researchers in audio, machine learning and artificial intelligence, as well as amateur seeking to better understand those models.
115
+
116
+ **Out-of-scope use cases:** The model should not be used on downstream applications without further risk evaluation and mitigation. The model should not be used to intentionally create or disseminate music pieces that create hostile or alienating environments for people. This includes generating music that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
117
+
118
+ ## Metrics
119
+
120
+ **Models performance measures:** We used the following objective measure to evaluate the model on a standard music benchmark:
121
+
122
+ - Frechet Audio Distance computed on features extracted from a pre-trained audio classifier (VGGish)
123
+ - Kullback-Leibler Divergence on label distributions extracted from a pre-trained audio classifier (PaSST)
124
+ - CLAP Score between audio embedding and text embedding extracted from a pre-trained CLAP model
125
+
126
+ Additionally, we run qualitative studies with human participants, evaluating the performance of the model with the following axes:
127
+
128
+ - Overall quality of the music samples;
129
+ - Text relevance to the provided text input;
130
+ - Adherence to the melody for melody-guided music generation.
131
+
132
+ More details on performance measures and human studies can be found in the paper.
133
+
134
+ **Decision thresholds:** Not applicable.
135
+
136
+ ## Evaluation datasets
137
+
138
+ The model was evaluated on the [MusicCaps benchmark](https://www.kaggle.com/datasets/googleai/musiccaps) and on an in-domain held-out evaluation set, with no artist overlap with the training set.
139
+
140
+ ## Training datasets
141
+
142
+ The model was trained on licensed data using the following sources: the [Meta Music Initiative Sound Collection](https://www.fb.com/sound), [Shutterstock music collection](https://www.shutterstock.com/music) and the [Pond5 music collection](https://www.pond5.com/). See the paper for more details about the training set and corresponding preprocessing.
143
+
144
+ ## Evaluation results
145
+
146
+ Below are the objective metrics obtained on MusicCaps with the released model. Note that for the publicly released models, we had all the datasets go through a state-of-the-art music source separation method, namely using the open source [Hybrid Transformer for Music Source Separation](https://github.com/facebookresearch/demucs) (HT-Demucs), in order to keep only the instrumental part. This explains the difference in objective metrics with the models used in the paper.
147
+
148
+ | Model | Frechet Audio Distance | KLD | Text Consistency | Chroma Cosine Similarity |
149
+ |---|---|---|---|---|
150
+ | facebook/musicgen-small | 4.88 | 1.42 | 0.27 | - |
151
+ | facebook/musicgen-medium | 5.14 | 1.38 | 0.28 | - |
152
+ | facebook/musicgen-large | 5.48 | 1.37 | 0.28 | - |
153
+ | **facebook/musicgen-melody** | 4.93 | 1.41 | 0.27 | 0.44 |
154
+
155
+ More information can be found in the paper [Simple and Controllable Music Generation](https://arxiv.org/abs/2306.05284), in the Results section.
156
+
157
+ ## Limitations and biases
158
+
159
+ **Data:** The data sources used to train the model are created by music professionals and covered by legal agreements with the right holders. The model is trained on 20K hours of data, we believe that scaling the model on larger datasets can further improve the performance of the model.
160
+
161
+ **Mitigations:** Vocals have been removed from the data source using corresponding tags, and then using a state-of-the-art music source separation method, namely using the open source [Hybrid Transformer for Music Source Separation](https://github.com/facebookresearch/demucs) (HT-Demucs).
162
+
163
+ **Limitations:**
164
+
165
+ - The model is not able to generate realistic vocals.
166
+ - The model has been trained with English descriptions and will not perform as well in other languages.
167
+ - The model does not perform equally well for all music styles and cultures.
168
+ - The model sometimes generates end of songs, collapsing to silence.
169
+ - It is sometimes difficult to assess what types of text descriptions provide the best generations. Prompt engineering may be required to obtain satisfying results.
170
+
171
+ **Biases:** The source of data is potentially lacking diversity and all music cultures are not equally represented in the dataset. The model may not perform equally well on the wide variety of music genres that exists. The generated samples from the model will reflect the biases from the training data. Further work on this model should include methods for balanced and just representations of cultures, for example, by scaling the training data to be both diverse and inclusive.
172
+
173
+ **Risks and harms:** Biases and limitations of the model may lead to generation of samples that may be considered as biased, inappropriate or offensive. We believe that providing the code to reproduce the research and train new models will allow to broaden the application to new and more representative data.
174
+
175
+ **Use cases:** Users must be aware of the biases, limitations and risks of the model. MusicGen is a model developed for artificial intelligence research on controllable music generation. As such, it should not be used for downstream applications without further investigation and mitigation of risks.