tsumugi-mrl
Pretrained music audio encoder from Tsumugi-MRL, with utilities for LoRA fine-tuning. The encoder reads stereo audio at 22,050 Hz and returns 512-dimensional frame features at 25 Hz.
Install
pip install tsumugi-mrl
The package requires PyTorch 2.7 or later. For GPU support, install the CUDA
build of torch and torchaudio for your platform from
pytorch.org first.
Extract features
import torch
from tsumugi_mrl import TsumugiMRLModel
model = TsumugiMRLModel.from_pretrained("anime-song/tsumugi-mrl").eval()
audio = torch.randn(1, 2, 22_050 * 4) # [batch, 2, samples], stereo 22,050 Hz
with torch.no_grad():
hidden = model(audio) # [batch, frames, 512]
clip = model.mean_pool(hidden) # [batch, 512]
Convert mono audio by repeating the channel. No pretraining objective trains
audio_projection, so use the frame features or their mean rather than
encode_embedding() unless you fine-tune that head.
Fine-tune with LoRA
import torch
from tsumugi_mrl import TsumugiMRLModel, apply_lora, load_lora, save_lora
encoder = TsumugiMRLModel.from_pretrained("anime-song/tsumugi-mrl")
apply_lora(encoder, rank=8, alpha=16) # q/k/v in all layers; other weights frozen
head = torch.nn.Linear(encoder.config.d_model, 10)
parameters = [p for p in encoder.parameters() if p.requires_grad] + list(head.parameters())
optimizer = torch.optim.AdamW(parameters, lr=1e-4)
# ... train ...
save_lora(encoder, "lora") # lora_config.json + lora.safetensors
restored = load_lora(TsumugiMRLModel.from_pretrained("anime-song/tsumugi-mrl"), "lora")
LoRAConfig selects other targets (to_out.0, to_gates, feed-forward
net.1/net.4), a subset of layers, per-pattern ranks, and extra trainable
parameters. merge_lora(model, unload=True) folds the adapters into ordinary
nn.Linear layers. See the
repository README
for details.
License
The code is released under the MIT License. The pretrained weights on the Hugging Face Hub are released separately under CC BY-NC 4.0.
Metadata
Release files for tsumugi-mrl 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tsumugi_mrl-0.1.1.tar.gz | 16.0 kB | Without provenance | Details for tsumugi_mrl-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tsumugi_mrl-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for tsumugi_mrl-0.1.1-py3-none-any.whl |
Total release size: 32.3 kB
Release files / tsumugi_mrl-0.1.1.tar.gz
| Download URL | tsumugi_mrl-0.1.1.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2721d7ef8747bdbf8a4048fea5b5a92871e965f820726374dbbd621fdb1b9a70
|
|
BLAKE2b-256 checksum How to use checksums |
39f8aa2cf9f76af3aafc27717e45c0581224f822721ef1f8c60691425a4b05a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Release files / tsumugi_mrl-0.1.1-py3-none-any.whl
| Download URL | tsumugi_mrl-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ea6c4b555a2fac0f262d14c40b54da50458acfbde9037aa69dd2605c40470f2
|
|
BLAKE2b-256 checksum How to use checksums |
31a02aa6caa079be286939625f873ec342f9ead300017169b00f1ca71d39d884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Security for tsumugi-mrl 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.