MusicLang / musiclang_predict

AI Prediction api of the MusicLang package
GNU General Public License v3.0
250 stars 16 forks source link

Trying to call predict leads to error `'module' object is not callable` #26

Closed readicculus closed 3 months ago

readicculus commented 3 months ago

I am trying to run the example from the docs https://musiclang.readthedocs.io/en/latest/auto_examples/01_basics/04_predict_new_music.html

from musiclang_predict import predict, MusicLangTokenizer
from transformers import GPT2LMHeadModel

model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-4k')
tokenizer = MusicLangTokenizer('musiclang/musiclang-4k')

# Predict a 8 bar song in 4/4 time signature with this model
soundtrack = predict(model, tokenizer, chord_duration=4, nb_chords=4)
soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4))

and I get the below error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 8
      5 tokenizer = MusicLangTokenizer('musiclang/musiclang-4k')
      7 # Predict a 8 bar song in 4/4 time signature with this model
----> 8 soundtrack = predict(model, tokenizer, chord_duration=4, nb_chords=4)
      9 soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4))

TypeError: 'module' object is not callable

Any idea if I'm doing anything wrong here? I installed musiclang-predict and you can see my package versions below.


%python -V
Python 3.12.2

% pip list | grep musiclang
musiclang               0.26.0
musiclang-predict       1.2.0
floriangardin commented 3 months ago

The examples were outdated, I updated the examples documentation to reflect new api of musiclang predict. It should work now.

readicculus commented 3 months ago

makes sense, thanks