OSError: We couldn‘t connect to ‘https://huggingface.co‘ to load this file, couldn‘t find it in the

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the

Problem Description

Insert image description here

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like distilbert-base-uncased-finetuned-sst-2-english is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

This actually means that if the model is overseas, the server cannot access the foreign model, and the model needs to be downloaded locally.

solution

Download the model file below and put it in a folder


Insert image description here

When loading the model, specify the local model

path = '/home/ubuntu/code/transformers-main/sentiment-analysis'
classifier = pipeline('sentiment-analysis',model=path)

Reference 1

Reference 2

Reference 3

Quick Start with Hugging Face

a warning

UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()
return self.fget.get(instance, owner)()Insert image description here
这个警告其实不影响代码的运行
Insert image description here

Guess you like

Origin blog.csdn.net/qq_41701723/article/details/135261846