How to prevent redownloading the model?

#4
by denis-kazakov - opened

How can I use model that has already been downloaded to my computer? I cloned the files into a local directory and I am trying to load from it.

model = AutoModel.from_pretrained(LOCAL_PATH)
classifier = pipeline(
    "audio-classification",
    model=model
)

But I get the following error:

Exception: Impossible to guess which feature extractor to use. Please provide a PreTrainedFeatureExtractor class or a path/identifier to a pretrained feature extractor.

Trying this version

classifier = pipeline(
    "audio-classification",
    model=model,
    feature_extractor=LOCAL_PATH
)

results in the following message:

The model 'Wav2Vec2Model' is not supported for audio-classification. Supported models are ['ASTForAudioClassification', 'Data2VecAudioForSequenceClassification', 'HubertForSequenceClassification', 'SEWForSequenceClassification', 'SEWDForSequenceClassification', 'UniSpeechForSequenceClassification', 'UniSpeechSatForSequenceClassification', 'Wav2Vec2ForSequenceClassification', 'Wav2Vec2ConformerForSequenceClassification', 'WavLMForSequenceClassification', 'WhisperForAudioClassification'].

In fact, even if I download it again with AutoModel.from_pretrained I still get the same error "Impossible to guess which feature extractor to use".

To answer my own question, I found that I should use model = AutoModelForAudioClassification.from_pretrained and feature_extractor = AutoFeatureExtractor.from_pretrained

denis-kazakov changed discussion status to closed

Sign up or log in to comment