liebharc / homr

homr is an Optical Music Recognition (OMR) software designed to transform camera pictures of sheet music into machine-readable MusicXML format.
GNU Affero General Public License v3.0
6 stars 2 forks source link

How to run on multiple pages? #5

Open emonigma opened 1 month ago

emonigma commented 1 month ago

I have sheet music on multiple pages. I could append the several files horizontally or vertically, but doing so over multiple files is tedious. Could HOMR provide a way to combine or concatenate the several pages at the output instead of the input?

liebharc commented 3 weeks ago

Hello @emonigma , just to double-check: What you would need is that homr takes e.g. image1.jpg, image2.jpg, image3.jpg and gives you a single musicxml file with the contents of all three images?

emonigma commented 3 weeks ago

Yes, exactly. I could learn about the XML format of MusicXML, or how to concatenate them in MuseScore, but I think it would be a nice use case of getting several images into a single XML file. Thanks for considering it!

liebharc commented 2 weeks ago

I was thinking about this: homr detection isn't perfect and likely never will be. The transformer at its core has some randomness, which can yield slightly different results for the same input. So, if you have several pages of sheet music, a good workflow might be:

This approach allows you to select the best result for each page, rather than hoping the processing of all files gives you a good result.

From this perspective, a separate script to concatenate musicxml files might be a better solution. I might add one in the future if I find the time—right now, my focus is still on improving detection in homr. However, if you'd like to contribute such a script, I'd be happy to accept a PR!

The script itself shouldn't be hard to write:

There is also this file https://github.com/liebharc/homr/blob/main/training/music_xml.py which parses musicxml files during training. However, I regret using xmltodict for it. For xml generation in homr (https://github.com/liebharc/homr/blob/main/homr/xml_generator.py) I switched to musicxml which works much better. Both scripts might help in writing a concatenation script.

emonigma commented 2 weeks ago

Hi! That's a good idea and I tested it on a melody that had two pages, then joined them in MuseScore. It works! But fixing the piano chords to coincide with the original ended up being a lot of work, so for my use case, I decided to simply hire a musician to record my scores. I'm sorry I won't be using HOMR in the immediate future, but it's good to know that this technology exists and provides good results in case I want to publish these scores.

Feel free to close the issue. Thanks!

liebharc commented 2 weeks ago

Hi @emonigma, makes sense! I'll leave the issue open in case someone else wants to add something to it.