Skip to content
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

Tensor error #3

Closed
asigalov61 opened this issue Sep 5, 2022 · 7 comments
Closed

Tensor error #3

asigalov61 opened this issue Sep 5, 2022 · 7 comments

Comments

@asigalov61
Copy link
Contributor

Hey @billyblu2000

I am getting a strange tensor error on my test melody. So I was wondering if you can help me out to figure out what I am doing wrong...

Here is the traceback:

Searching for Phrase 1 Searching for Phrase 2 Searching for Phrase 3 Reference chosen: [(144, '倒带'), (144, '倒带'), (144, '倒带')] Pitch Transposition (Fit by Model): [-3, 2, 2] Generating... Traceback (most recent call last): File "demo.py", line 14, in <module> cdt.generate_save(demo_name + '_output_results') File "/content/AccoMontage2/chorderator/interaction.py", line 91, in generate_save return _core.generate_save(output_name=output_name, task=task, log=log, wav=wav, **kwargs) File "/content/AccoMontage2/chorderator/core.py", line 392, in generate_save log=True, **kwargs) File "/content/AccoMontage2/chorderator/core.py", line 361, in generate gen = self.run(cut_in, cut_in_arg, with_texture, **kwargs) File "/content/AccoMontage2/chorderator/core.py", line 294, in run **kwargs) File "/content/AccoMontage2/chorderator/utils/pipeline.py", line 62, in send_in self.final_output = self.__add_textures(self.chord_gen_output, self.final_output_log, **kwargs) File "/content/AccoMontage2/chorderator/utils/pipeline.py", line 113, in __add_textures processor.solve() File "/content/AccoMontage2/chorderator/utils/models/accomontage/AccoMontage.py", line 122, in solve midi = render_acc(piano_roll, chord_table, query_seg, path, shift, acc_pool, state_dict=self.state_dict) File "/content/AccoMontage2/chorderator/utils/models/accomontage/util_tools/AccoMontage.py", line 248, in render_acc est_x = model.inference(pr_matrix, gt_chord, sample=False) File "/content/AccoMontage2/chorderator/utils/models/accomontage/models/model.py", line 139, in inference dec_z = torch.cat([z_chd, z_rhy], dim=-1) RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 10 but got size 8 for tensor number 1 in the list.

My demo.py file is setup as such:

`import chorderator as cdt

if name == 'main':

demo_name = 'test'
input_melody_path = 'MIDI demos/inputs/' + demo_name + '/melody.mid'

cdt.set_melody(input_melody_path)
cdt.set_meta(tonic=cdt.Key.D)
cdt.set_segmentation('A4B8A4')
cdt.set_texture_prefilter((0, 2))
cdt.set_note_shift(0)
cdt.set_output_style(cdt.Style.POP_STANDARD)
cdt.generate_save(demo_name + '_output_results')`

And the melody MIDI is attached.

Thank you.
melody.zip

@billyblu2000
Copy link
Owner

Sure, I will review it shortly.

@billyblu2000
Copy link
Owner

Hi @asigalov61, two small problems.

First, regarding the melody.mid, it's totally fine. But there is a minor bug in the program: If the melody has exactly 4/8/16.. bars, then the program would crash. The program would not crash if the melody have 15.99 bars or 7.99 bars etc. I will fix this bug soon. 

Second, regarding the parameters, I think there are small problems. 

  1. The melody seems to be in F Major, instead of D Major. However, if you assigned D Major intentionally, never mind.
  2. The melody has 16 bars, so the segmentation label is incorrect. I would recommend using A8B8.

I make the last note in your melody.mid shorter, and generate using the following parameters. The generation is successful. Feel free to change the styles or the segmentation if you are not satisfied with the result.

import chorderator as cdt

if __name__ == '__main__':

    cdt.set_melody('melody.mid')
    cdt.set_meta(tonic=cdt.Key.F)
    cdt.set_segmentation('A8B8')
    cdt.set_texture_prefilter((0, 2))
    cdt.set_note_shift(0)
    cdt.set_output_style(cdt.Style.POP_STANDARD)
    cdt.generate_save('output_results')

output_results.zip

@asigalov61
Copy link
Contributor Author

asigalov61 commented Sep 5, 2022

@billyblu2000 Yes, it worked! :) Thank you very much for your help yet again!

I have a few questions though...

Why did you recommend to set A8B8?

And lastly, I wanted to ask you if you plan to automate melody preparation and control settings?
I know it may be difficult if not impossible to do, but it would really help to ease the generation process IMHO... Just a suggestion...

Again, thank you for your explanations and help.

Alex

@billyblu2000
Copy link
Owner

@asigalov61 You are welcome!

Why did you recommend to set A8B8?

The melody has 16 bars, the first 8 bars have one motive, and the last 8 bars have another motive. Apparently, they should have different phrase names. There are two options for us to choose: A4A4B4B4 or A8B8. Usually, if 8 is possible, I would choose 8, because in our chord progression template, the quality of the 8-bar templates is better than the 4-bar templates, and thus A8B8 will give AccoMontage2 a higher possibility to generate a good result.

And lastly, I wanted to ask you if you plan to automate melody preparation and control settings?

There are ways to automate this process. Previous research has proposed different MIR algorithms regarding tonic, mode estimation, melody segmentation, etc. Unfortunately, this is not the focus of this research. At least at the current stage, we are not planning to add those modules. We might do it in the future but please don't count on us. You can seek other projects that are doing this and combine it with AccoMontage2.

Billy

@asigalov61
Copy link
Contributor Author

@billyblu2000 Great! Thank you for your clarifications and your response :)

@asigalov61
Copy link
Contributor Author

@billyblu2000 PS. I was able to successfully make a production track from this melody/generated output. Take a listen if you like: https://soundcloud.com/aleksandr-sigalov-61/musenet-pop-composition-1

This is raw AccoMontage2 output continued by OpenAI's MuseNet.

Once again, thank you very much for your work. It produces very good, production quality results. :)

Alex

@billyblu2000
Copy link
Owner

@billyblu2000 PS. I was able to successfully make a production track from this melody/generated output. Take a listen if you like: https://soundcloud.com/aleksandr-sigalov-61/musenet-pop-composition-1

This is raw AccoMontage2 output continued by OpenAI's MuseNet.

Once again, thank you very much for your work. It produces very good, production quality results. :)

Alex

Your music is extremely beautiful! Thank you for your interest in AccoMontage2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants