RepositoryJupyter NotebookDEGermany
liebharc

liebharc/homr

homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format.

501stars
93forks
5issues
8views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: optical-music-recognition

#1 Repository of the week

1
TINIX TRENDING·Topic: omr

#1 Repository of the week

2
TINIX TRENDING·Topic: sheet-music

#2 Repository of the week

homr

homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format. The resulting MusicXML files can be further processed using tools such as musescore.

Open In Colab

You might also want to check out Andromr, an Android app for optical music recognition using homr.

Prerequisites

  • Python 3.11
  • Poetry
  • Optional: NVidia GPU with CUDA 12.1

Getting started (uv)

The easiest way to get started is using uvx (uv must be installed). Note that is does not make use of the GPU.

  • uvx homr <img>
  • The resulting MusicXML file will be saved in the same directory as the input image
  • To combine the MusicXML results from multiple images, you can use relieur

Getting started (poetry)

  • Clone the repository
  • Install dependencies for:
    • GPU (requires CUDA): poetry install --only main,gpu
    • CPU: poetry install --only main
    • Development: poetry install
  • Run the program using poetry run homr <image>
  • The resulting MusicXML file will be saved in the same directory as the input image
  • To combine the MusicXML results from multiple images, you can use relieur

Example

The 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 Imagehomr Result
Go to https://github.com/liebharc/homr if this image isn't displayed

The homr result is obtained by processing the homr output and rendering it with musescore.

Limitations

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.

Technical Details

homr uses a two-stage pipeline: segmentation for structural analysis followed by semantic symbol recognition via transformer models.

Stage 1: Image Segmentation and Structural Analysis

homr employs UNet-based segmentation models (adapted from oemer) to extract structural components from the sheet music image:

  • Staff lines and symbols: Detected via trained segmentation networks that identify:
    • Staff line fragments
    • Note heads
    • Stems and rests
    • Bar lines
    • Clefs and key signatures

The segmentation process generates bounding boxes for each detected element. These predictions serve as inputs for the staff detection algorithm.

Stage 2: Staff Detection and Merging

Using the segmentation outputs, homr constructs staffs through the following steps:

  1. 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.

  2. 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.

  3. Staff Reconstruction: Around each anchor, five staff lines are located and the remaining staff structure is reconstructed using the estimated unit size.

  4. Grand Staff Merging: Braces and brackets are identified to merge related staffs, supporting:

    • Grand staffs (piano, organ)
    • Multiple voices on a single staff
    • Mixed instrument groups

Stage 3: Semantic Symbol Recognition via Transformer

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:

  • Rhythm symbols: Note durations, rests, and tuplet information
  • Pitch information: Absolute pitch values with accidentals (sharps, flats, naturals)
  • Articulation marks: Accents, staccato, tenuto, and slur markers
  • Performance annotations: Dynamic expressions and other musical notation

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 can be used to estimate the focus point on the staff image.

Stage 4: MusicXML Output

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).

Citation

If you use this code in your research work, please cite oemer and Polyphonic-TrOMR.

Name

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.

Thanks

This project builds upon previous work, including:

Similar Projects

Discover other similar projects and AI models.

Dataset
HugoSchtr/debussy-omr-fullpage-lvl

Debussy OMR – Full-Page Level Dataset A dataset of 101 paired samples of full-page images from handwritten music scores written by Claude Debussy (French Composer, 1862 - 1918) and their corresponding MusicXML transcriptions. The manuscript images originate from the collections of the Bibliothèque nationale de France (BnF) and were accessed through the IIIF protocol. Dataset Description Property Value Samples 101 Documents 37 Image format JPEG… See the full description on the dataset page: https://huggingface.co/datasets/HugoSchtr/debussy-omr-fullpage-lvl.

♥0
174
Mar 11, 2026
Dataset
HugoSchtr/debussy-omr-system-lvl

Debussy OMR – System-Level Dataset A dataset of 491 paired samples of cropped system images from handwritten music scores written by Claude Debussy (French Composer, 1862 - 1918) and their corresponding MusicXML transcriptions. The manuscript images originate from the collections of the Bibliothèque nationale de France (BnF) and were accessed through the IIIF protocol. Dataset Description Property Value Samples 491 Documents 37 Pages 101 Image… See the full description on the dataset page: https://huggingface.co/datasets/HugoSchtr/debussy-omr-system-lvl.

♥0
153
Mar 11, 2026
RepositoryJupyter Notebook
Quackone/homr_gui

Desktop GUI for HOMR optical music recognition — screenshot or drag a score and convert it to MusicXML & MIDI in one click.

138
Sep 5, 2026
RepositoryPython
AbdallahHemdan/Orchestra

Orchestra is a sheet music reader (optical music recognition (OMR) system) that converts sheet music to a machine-readable version.

143
Jun 20, 2023
RepositoryPython
OMR-Research/MeasureDetector

A Deep Learning based detector for measures in musical scores

53
Jun 14, 2026
RepositoryKotlin
team-spotube/spotube

🎧 Open source music streaming app! Available for both desktop & mobile!

51.1k
Dec 1, 2026
RepositoryTypeScript
pear-devs/pear-desktop

Pear 🍐 is extension for music player

34.1k
Nov 27, 2026
RepositoryDart
qier222/YesPlayMusic

A better-looking desktop music player for local files, media servers, and plugins. For macOS, Windows and Linux.

33.9k
Dec 1, 2026
RepositoryPython
spotDL/spotify-downloader

Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).

27.0k
Nov 22, 2026