一、问题
HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url:LocalEntryNotFoundError: Connection error, and we cannot find the requested
files in the disk cache. Please try again or make sure your Internet connection is on.
二、解决思路
这是因为在中国境内暂时无法访问Huggingface.co。
目前的解决方法有两种
第一种:使用代理
这种方式并不被推荐,因为很多模型都非常庞大,使用代理服务器下载可能会消耗大量的网络流量。
第二种:使用镜像网站下载
演示使用方法
1.使用everything搜索huggingface_hub文件夹并打开该文件夹下的constans.py
2.打开该文件进行配置,将其中的 https://huggingface.co修改成镜像网站如图
HUGGINGFACE_CO_URL_HOME = "https://hf-mirror.com/"
_HF_DEFAULT_ENDPOINT = "https://hf-mirror.com"
修改成功后保存,然后测试一下。
import gradio as gr
from transformers import pipeline
gr.Interface.from_pipeline(pipeline("text-classification", model="uer/roberta-base-finetuned-dianping-chinese")).launch()
如果出现模型正在加载的界面,就是配置成功了,我这里是模型下载完毕后的结果