homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format.
Jupyter Notebook
436
495 commits
updated Oct 15, 2026
homr is an Optical Music Recognition (OMR) software designed to transform camera pictures or PDFs of sheet music into machine-readable MusicXML format. The resulting MusicXML files can be further processed using tools such as musescore.
For a quick try, visit our online demo at homr.site or
You might also want to check out Andromr, an Android app for optical music recognition using homr.
The easiest way to get started is using uvx (uv must be installed). Select an inference backend:
CPU: uvx --from 'homr[cpu]' homr <image>
NVIDIA CUDA: uvx --from 'homr[cuda]' homr <image>
AMD ROCm: uvx --python 3.12 --from 'homr[rocm]' homr <image>
The resulting MusicXML file will be saved in the same directory as the input image
poetry install --only main --extras cpupoetry install --extras cpu--extras cpu to --extras cuda / --extras rocmpoetry run homr <image>poetry run homr <image_1> <image_2>merged_image_1.musicxmlThe example below provides an overview of the current performance of the implementation. While some errors are present in the output, the overall structure remains accurate.
| Original Image | homr Result |
|---|---|
![]() |
The homr result is obtained by processing the homr output and rendering it with musescore.
Depending on the input, preprocessing the image can improve the results. A common step is to remove the background from scanned images.
The current implementation focuses on pitch and rhythm information on the bass or treble clef, neglecting dynamics, articulation, double sharps/flats, and other musical symbols.
homr uses a two-stage pipeline: segmentation for structural analysis followed by semantic symbol recognition via transformer models.
homr employs UNet-based segmentation models (adapted from oemer) to extract structural components from the sheet music image:
The segmentation process generates bounding boxes for each detected element. These predictions serve as inputs for the staff detection algorithm.
Using the segmentation outputs, homr constructs staffs through the following steps:
Staff Anchor Detection: The algorithm identifies "staff anchors" (clefs and bar lines) that serve as reference points for accurate staff localization, even when symbols partially obscure staff lines.
Unit Size Estimation: For each staff, the algorithm calculates the "unit size" (distance between staff lines). This accommodates camera perspective variations and non-uniform staff spacing.
Staff Reconstruction: Around each anchor, five staff lines are located and the remaining staff structure is reconstructed using the estimated unit size.
Grand Staff Merging: Braces and brackets are identified to merge related staffs, supporting:
Each staff is dewarped (perspective-corrected) and passed through a transformer-based model (based on Polyphonic-TrOMR) that performs end-to-end symbol sequence recognition. The model outputs:
The transformer model generates these predictions in sequence, processing the dewarped staff image to understand the spatial and temporal relationships between musical symbols.
Note: The transformer output provides the sequence of symbols but does not include explicit positional information (horizontal or vertical coordinates). However, the model computes the center of attention as a byproduct of the attention mechanism, which is used to estimate the focus point on the staff image. homr maps this point back to the input image and writes it as a comment into each note of the MusicXML output, e.g. <!-- imgpos: 45, 231 -->. These are rough positions: they point at or near the symbol, but aren't pixel-exact.
The symbol sequence is converted into MusicXML format and saved to disk. The resulting file can be processed with tools like musescore or relieur (for multi-image combinations).
homr is licensed under AGPL-3.0. For commercial use and the licenses of the training data behind the model weights, see LICENSE_FAQ.md.
If you use this code in your research work, please cite oemer and Polyphonic-TrOMR.
The name "homr" stands for Homer's Optical Music Recognition (OMR), leaving the interpretation of "Homer" to the user's discretion, whether referring to the ancient poet Homer or the iconic character from The Simpsons.
This project builds upon previous work, including:
141 followers · starred Jan 2026
51 followers · starred Mar 2026
201 followers · starred Jul 2026
469 followers · starred Sep 2026
homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format.
Jupyter Notebook
436
495 commits
updated Oct 15, 2026
homr is an Optical Music Recognition (OMR) software designed to transform camera pictures or PDFs of sheet music into machine-readable MusicXML format. The resulting MusicXML files can be further processed using tools such as musescore.
For a quick try, visit our online demo at homr.site or
You might also want to check out Andromr, an Android app for optical music recognition using homr.
The easiest way to get started is using uvx (uv must be installed). Select an inference backend:
CPU: uvx --from 'homr[cpu]' homr <image>
NVIDIA CUDA: uvx --from 'homr[cuda]' homr <image>
AMD ROCm: uvx --python 3.12 --from 'homr[rocm]' homr <image>
The resulting MusicXML file will be saved in the same directory as the input image
poetry install --only main --extras cpupoetry install --extras cpu--extras cpu to --extras cuda / --extras rocmpoetry run homr <image>poetry run homr <image_1> <image_2>merged_image_1.musicxmlThe example below provides an overview of the current performance of the implementation. While some errors are present in the output, the overall structure remains accurate.
| Original Image | homr Result |
|---|---|
![]() |
The homr result is obtained by processing the homr output and rendering it with musescore.
Depending on the input, preprocessing the image can improve the results. A common step is to remove the background from scanned images.
The current implementation focuses on pitch and rhythm information on the bass or treble clef, neglecting dynamics, articulation, double sharps/flats, and other musical symbols.
homr uses a two-stage pipeline: segmentation for structural analysis followed by semantic symbol recognition via transformer models.
homr employs UNet-based segmentation models (adapted from oemer) to extract structural components from the sheet music image:
The segmentation process generates bounding boxes for each detected element. These predictions serve as inputs for the staff detection algorithm.
Using the segmentation outputs, homr constructs staffs through the following steps:
Staff Anchor Detection: The algorithm identifies "staff anchors" (clefs and bar lines) that serve as reference points for accurate staff localization, even when symbols partially obscure staff lines.
Unit Size Estimation: For each staff, the algorithm calculates the "unit size" (distance between staff lines). This accommodates camera perspective variations and non-uniform staff spacing.
Staff Reconstruction: Around each anchor, five staff lines are located and the remaining staff structure is reconstructed using the estimated unit size.
Grand Staff Merging: Braces and brackets are identified to merge related staffs, supporting:
Each staff is dewarped (perspective-corrected) and passed through a transformer-based model (based on Polyphonic-TrOMR) that performs end-to-end symbol sequence recognition. The model outputs:
The transformer model generates these predictions in sequence, processing the dewarped staff image to understand the spatial and temporal relationships between musical symbols.
Note: The transformer output provides the sequence of symbols but does not include explicit positional information (horizontal or vertical coordinates). However, the model computes the center of attention as a byproduct of the attention mechanism, which is used to estimate the focus point on the staff image. homr maps this point back to the input image and writes it as a comment into each note of the MusicXML output, e.g. <!-- imgpos: 45, 231 -->. These are rough positions: they point at or near the symbol, but aren't pixel-exact.
The symbol sequence is converted into MusicXML format and saved to disk. The resulting file can be processed with tools like musescore or relieur (for multi-image combinations).
homr is licensed under AGPL-3.0. For commercial use and the licenses of the training data behind the model weights, see LICENSE_FAQ.md.
If you use this code in your research work, please cite oemer and Polyphonic-TrOMR.
The name "homr" stands for Homer's Optical Music Recognition (OMR), leaving the interpretation of "Homer" to the user's discretion, whether referring to the ancient poet Homer or the iconic character from The Simpsons.
This project builds upon previous work, including:
141 followers · starred Jan 2026
51 followers · starred Mar 2026
201 followers · starred Jul 2026
469 followers · starred Sep 2026