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

Error: can't load model #3256

Closed
janson91 opened this issue Feb 19, 2021 · 6 comments
Closed

Error: can't load model #3256

janson91 opened this issue Feb 19, 2021 · 6 comments

Comments

@janson91
Copy link

hi, I tried some wav2vec models, but there was always error:
the code is
`import torch
import fairseq

cp_path = '/path/to/wav2vec.pt'
model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task([cp_path])
model = model[0]
model.eval()`

and the error :
the model: https://dl.fbaipublicfiles.com/fairseq/wav2vec/wav2vec_large.pt Error:KeyError: 'speech_pretraining'
the model:https://dl.fbaipublicfiles.com/fairseq/wav2vec/vq-wav2vec.pt Error:KeyError: 'binary_cross_entropy'
the model:https://dl.fbaipublicfiles.com/fairseq/wav2vec/vq-wav2vec_kmeans.pt KeyError: 'binary_cross_entropy'
the model:https://dl.fbaipublicfiles.com/fairseq/wav2vec/xlsr_53_56k.pt AttributeError: 'NoneType' object has no attribute 'task'

is anywhere more examples for loading the model?

thanks

@myleott
Copy link
Contributor

myleott commented Feb 20, 2021

What version of fairseq do you have installed? You may need to install the latest version from source: https://github.com/pytorch/fairseq/#requirements-and-installation

@olafthiele
Copy link

@janson91 Check the colab mentioned in this issue. You might have to checkout that days commit, the newer ones seem to have problems. An reload the xlsr..pt if it is older than 7 days. There was a problem with it.

@yc-li20
Copy link

yc-li20 commented May 6, 2021

same issue though fairseq is the latest version.

@duwf2003
Copy link

I have solved this problem.
(1)You need to find out where is the location of fairseq, in my env is ~/miniconda3/envs/myconda/lib/python3.7/site-packages/fairseq/.
(2)After that, you need to change your location, and modify the file checkpoint_utils.py
cd ~/miniconda3/envs/myconda/lib/python3.7/site-packages/fairseq/
vi checkpoint_utils.py
line 438
if choice is not None:
change to
if choice is not None and choice in REGISTRY["registry"]:

(3) After save the checkpoint_utils.py, this is the workable example:
cp = 'path/to/vq-wav2vec.pt'
model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task([cp])
model = model[0]
model.eval()

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale
Copy link

stale bot commented May 1, 2022

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@stale stale bot closed this as completed May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants