Skip to main content

End-to-end Optical Music Recognition (OMR) system build on top of vision transformers.

Project description

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.

Prequisites

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

Getting started

  • Clone the repository
  • Install dependencies using 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

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 Image homr Result

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

Technical Details

homr employs segmentation techniques outlined in oemer to identify staff lines, clefs, bar lines, and note heads in an image. These components are combined to determine the position of staffs within the picture.

Subsequently, each staff image undergoes transformation using a transformer model (based on Polyphonic-TrOMR) to identify symbols present on the staff. Pitch information is cross-validated with note head data obtained from the segmentation model.

The results are then converted into MusicXML format and saved to disk.

Image Predictions

homr utilizes oemer's UNet implementations to isolate staff lines and other symbols for note head identification. These predictions serve as input for staff and symbol detection.

Preprocessing the image has shown to enhance robustness against noisy backgrounds and variations in brightness.

Staff and Symbol Detection

The detection process involves extracting model data types from the image predictions. A key concept is the "staff anchor," which serves as a reference point ensuring accurate staff detection amidst symbols that might obscure it. Clefs and bar lines are currently utilized as anchor symbols.

For each anchor, the algorithm attempts to locate five staff lines and constructs the remainder of the staff around these anchors.

Unit Sizes

The unit size denotes the distance between staff lines, which may vary due to camera perspective. To accommodate this, the unit size is calculated per staff.

Connecting Staffs

Support for multiple voices and grand staffs is facilitated by identifying braces and brackets to combine individual staffs.

Rhythm Parsing

Dewarped images of each staff are computed and passed through a transformer to extract staff contents. From this point onward, semantic information from the sheet music is utilized rather than pixel-based data.

XML Generation

The previous outputs in terms of result model objects are used to generate music XML.

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

homr-0.1.0.tar.gz (71.0 kB view details)

Uploaded Source

Built Distribution

homr-0.1.0-py3-none-any.whl (81.4 kB view details)

Uploaded Python 3

File details

Details for the file homr-0.1.0.tar.gz.

File metadata

  • Download URL: homr-0.1.0.tar.gz
  • Upload date:
  • Size: 71.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/6.5.0-1021-azure

File hashes

Hashes for homr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7062c7efbeeac6a1200d515bd2341e3ebba1ffa982a1bc703c79cadec866f4a
MD5 d52be966c0fdfce66d8525d6f68444d3
BLAKE2b-256 bf50b3426c5df44c832f2d69b65941364b535758bad9885715130707a4210960

See more details on using hashes here.

File details

Details for the file homr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: homr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 81.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/6.5.0-1021-azure

File hashes

Hashes for homr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cfc91b43d99f8c280f38e70a426556b458e1bd25e8c88cb6eb55c9e665934ad
MD5 d32274286b0f84f696316d69a106f5fc
BLAKE2b-256 d21c5965ec196639a8366b8303b6c04ba0ed79f2e1eba44e864b2d42188bd689

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page