Unable to load saved model from "model-directory" using pipeline
used the following code to save the model to "model-directory"
!sudo yum update -y
!curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
!sudo yum install git-lfs git -y
repository = "openai/whisper-small"
model_id=repository.split("/")[-1]
!git lfs install
!git clone https://huggingface.co./$repository
code to setup pipeline
from transformers import WhisperTokenizer, WhisperForConditionalGeneration, WhisperFeatureExtractor, WhisperProcessor
model_dir = "./whisper-small"
t = WhisperTokenizer.from_pretrained(model_dir)
m = WhisperForConditionalGeneration.from_pretrained(model_dir)
fe = WhisperProcessor.from_pretrained(model_dir)
from transformers import pipeline
classifier = pipeline(
task= 'automatic-speech-recognition',
model= m,
feature_extrator = fe_hf,
tokenizer=t,
config="whisper-small/config.json"
)
getting error ---
Exception: Impossible to guess which feature extractor to use. Please provide a PreTrainedFeatureExtractor class or a path/identifier to a pretrained feature extractor.
please help
anyone?? seeing this?
You can do it directly from a pre-trained identifier on the Hub:
>>> import torch
>>> from transformers import pipeline
>>> from datasets import load_dataset
>>> device = "cuda:0" if torch.cuda.is_available() else "cpu"
>>> pipe = pipeline(
>>> "automatic-speech-recognition",
>>> model="openai/whisper-small",
>>> chunk_length_s=30,
>>> device=device,
>>> )
Or through a local model path, e.g. if you've cloned the model into whisper-small
:
>>> pipe = pipeline(
>>> "automatic-speech-recognition",
>>> model="./whisper-small",
>>> chunk_length_s=30,
>>> device=device,
>>> )
thanks, it worked
I am also trying to load a local model but get the error OSError: Incorrect path_or_model_id
#save model locallymodel = WhisperModel.from_pretrained("openai/whisper-tiny")
PreTrainedModel.save_pretrained(model, <my_path>
Error when doing following:model = WhisperModel.from_pretrained(pretrained_model_name_or_path=<my_path>, local_files_only=True)