Huggingface的from pretrained的下载代理服务器方法设置

慈云数据 2024-03-12 技术支持 98 0

笔者需要用到下载预训练模型,但是此时TUNA和BSFU的镜像已经停止了,希望有可用的途径下载到位于网上的预训练模型。

此时查找了huggingface的文档Configuration

根据文档,该参数proxies (Dict, optional)

  • A dictionary of proxy servers to use by protocol or endpoint,e.g.:

    {'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.

    The proxies are used on each request.

    即可代理http(s)流量

    proxies={'http': 'http://127.0.0.1:8118', 'https': 'http://127.0.0.1:8118'}

    BertTokenizerFast.from_pretrained("bert-base-uncased", proxies=proxies)

     

    在StackOverflow有类似解决方法How to specify a proxy in transformers pipeline

     实在不行,放大招:

    --------------------------------------------------------------

    下面方法失败了,好容易下载的结果版本(TF或PT)不匹配,失败!!!!!!!!!!!!!!!!!!!!

      cd 到 ~/.cache/huggingface/diffusers/models--runwayml--stable-diffusion-v1-5/snapshots/39593d5650112b4cc580433f6b0435385882d819/unet

     aria2c   https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/diffusion_pytorch_model.safetensors  --max-connection-per-server=4 --min-split-size=1M  --all-proxy='http://127.0.0.1:8118'
    
微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon