PapaMoth juhayna commited on
Commit
4d70949
·
0 Parent(s):

Duplicate from OpenMuQ/MuQ-MuLan-large

Browse files

Co-authored-by: Haina Zhu <juhayna@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +111 -0
  3. config.json +41 -0
  4. pytorch_model.bin +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - en
5
+ - zh
6
+ pipeline_tag: audio-classification
7
+ tags:
8
+ - music
9
+ ---
10
+
11
+ # MuQ & MuQ-MuLan
12
+
13
+ <div>
14
+ <a href='#'><img alt="Static Badge" src="https://img.shields.io/badge/Python-3.8%2B-blue?logo=python&logoColor=white"></a>
15
+ <a href='https://arxiv.org/abs/2501.01108'><img alt="Static Badge" src="https://img.shields.io/badge/arXiv-2501.01108-%23b31b1b?logo=arxiv&link=https%3A%2F%2Farxiv.org%2F"></a>
16
+ <a href='https://huggingface.co/OpenMuQ'><img alt="Static Badge" src="https://img.shields.io/badge/huggingface-OpenMuQ-%23FFD21E?logo=huggingface&link=https%3A%2F%2Fhuggingface.co%2FOpenMuQ"></a>
17
+ <a href='https://pytorch.org/'><img alt="Static Badge" src="https://img.shields.io/badge/framework-PyTorch-%23EE4C2C?logo=pytorch"></a>
18
+ <a href='https://pypi.org/project/muq'><img alt="Static Badge" src="https://img.shields.io/badge/pip%20install-muq-green?logo=PyPI&logoColor=white&link=https%3A%2F%2Fpypi.org%2Fproject%2Fmuq"></a>
19
+ </div>
20
+
21
+
22
+ This is the official repository for the paper *"**MuQ**: Self-Supervised **Mu**sic Representation Learning
23
+ with Mel Residual Vector **Q**uantization"*. For more detailed information, we strongly recommend referring to https://github.com/tencent-ailab/MuQ and the [paper]((https://arxiv.org/abs/2501.01108)).
24
+
25
+ In this repo, the following models are released:
26
+
27
+ - **MuQ**(see [this link](https://huggingface.co/OpenMuQ/MuQ-large-msd-iter)): A large music foundation model pre-trained via Self-Supervised Learning (SSL), achieving SOTA in various MIR tasks.
28
+ - **MuQ-MuLan**(see [this link](https://huggingface.co/OpenMuQ/MuQ-MuLan-large)): A music-text joint embedding model trained via contrastive learning, supporting both English and Chinese texts.
29
+
30
+
31
+ ## Usage
32
+
33
+ To begin with, please use pip to install the official `muq` lib, and ensure that your `python>=3.8`:
34
+ ```bash
35
+ pip3 install muq
36
+ ```
37
+
38
+
39
+ Using **MuQ-MuLan** to extract the music and text embeddings and calculate the similarity:
40
+ ```python
41
+ import torch, librosa
42
+ from muq import MuQMuLan
43
+
44
+ # This will automatically fetch checkpoints from huggingface
45
+ device = 'cuda'
46
+ mulan = MuQMuLan.from_pretrained("OpenMuQ/MuQ-MuLan-large")
47
+ mulan = mulan.to(device).eval()
48
+
49
+ # Extract music embeddings
50
+ wav, sr = librosa.load("path/to/music_audio.wav", sr = 24000)
51
+ wavs = torch.tensor(wav).unsqueeze(0).to(device)
52
+ with torch.no_grad():
53
+ audio_embeds = mulan(wavs = wavs)
54
+
55
+ # Extract text embeddings (texts can be in English or Chinese)
56
+ texts = ["classical genres, hopeful mood, piano.", "一首适合海边风景的小提琴曲,节奏欢快"]
57
+ with torch.no_grad():
58
+ text_embeds = mulan(texts = texts)
59
+
60
+ # Calculate dot product similarity
61
+ sim = mulan.calc_similarity(audio_embeds, text_embeds)
62
+ print(sim)
63
+ ```
64
+
65
+
66
+ To extract music audio features using **MuQ**:
67
+ ```python
68
+ import torch, librosa
69
+ from muq import MuQ
70
+
71
+ device = 'cuda'
72
+ wav, sr = librosa.load("path/to/music_audio.wav", sr = 24000)
73
+ wavs = torch.tensor(wav).unsqueeze(0).to(device)
74
+
75
+ # This will automatically fetch the checkpoint from huggingface
76
+ muq = MuQ.from_pretrained("OpenMuQ/MuQ-large-msd-iter")
77
+ muq = muq.to(device).eval()
78
+
79
+ with torch.no_grad():
80
+ output = muq(wavs, output_hidden_states=True)
81
+
82
+ print('Total number of layers: ', len(output.hidden_states))
83
+ print('Feature shape: ', output.last_hidden_state.shape)
84
+
85
+ ```
86
+
87
+ ## Model Checkpoints
88
+
89
+ | Model Name | Parameters | Data | HuggingFace🤗 |
90
+ | ----------- | --- | --- | ----------- |
91
+ | MuQ | ~300M | MSD dataset | [OpenMuQ/MuQ-large-msd-iter](https://huggingface.co/OpenMuQ/MuQ-large-msd-iter) |
92
+ | MuQ-MuLan | ~700M | music-text pairs | [OpenMuQ/MuQ-MuLan-large](https://huggingface.co/OpenMuQ/MuQ-MuLan-large) |
93
+
94
+ **Note**: Please note that the open-sourced MuQ was trained on the Million Song Dataset. Due to differences in dataset size, the open-sourced model may not achieve the same level of performance as reported in the paper.
95
+
96
+ ## License
97
+
98
+ The code is released under the MIT license.
99
+
100
+ The model weights (MuQ-large-msd-iter, MuQ-MuLan-large) are released under the CC-BY-NC 4.0 license.
101
+
102
+ ## Citation
103
+
104
+ ```
105
+ @article{zhu2025muq,
106
+ title={MuQ: Self-Supervised Music Representation Learning with Mel Residual Vector Quantization},
107
+ author={Haina Zhu and Yizhi Zhou and Hangting Chen and Jianwei Yu and Ziyang Ma and Rongzhi Gu and Yi Luo and Wei Tan and Xie Chen},
108
+ journal={arXiv preprint arXiv:2501.01108},
109
+ year={2025}
110
+ }
111
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mulan": {
3
+ "sr": 24000,
4
+ "clip_secs": 10,
5
+ "dim_latent": 512,
6
+ "decoupled_contrastive_learning": true,
7
+ "hierarchical_contrastive_loss": false,
8
+ "hierarchical_contrastive_loss_layers": null,
9
+ "sigmoid_contrastive_loss": false,
10
+ "rank_contrast": true
11
+ },
12
+ "audio_model": {
13
+ "name": "OpenMuQ/MuQ-large-msd-iter",
14
+ "model_dim": 1024,
15
+ "use_layer_idx": -1
16
+ },
17
+ "text_model": {
18
+ "name": "xlm-roberta-base",
19
+ "model_dim": null,
20
+ "use_layer_idx": -1
21
+ },
22
+ "audio_transformer": {
23
+ "dim": 768,
24
+ "tf_depth": 0,
25
+ "heads": 8,
26
+ "dim_head": 64,
27
+ "attn_dropout": 0,
28
+ "ff_dropout": 0,
29
+ "ff_mult": 4
30
+ },
31
+ "text_transformer": {
32
+ "dim": 768,
33
+ "tf_depth": 8,
34
+ "max_seq_len": 1024,
35
+ "dim_head": 64,
36
+ "heads": 8,
37
+ "attn_dropout": 0,
38
+ "ff_dropout": 0,
39
+ "ff_mult": 4
40
+ }
41
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d42ae3f7cb9b66759ee0089ddc70e2f28b130c2d8ba621457358272d32dd0444
3
+ size 2653954401