-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update README.md #10
Comments
This is very cool! I've been meaning to port this over to python for a while now, so I'm really happy you've gotten this started! However, before I link to it, I would want to have some tests running to ensure that the outputs of the two programs are always identical. Ideally, this would be a full evaluation for a few different (long) pieces, as well as some unit tests of some of the main functions, comparing the python output to the java output. I'm not sure what's the best way to do this at the moment, aside from just writing a python script and a java script that each print verbose output at each step, and then compare their output. I would also hope to add to your readme a note that the canonical version is (at least for now) the java code (ie, it is best to check the final results with the java code, at least until the above tests are working). For example, I was looking through your DTW code and noticed this But overall, I'm very excited about this! Let me know if you'd like me to help you work on this at all. |
Hi, will be great to have some help to do this tests, I think we can do to do some output tests for now, for example, add some midi files to repository and execute the command line of Java version and compare both output values. I have executed it with some pieces from my work, but my dataset have some bias from the instrument and the style of music. I think will be great if you can share more pieces to we write this unit tests. You have an good point on DTW, my mistake, I will fix that, thanks 👍 |
I've made some example inputs/outputs here for you to test: test-examples.zip The original scores come from the MusicXML scores from ASAP, and I manually edited some errors into them. I converted the scores to MIDI using musescore as described in the MV2H readme. Then, I used the java converter to convert them to the text format. Both the MIDI and the txt files are included in the zip, so you can test the MIDI -> txt conversion that way. I also ran a few different specific tests:
More tests are in Command: -g test-examples/Bach-846p-orig.mid.txt -t test-examples/Bach-846p-edited.mid.txt -a -p 0.0 I also ran tests on all of the pairs of alignments using a bash command found in the Please let me know if something doesn't make sense! |
These should be good for now, but the process is a bit messy. In the future, it would be good to have better tests, both with actual transcriptions, and some unit testing. |
And here are some actual transcription examples (thanks to Lele Liu: @cheriell) and their outputs with and without -a. Also converted from xml to midi using musescore3. |
Hey, I'm finishing of writing the unit test's to compare the Java Version with the Python, but one of the tasks:
When I use this with the Something like: The total calculated after by I'm removing this case from tests for now, but it's really necessary investigate why this is happen. (For replicate that in Java, you need to change to BigInteger, long not support that value too, if you want I can provide my changes in one pull request). I think the cause is the probably trying to align two different music's (I don't know) I have added test's to the Python Version to compare the Java Version output to the Python Version, you can see it here. Basically it run's the parameters described here, execute the same parameters on python version and compare it with the python output values. Python version code coverage:
|
Thank you for pointing out that bug! I've just fixed it in the most recent release, and confirm that the count you get is what the java code now gets as well. But I don't think it's a bug with the DTW implementation, but rather due to the fact that there are just so many non-matching notes in cases like that (and the pieces are so long). In such cases, depending on the penalty, we might have something like The tests look really nice! Can you run also the most recent examples from Lele? These are also much more realistic examples, but I assume they will be fine since the previous ones were. Also, can you tell me what commands you've run exactly for these tests? I'd like to play around with them a bit on my machine with some different outputs, etc. This is looking really good, though! :D |
I also added a preliminary link to the readme here. |
Thanks, I will add the others cases provided on Lele samples later today, and add some tests to coverage the midi conversion too |
Included the new test cases from Lele Liu (@cheriell). Before you execute the tests, you need to install the pyMV2H on your enviroment (root, virtualenv, conda, etc) To do this, you may need to run: pip install -e . This will install the package based on the current directory, after that you just need to run To see the code code-coverage report, after the tests run: coverage report -m |
The tests look very nice! The python program is quite slow though. For example, when I run the following java command (using Lele's files), it takes on 3 seconds:
However, with the python, this is still very slow. I made a lot of improvements for Lele in the past couple of months, so maybe you can have a look at this PR for how I sped up the computation significantly. You can profile the python code using this command:
In particular, it looks like the convert_time function is quite slow (I added caching for this function, I think). I also added caching in a couple of places when getting the F1 of two note_sets, I think. Let you know if you need some help with this. |
I have made some improvements here: lucasmpaim/pyMV2H#1 The The performance for this case keep really slow, with that PR decrease a lot, but is running in ~2min on my macbook pro m1, I think don't have more things to do in Python side to improve this, the code complexity (number of large loop's) is big, and the work for improve this on python way, (using list comprehension, or other's things) will get a lot of time. For improve this, I think is better rewrite the align and DTW in C++ and integrate it with Cython to get a good performance like's Java version's. |
I would be surprised if C++ would be necessary. Python is not really slower than java (especially by this much) for simple cases like this. I was looking into your convert_time code and noticed 2 errors:
I suspect the first will speed up the code significantly. |
I noticed a few other points as well (the get_distance function seems to be the slowest now...):
In
to:
Finally, the I hope these will help. |
I have implemented an pure-python version of this metrics for a better integration with python frameworks (such: pytorc, tensorflow and others), I'm using it for my own research with AMT system.
I think will be great reference that repository on README, will help a lot the community that don't want to use something like
JPype
and write JVM code or make an wrapper of it.You can see it here
Thanks ;)
The text was updated successfully, but these errors were encountered: