magenta / mt3

MT3: Multi-Task Multitrack Music Transcription
Apache License 2.0
1.41k stars 185 forks source link

error when running the "Transcribe Audio" stage #144

Closed mio-19 closed 3 months ago

mio-19 commented 8 months ago
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-5-689ff6dbf16f>](https://localhost:8080/#) in <cell line: 25>()
     23 note_seq.play_sequence(est_ns, synth=note_seq.fluidsynth,
     24                        sample_rate=SAMPLE_RATE, sf2_path=SF2_PATH)
---> 25 note_seq.plot_sequence(est_ns)

2 frames
[/usr/local/lib/python3.10/dist-packages/bokeh/core/has_props.py](https://localhost:8080/#) in _raise_attribute_error_with_matches(self, name, properties)
    373             matches, text = sorted(properties), "possible"
    374 
--> 375         raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
    376 
    377     def __str__(self) -> str:

AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width
jackbullen commented 6 months ago

I got the same issue and it is from the note_seq.plot_sequence function call. Likely because of a version incompatibility with bokeh library.

Despite this, est_ns = inference_model(audio) successfully completes, so you can get the midi file with note_seq.sequence_proto_to_midi_file(est_ns, "path_to_output_midi")

0xdevalias commented 3 months ago

After that fix, now getting a new issue unfortunately:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-6-689ff6dbf16f>](https://localhost:8080/#) in <cell line: 25>()
     23 note_seq.play_sequence(est_ns, synth=note_seq.fluidsynth,
     24                        sample_rate=SAMPLE_RATE, sf2_path=SF2_PATH)
---> 25 note_seq.plot_sequence(est_ns)

2 frames
[/usr/local/lib/python3.10/dist-packages/bokeh/core/has_props.py](https://localhost:8080/#) in _raise_attribute_error_with_matches(self, name, properties)
    373             matches, text = sorted(properties), "possible"
    374 
--> 375         raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
    376 
    377     def __str__(self) -> str:

AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width

Which seems to be at least these 2 issues:

Originally posted by @0xdevalias in https://github.com/magenta/mt3/issues/151#issuecomment-2126159018

Running the error I got here through ChatGPT suggested the following:

The error you encountered, AttributeError: unexpected attribute 'plot_width' to figure, similar attributes are outer_width, width or min_width, suggests that there is an issue with the usage of the plot_width attribute in a Bokeh figure object.

Bokeh, a visualization library for Python, uses figure objects to create plots, and it seems like the code is trying to set an attribute plot_width which does not exist. Instead, Bokeh provides width, outer_width, or min_width as valid attributes.

Looking at the colab file:

The relevant snippet of code that's failing is:

import note_seq

# ..snip..

inference_model = InferenceModel(checkpoint_path, MODEL)

# ..snip..

est_ns = inference_model(audio)

# ..snip..

note_seq.plot_sequence(est_ns)

We can see the note_seq library here:

And here is a relevant sounding PR that may be related to this issue:

Which notes:

As described in this stackoverflow question:

In the 3.0.0 bokeh release, the plot_width attribute of a figure was replaced with width. Similarly, plot_height was replaced with height. Even in the last 2.x.x release docs, they are described as "compatibility aliases" for width and height.

This pull request fixes this issue by following the stackover flow answer mentioned above.

Originally posted by @Yao-Lirong in https://github.com/magenta/note-seq/pull/72

Once that PR lands, it should fix the root cause, but until then, it sounds like the workaround is to use a pre-3.x version of Bokeh.

Searching the issues here, we can see that this was already suggested in another thread:

It worked, finally. I also downgraded bokeh so that midi image could come out normally. https://colab.research.google.com/drive/1JkWyAwFhAC6SJJ1Lvf4VPap6FwtniEuy?usp=sharing

Originally posted by @Jackl-o-o-l in https://github.com/magenta/mt3/issues/134#issuecomment-1657923778

iansimon commented 3 months ago

Should be fixed now.