parent
8a8028e223
commit
68640c53ce
@ -1,27 +0,0 @@
|
|||||||
"""
|
|
||||||
pip install huggingface_hub
|
|
||||||
pip install pysocks
|
|
||||||
pip install hf_xet
|
|
||||||
开VPN后,使用Python下载模型
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
from transformers import AutoModel, AutoTokenizer
|
|
||||||
|
|
||||||
# 设置环境变量
|
|
||||||
os.environ['HTTP_PROXY'] = 'socks5://127.0.0.1:1080'
|
|
||||||
os.environ['HTTPS_PROXY'] = 'socks5://127.0.0.1:1080'
|
|
||||||
|
|
||||||
# 配置代理
|
|
||||||
proxies = {
|
|
||||||
'http': 'socks5://127.0.0.1:1080',
|
|
||||||
'https': 'socks5://127.0.0.1:1080'
|
|
||||||
}
|
|
||||||
|
|
||||||
# 加载模型
|
|
||||||
model_id = "google-bert/bert-base-uncased"
|
|
||||||
model = AutoModel.from_pretrained(model_id, proxies=proxies)
|
|
||||||
tokenizer = AutoTokenizer.from_pretrained(model_id, proxies=proxies)
|
|
||||||
|
|
||||||
# 保存模型到本地
|
|
||||||
model.save_pretrained("d:/Model/google-bert/bert-base-uncased")
|
|
||||||
tokenizer.save_pretrained("d:/Model/google-bert/bert-base-uncased")
|
|
Loading…
Reference in new issue