SarthakYadav / leaf-pytorch

PyTorch implementation of the LEAF audio frontend
64 stars 10 forks source link

module 'torchaudio.transforms' has no attribute 'create_fb_matrix' #6

Closed chen-bh closed 2 years ago

chen-bh commented 2 years ago

thanks for your code! help us a lot! when i run train,i got this Error:

File "train.py", line 334, in acc = train(ARGS) File "train.py", line 149, in train model = Classifier(cfg).to(device) File "/home/xxx/Ben/code/leaf-pytorch/models/classifier.py", line 11, in init self.features = get_frontend(cfg) File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/frontend_helper.py", line 25, in get_frontend fe = Leaf(use_legacy_complex=use_legacy_complex, initializer=initializer) File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/frontend.py", line 56, in init use_legacy_complex=use_legacy_complex File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/convolution.py", line 45, in init init_weights = initializer((self._filters, 2)) File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/initializers.py", line 18, in call return gabor_filters.gabor_params_from_mels() File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/filters.py", line 30, in gabor_params_from_mels sqrt_filters = torch.sqrt(self.mel_filters()) File "/home/xxx/Ben/code/leaf-pytorch/leaf_pytorch/filters.py", line 49, in mel_filters mel_filters = torchaudio.transforms.create_fb_matrix( AttributeError: module 'torchaudio.transforms' has no attribute 'create_fb_matrix'

i found that maybe "create_fb_matrix" was deprecated (i'm using 0.11). https://github.com/pytorch/audio/issues/1669

how can i fix it. or can i using others replace it?

of cause i will go back to the past version and try.

wangych6 commented 2 years ago

By my test: installed torch-1.10.0 torchaudio-0.10.0 can solve ur problems

SarthakYadav commented 2 years ago

Hi @chen-bh. Apologies for the delay.

You can use torchaudio.functional.melscale_fbanks as documented here, which is more or less just a refractor of create_fb_matrix.

that should work out of the box.

SarthakYadav commented 2 years ago

As a matter of fact, I just pushed a commit (https://github.com/SarthakYadav/leaf-pytorch/commit/be2674c5ebdcf92993aeb0bb408efe4da93994d0) to fix this.

Closing the issue now, feel free to reopen/comment if you still face issues.

chen-bh commented 2 years ago

@SarthakYadav thanks a lot