facebook / musicgen-large

huggingface.co
Total runs: 7.1K
24-hour runs: 50
7-day runs: 43
30-day runs: 1.0K
Model's Last Updated: Novembro 17 2023
text-to-audio

Introduction of musicgen-large

Model Details of musicgen-large

MusicGen - Large - 3.3B

MusicGen is a text-to-music model capable of genreating high-quality music samples conditioned on text descriptions or audio prompts. It is a single stage auto-regressive Transformer model trained over a 32kHz EnCodec tokenizer with 4 codebooks sampled at 50 Hz. Unlike existing methods, like MusicLM, MusicGen doesn't require a self-supervised semantic representation, and it generates all 4 codebooks in one pass. 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.

MusicGen was published in Simple and Controllable Music Generation by Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre Défossez .

Four checkpoints are released:

Example

Try out MusicGen yourself!

  • Audiocraft Colab:
Open In Colab
  • Hugging Face Colab:
Open In Colab
  • Hugging Face Demo:
Open in HuggingFace
🤗 Transformers Usage

You can run MusicGen locally with the 🤗 Transformers library from version 4.31.0 onwards.

  1. First install the 🤗 Transformers library and scipy:
pip install --upgrade pip
pip install --upgrade transformers scipy
  1. Run inference via the Text-to-Audio (TTA) pipeline. You can infer the MusicGen model via the TTA pipeline in just a few lines of code!
from transformers import pipeline
import scipy

synthesiser = pipeline("text-to-audio", "facebook/musicgen-large")

music = synthesiser("lo-fi music with a soothing melody", forward_params={"do_sample": True})

scipy.io.wavfile.write("musicgen_out.wav", rate=music["sampling_rate"], data=music["audio"])
  1. Run inference via the Transformers modelling code. You can use the processor + generate code to convert text into a mono 32 kHz audio waveform for more fine-grained control.
from transformers import AutoProcessor, MusicgenForConditionalGeneration

processor = AutoProcessor.from_pretrained("facebook/musicgen-large")
model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-large")

inputs = processor(
    text=["80s pop track with bassy drums and synth", "90s rock song with loud guitars and heavy drums"],
    padding=True,
    return_tensors="pt",
)

audio_values = model.generate(**inputs, max_new_tokens=256)
  1. Listen to the audio samples either in an ipynb notebook:
from IPython.display import Audio

sampling_rate = model.config.audio_encoder.sampling_rate
Audio(audio_values[0].numpy(), rate=sampling_rate)

Or save them as a .wav file using a third-party library, e.g. scipy :

import scipy

sampling_rate = model.config.audio_encoder.sampling_rate
scipy.io.wavfile.write("musicgen_out.wav", rate=sampling_rate, data=audio_values[0, 0].numpy())

For more details on using the MusicGen model for inference using the 🤗 Transformers library, refer to the MusicGen docs .

Audiocraft Usage

You can also run MusicGen locally through the original Audiocraft library :

  1. First install the audiocraft library
pip install git+https://github.com/facebookresearch/audiocraft.git
  1. Make sure to have ffmpeg installed:
apt get install ffmpeg
  1. Run the following Python code:
from audiocraft.models import MusicGen
from audiocraft.data.audio import audio_write

model = MusicGen.get_pretrained("large")
model.set_generation_params(duration=8)  # generate 8 seconds.

descriptions = ["happy rock", "energetic EDM"]

wav = model.generate(descriptions)  # generates 2 samples.

for idx, one_wav in enumerate(wav):
    # Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
    audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness")
Model details

Organization developing the model: The FAIR team of Meta AI.

Model date: MusicGen was trained between April 2023 and May 2023.

Model version: This is the version 1 of the model.

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.

Paper or resources for more information: More information can be found in the paper Simple and Controllable Music Generation .

Citation details:

@misc{copet2023simple,
      title={Simple and Controllable Music Generation}, 
      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},
      year={2023},
      eprint={2306.05284},
      archivePrefix={arXiv},
      primaryClass={cs.SD}
}

License: Code is released under MIT, model weights are released under CC-BY-NC 4.0.

Where to send questions or comments about the model: Questions and comments about MusicGen can be sent via the Github repository of the project, or by opening an issue.

Intended use

Primary intended use: The primary use of MusicGen is research on AI-based music generation, including:

  • Research efforts, such as probing and better understanding the limitations of generative models to further improve the state of science
  • Generation of music guided by text or melody to understand current abilities of generative AI models by machine learning amateurs

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.

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.

Metrics

Models performance measures: We used the following objective measure to evaluate the model on a standard music benchmark:

  • Frechet Audio Distance computed on features extracted from a pre-trained audio classifier (VGGish)
  • Kullback-Leibler Divergence on label distributions extracted from a pre-trained audio classifier (PaSST)
  • CLAP Score between audio embedding and text embedding extracted from a pre-trained CLAP model

Additionally, we run qualitative studies with human participants, evaluating the performance of the model with the following axes:

  • Overall quality of the music samples;
  • Text relevance to the provided text input;
  • Adherence to the melody for melody-guided music generation.

More details on performance measures and human studies can be found in the paper.

Decision thresholds: Not applicable.

Evaluation datasets

The model was evaluated on the MusicCaps benchmark and on an in-domain held-out evaluation set, with no artist overlap with the training set.

Training datasets

The model was trained on licensed data using the following sources: the Meta Music Initiative Sound Collection , Shutterstock music collection and the Pond5 music collection . See the paper for more details about the training set and corresponding preprocessing.

Evaluation results

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 (HT-Demucs), in order to keep only the instrumental part. This explains the difference in objective metrics with the models used in the paper.

Model Frechet Audio Distance KLD Text Consistency Chroma Cosine Similarity
facebook/musicgen-small 4.88 1.42 0.27 -
facebook/musicgen-medium 5.14 1.38 0.28 -
facebook/musicgen-large 5.48 1.37 0.28 -
facebook/musicgen-melody 4.93 1.41 0.27 0.44

More information can be found in the paper Simple and Controllable Music Generation , in the Results section.

Limitations and biases

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.

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 (HT-Demucs).

Limitations:

  • The model is not able to generate realistic vocals.
  • The model has been trained with English descriptions and will not perform as well in other languages.
  • The model does not perform equally well for all music styles and cultures.
  • The model sometimes generates end of songs, collapsing to silence.
  • It is sometimes difficult to assess what types of text descriptions provide the best generations. Prompt engineering may be required to obtain satisfying results.

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.

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.

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.

Runs of facebook musicgen-large on huggingface.co

7.1K
Total runs
50
24-hour runs
-3
3-day runs
43
7-day runs
1.0K
30-day runs

More Information About musicgen-large huggingface.co Model

More musicgen-large license Visit here:

https://choosealicense.com/licenses/cc-by-nc-4.0

musicgen-large huggingface.co

musicgen-large huggingface.co is an AI model on huggingface.co that provides musicgen-large's model effect (), which can be used instantly with this facebook musicgen-large model. huggingface.co supports a free trial of the musicgen-large model, and also provides paid use of the musicgen-large. Support call musicgen-large model through api, including Node.js, Python, http.

musicgen-large huggingface.co Url

https://huggingface.co/facebook/musicgen-large

facebook musicgen-large online free

musicgen-large huggingface.co is an online trial and call api platform, which integrates musicgen-large's modeling effects, including api services, and provides a free online trial of musicgen-large, you can try musicgen-large online for free by clicking the link below.

facebook musicgen-large online free url in huggingface.co:

https://huggingface.co/facebook/musicgen-large

musicgen-large install

musicgen-large is an open source model from GitHub that offers a free installation service, and any user can find musicgen-large on GitHub to install. At the same time, huggingface.co provides the effect of musicgen-large install, users can directly use musicgen-large installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

musicgen-large install url in huggingface.co:

https://huggingface.co/facebook/musicgen-large

Url of musicgen-large

musicgen-large huggingface.co Url

Provider of musicgen-large huggingface.co

facebook
ORGANIZATIONS

Other API from facebook

huggingface.co

Total runs: 12.0M
Run Growth: 9.4M
Growth Rate: 81.68%
Updated: Março 22 2023
huggingface.co

Total runs: 11.9M
Run Growth: 3.9M
Growth Rate: 31.86%
Updated: Janeiro 17 2024
huggingface.co

Total runs: 7.5M
Run Growth: 2.4M
Growth Rate: 33.09%
Updated: Setembro 15 2023
huggingface.co

Total runs: 3.0M
Run Growth: 759.8K
Growth Rate: 25.94%
Updated: Novembro 16 2022
huggingface.co

Total runs: 2.9M
Run Growth: 2.8M
Growth Rate: 96.34%
Updated: Janeiro 25 2024
huggingface.co

Total runs: 2.8M
Run Growth: 1.8M
Growth Rate: 62.21%
Updated: Setembro 06 2023
huggingface.co

Total runs: 2.2M
Run Growth: 986.1K
Growth Rate: 44.88%
Updated: Novembro 13 2023
huggingface.co

Total runs: 1.4M
Run Growth: 109.0K
Growth Rate: 8.31%
Updated: Fevereiro 29 2024
huggingface.co

Total runs: 1.0M
Run Growth: 810.0K
Growth Rate: 79.38%
Updated: Setembro 15 2023
huggingface.co

Total runs: 902.9K
Run Growth: 274.4K
Growth Rate: 36.28%
Updated: Setembro 06 2023
huggingface.co

Total runs: 753.6K
Run Growth: 220.0K
Growth Rate: 30.34%
Updated: Dezembro 28 2021
huggingface.co

Total runs: 738.7K
Run Growth: 189.9K
Growth Rate: 26.37%
Updated: Janeiro 11 2024
huggingface.co

Total runs: 560.1K
Run Growth: 162.9K
Growth Rate: 29.08%
Updated: Novembro 16 2023
huggingface.co

Total runs: 444.4K
Run Growth: -119.6K
Growth Rate: -26.87%
Updated: Setembro 01 2023
huggingface.co

Total runs: 321.9K
Run Growth: 196.3K
Growth Rate: 60.26%
Updated: Janeiro 11 2024
huggingface.co

Total runs: 320.1K
Run Growth: 6.3K
Growth Rate: 2.24%
Updated: Junho 13 2023
huggingface.co

Total runs: 279.5K
Run Growth: -166.7K
Growth Rate: -59.17%
Updated: Janeiro 19 2022
huggingface.co

Total runs: 228.1K
Run Growth: -480.1K
Growth Rate: -210.43%
Updated: Junho 15 2023
huggingface.co

Total runs: 219.7K
Run Growth: 54.4K
Growth Rate: 24.98%
Updated: Setembro 06 2023
huggingface.co

Total runs: 212.0K
Run Growth: 35.8K
Growth Rate: 16.87%
Updated: Junho 03 2022
huggingface.co

Total runs: 175.9K
Run Growth: -33.1K
Growth Rate: -18.51%
Updated: Maio 22 2023
huggingface.co

Total runs: 170.4K
Run Growth: 102.3K
Growth Rate: 60.42%
Updated: Janeiro 11 2024
huggingface.co

Total runs: 162.4K
Run Growth: -20.6K
Growth Rate: -12.68%
Updated: Setembro 04 2023
huggingface.co

Total runs: 152.9K
Run Growth: 41.9K
Growth Rate: 28.42%
Updated: Setembro 15 2023
huggingface.co

Total runs: 85.1K
Run Growth: 58.0K
Growth Rate: 68.04%
Updated: Outubro 16 2024
huggingface.co

Total runs: 64.6K
Run Growth: 20.4K
Growth Rate: 38.01%
Updated: Maio 22 2023
huggingface.co

Total runs: 60.8K
Run Growth: 54.1K
Growth Rate: 89.40%
Updated: Novembro 20 2023
huggingface.co

Total runs: 50.3K
Run Growth: -141
Growth Rate: -0.28%
Updated: Setembro 15 2023
huggingface.co

Total runs: 46.1K
Run Growth: 3.5K
Growth Rate: 7.61%
Updated: Janeiro 24 2023
huggingface.co

Total runs: 38.1K
Run Growth: -8.5K
Growth Rate: -22.47%
Updated: Março 13 2024
huggingface.co

Total runs: 35.9K
Run Growth: 10.1K
Growth Rate: 30.67%
Updated: Fevereiro 11 2023
huggingface.co

Total runs: 30.0K
Run Growth: 9.1K
Growth Rate: 31.98%
Updated: Setembro 06 2023