Lead Sheet Reader endpoint: source
This is the complete source of the service behind Rudran Labs' Lead Sheet Reader: a photo of one handwritten jazz or
band lead sheet in, MusicXML (melody and chord symbols) out. It is published under the GNU Affero General Public
License v3.0 (LICENSE), because the staff detector it runs may be covered by AGPL-3.0 (below).
It is the same code, weights and dependency list as the private Hugging Face Inference Endpoint repository the
product runs, at commit 840bdf0e6d64a345bf52c1dfa82f57353eb3fe26. Only the vendored dependency wheels are left out:
they are the unmodified PyPI releases pinned in requirements.txt.
Copyright (C) 2026 Rudran Labs Inc. handler.py and kern2musicxml.py are free software: you can redistribute them
and/or modify them under the terms of the GNU Affero General Public License as published by the Free Software
Foundation, version 3. They are distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE for details.
What is here, and under which licence
| Path | What it is | Licence |
|---|---|---|
handler.py |
The endpoint handler: decodes the image, finds the staves, reads each one, writes MusicXML | AGPL-3.0, Rudran Labs |
kern2musicxml.py |
Converts the model's **kern and chord output to MusicXML with music21 | AGPL-3.0, Rudran Labs |
requirements.txt |
Exact dependency versions the endpoint installs | AGPL-3.0, Rudran Labs |
config.json, model.safetensors |
The SMT model JuanCarlosMartinezSevilla/jazzmus-model at revision b38466e738548cf4d3826a0426d709a711533618, unchanged |
MIT, see jazzmus_smt/LICENSE |
jazzmus_smt/ |
The model's code, from the authors' ISMIR-Jazzmus repository, unchanged | MIT, see jazzmus_smt/LICENSE |
yolo_staff_detector.onnx |
The jazzmus authors' yolo_staff_detector.pt (published under MIT), converted to ONNX by Rudran Labs |
AGPL-3.0 (see below) |
The staff detector is a YOLO11s model the authors trained with Ultralytics' software. Ultralytics states that models
trained with its software fall under AGPL-3.0, and the ONNX export's metadata says so too, so this repository treats
the detector, and the service that runs it, as AGPL-3.0. No Ultralytics code runs here: the detector runs on
onnxruntime (MIT), with letterboxing, box decoding and non-maximum suppression written in numpy in handler.py.
Both models were trained by their authors on their own JAZZMUS data.
Running it
The handler is written for Hugging Face's inference toolkit 0.5.6 CPU image (Python 3.11). That image installs
requirements.txt at startup. To run it outside the toolkit:
python3.11 -m venv .venv && . .venv/bin/activate
pip download --no-deps -d wheels --index-url https://download.pytorch.org/whl/cpu torch==2.14.1+cpu torchvision==0.29.1+cpu torchaudio==2.11.0+cpu
pip download --no-deps -d wheels sympy==1.14.0 transformers==4.57.6 huggingface_hub==0.36.2 tokenizers==0.22.2 \
hf-xet==1.7.0 onnxruntime==1.31.0 music21==10.5.0 gin-config==0.5.0 chardet==7.7.0 more-itertools==11.2.1 \
webcolors==25.10.0
pip install safetensors==0.8.0 einops==0.8.2 pillow==13.0.0 numpy==1.26.4 && PIP_NO_DEPS=1 pip install -r requirements.txt
Then, in Python:
import base64
from handler import EndpointHandler
h = EndpointHandler(".")
with open("page.jpg", "rb") as f:
out = h({"inputs": base64.b64encode(f.read()).decode(), "parameters": {"contentType": "image/jpeg"}})
print(out["staves"], out["musicxml"][:200])
Request: POST {"inputs": "<base64 image>", "parameters": {"contentType": "image/png|image/jpeg|image/webp"}}.
Response: 200 {"musicxml": "<text>", "staves": <int>}, or 400 {"error": "<code>"}. Images over 24 million
pixels are refused.
The result is a first draft to correct. It reads handwriting, and it can be wrong.
Contact
- Downloads last month
- 23