Views
No views yet
1pip install torch transformers librosa soundfile numpy
2pip3 install muq1from huggingface_hub import snapshot_download
2import os
3
4local_dir = snapshot_download(repo_id="nishitanand/FIGMA")
5ckpt = os.path.join(local_dir, "figma.ckpt")1import torch, librosa
2from figma_model import Figma, get_tokenizer
3
4device = "cuda"
5model = Figma.from_checkpoint(ckpt, device=device) # ckpt from the download step
6tok = get_tokenizer()
7
8# Text embedding
9t = tok(["a song in F minor at 120 BPM in 4/4 time"], return_tensors="pt",
10 padding="max_length", truncation=True, max_length=128).to(device)
11text_emb = model.encode_text(t) # [1, 512], L2-normalized
12
13# Audio embedding (24 kHz mono -> [B, 1, samples])
14wav, _ = librosa.load("clip.wav", sr=24000)
15wav = torch.tensor(wav)[None, None].to(device)
16audio_emb = model.encode_audio(wav) # [1, 512], L2-normalized
17
18similarity = (audio_emb @ text_emb.T).item()1python inference.py --checkpoint figma.ckpt \
2 --audio_dir ./clips --query "a jazzy track in C major at 90 bpm" --topk 51@inproceedings{figma2026,
2 title = {FIGMA: Towards FIne-Grained Music retrievAl},
3 author = {Anand, Nishit and Seth, Ashish and Ghosh, Sreyan and Manocha, Dinesh and Duraiswami, Ramani},
4 booktitle = {Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics},
5 year = {2026},
6 url = {https://arxiv.org/abs/2606.06615}
7}