Instructions to use guang-yang/legato-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use guang-yang/legato-2 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="guang-yang/legato-2")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("guang-yang/legato-2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Legato 2
Paper (NeurIPS 2026) · Code (release v2.0)
Full-page optical music recognition. A detector finds the systems on a page and a transcriber reads each one in turn, conditioned on the ABC it has already produced for the systems above it, so the notation stays consistent down the page.
Both halves live here: model.safetensors is the transcriber, segmenter.pt the YOLO line
detector. They are versioned together because a change to either one changes the result.
Usage
Install the code from GitHub (the environment is pinned in
requirements.txt), then:
from legato.pipeline import Legato2
omr = Legato2.from_pretrained("guang-yang/legato-2", device="cuda:0")
abc = omr("page.png")
Decoding follows the paper by default: greedy (beam size 1), repetition penalty 1.1, maximum
length 2048; segmentation uses confidence 0.7 at image size 640. All of these can be
overridden per call, for example omr("page.png", beam_size=10, yolo_conf=0.5).
A PDF can be transcribed from the command line, where it is first rendered to one tall image so a multi-page score is read as a single piece:
python scripts/run_legato2.py --image_path score.pdf --model_path guang-yang/legato-2
Checkpoint
legato-segment-bytes-tokenizer-lr-3e-4-cosine-e5-b32-v4096: byte-level tokenizer with a
4096-entry vocabulary, learning rate 3e-4 on a cosine schedule, five epochs at batch size 32.
Evaluation
OMR-NED, lower is better. Scored with our musicdiff fork (5.2) on music21 9.9.1 and converter21 4.0.1; the ABC is converted to MusicXML with abc2xml followed by a MuseScore 3.6.2 rewrite, which is part of the measurement and shifts the figures by one to two points if skipped.
| Dataset | Legato 2 | Legato 1 | Audiveris | Gemini 3.1 Pro |
|---|---|---|---|---|
| Camera OpenScore String Quartets | 31.6 | 58.3 | 70.6 | 94.8 |
| Rendered OpenScore String Quartets | 17.1 | 32.6 | 37.8 | 93.5 |
| Camera OpenScore Lieder (v1.2) | 38.3 | 49.0 | 52.0 | 87.2 |
| Rendered OpenScore Lieder (v1.2) | 27.7 | 34.4 | 29.5 | 86.7 |
| IMSLP Piano Scores | 36.6 | 43.8 | 66.1 | 89.1 |
| PDMX-Synth test (page level) | 21.7 | 27.4 | 35.3 | 85.2 |
Audiveris is version 5.11.0 with text recognition enabled. These figures differ from the first arXiv version of the paper because the evaluation was made fully end to end and pinned: PDMX-Synth pages are segmented by YOLO instead of using stored system crops, IMSLP Piano Scores uses the PNG images released on Hugging Face, OpenScore Lieder uses version 1.2, and Legato 1 is re-run under the same setup. The next arXiv version will report these numbers.
License
The two files in this repository are licensed separately:
| File | License |
|---|---|
model.safetensors |
Llama 3.2 Community License. Its vision encoder is the encoder of Llama 3.2 11B Vision, kept frozen during training. |
segmenter.pt |
AGPL-3.0. It was trained with Ultralytics YOLO. |
Built with Llama. Llama 3.2 is licensed under the Llama 3.2 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.
Citation
@inproceedings{yang2026legato2,
title={{LEGATO} 2: Toward Multimodal Sheet Music Recognition and Understanding},
author={Guang Yang and Brian Siyuan Zheng and Victoria Ebert and Noah A. Smith},
booktitle={The Fortieth Annual Conference on Neural Information Processing Systems},
year={2026},
eprint={2607.05769},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2607.05769}
}
- Downloads last month
- 4