MusicLang / musiclang

BSD 2-Clause "Simplified" License
170 stars 13 forks source link

Issue loading midi file Mac OSX causing error in MusicLangPredictor.predict_chords #53

Open readicculus opened 6 months ago

readicculus commented 6 months ago

I've tried using Python 3.11 and 3.12 (3.12.2) now and having the same issue running the sample code to generate based on an example, in this case the provided bach_847 from the corpus. I'm on Mac OSX Sonoma 14.4.1. I am not familiar with the underlying libraries loading midi or even the file format of midi really and I've been trying for a while now to figure out how to fix the issue with no success. Any help would be greatly appeciated.

Code I ran

from musiclang_predict import MusicLangPredictor
from musiclang_predict import corpus

song_name = 'bach_847' # corpus.list_corpus() to get the list of available songs
chord_progression = "Cm C7/E Fm F#dim G7 Cm"
nb_tokens = 1024 
temperature = 0.8 
top_p = 1.0 
seed = 3666 

ml = MusicLangPredictor('musiclang/musiclang-v2')

score = ml.predict_chords(
    chord_progression,
    score=corpus.get_midi_path_from_corpus(song_name),
    time_signature=(4, 4),
    nb_tokens=1024,
    prompt_chord_range=(0,4),
    temperature=temperature,
    topp=top_p,
    rng_seed=seed # set to 0 to unset seed
)

There error I get is

type object '_PurePosixPath' has no attribute '_from_parts'

When I run

corpus.get_midi_path_from_corpus(song_name)

I get

'/Users/yuvalboss/Projects/SANDBOX/musiclang-test/.venv/lib/python3.12/site-packages/musiclang_predict/corpus/bach_847.mid'

which exists and i'm able to load and play this midi successfully via MuseScore4. And here is the stack trace and the text if that is easier to work with stacktrace.txt

image image image image
readicculus commented 6 months ago

I force upgraded the package this error is coming from using pip install partitura --upgrade --force

and things work now but pip is not happy with the incompatibilities even though it did the upgrade. I may end up forking and using my own musiclang for now but might be worth looking into upgrading this dependency.

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
musiclang 0.26.0 requires mido==1.2.10, but you have mido 1.3.2 which is incompatible.
musiclang 0.26.0 requires partitura==1.3.1, but you have partitura 1.4.1 which is incompatible.
musiclang 0.26.0 requires xmlschema==2.1.1, but you have xmlschema 3.2.1 which is incompatible.

Things are working now though!