情况1
由于某些原因huggingface无法连接,还好有国内镜像,目前是可用的。
仅需在代码最上面加这两句就解决了!!!
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
情况2
1、下载依赖包
pip install -U huggingface_hub
2、修改环境配置(亲测加了https才能连上)
export HF_ENDPOINT=https://hf-mirror.com
修改原理
找到huggingface_hub依赖包下载配置文件,参考下面这个地址:
/path/to/env/site-packages/huggingface_hub/constants.py
如果环境中有HF_ENDPOINT的设定就会采用该设定作为前缀,即上面镜像的https://hf-mirror.com
而非默认的https://huggingface.co
。
参考:https://www.jianshu.com/p/645620c37c12
https://blog.csdn.net/qq_40277409/article/details/138566289
https://zhuanlan.zhihu.com/p/689290456
https://zhuanlan.zhihu.com/p/676420788