'SpeechBrain: Cannot Load Pretrained Model from Local Path

I'm trying to load a pretrained SpeechBrain HuggingFace model from local files; I don't want it to call out to HuggingFace to download. However, unless I change the pretrained_path in hyperparams.yaml, it is still calling out to HuggingFace and downloading the models from HF.

from speechbrain.pretrained import EncoderClassifier
model_folder = "/local/path/to/folder/with/model_files"
model = EncoderClassifier.from_hparams(source=model_folder)

To get the model files into a local directory:

  1. I downloaded the model from HuggingFace.
  2. I moved the actual model files in ~/.cache/huggingface/hub/ to model_folder path. I also renamed them to their symlinked names: embedding_model.ckpt, label_encoder.ckpt, and classifier.ckpt.
  3. I then tried changing pretrained_path in hyperparams.yaml to model_folder. But that causes the model to not load properly.

HF model: https://huggingface.co/TalTechNLP/voxlingua107-epaca-tdnn

What's the right way to load an EncoderClassifier from local files?



Solution 1:[1]

SOLVED: User Error. The steps in 1-3 above work. There was a typo in the names of one of my files: it should be label_encoder.txt not label_encoder.ckpt. You can see this by looking at hyperparams.yaml for voxlingua107-epaca-tdnn to see what it expects.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nat G