一些预训练的权重可以传到Huggingface上
下面是具体操作教程,转载自Huggingface上传自己的预训练模型(大小权重都可以)
$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
$ sudo apt-get install git-lfs
$ git lfs install
$ pip install huggingface_hub
上述是Linux安装git-lfs, windows用户可以直接下载并安装。地址:Git Large File Storage
使用huggingface-cli login
命令进行登录,登录过程中需要输入用户的Access Tokens 。这里需要先到网站页面上进行设置然后复制过来进行登录。
$ huggingface-cli login
_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
To login, `huggingface_hub` now requires a token generated from https://huggingface.co/settings/token.
(Deprecated, will be removed in v0.3.0) To login with username and password instead, interrupt with Ctrl+C.
Token:
Login successful
$ huggingface-cli repo create model_name
如果你想要手动创建,则可以直接在Huggingface
上new一个Model
就可以跳过这一步了。
$ git lfs install
$ git clone https://huggingface.co/username/model_name
克隆来以后就可以把需要上传的文件放入到这个下载的model_name文件夹中。
这个时候如果你发现你上传的文件的大小大于5GB,你就应该运行以下命令,否则可以不运行:
$ huggingface-cli lfs-enable-largefiles ./path/to/your/repo
$ git add .
$ git commit -m "commit from $USER"
$ git push
第一次上传可能出现让你输入账号密码,只需要按照要求输入即可。
最近Huggingface被墙了,所以可以需要代理.
在Windows命令提示符(cmd)中设置代理的方法:
set http_proxy=http://127.0.0.1:2802
set https_proxy=http://127.0.0.1:2802
# 127.0.0.1 一般不变, :后面是端口号, 需要自己查看并设置。
# 代理端口,可以在 设置 → 网络和Internet → 代理 中查看。
若以上设置还不能,下面是在 Windows 系统上为 Git 添加代理设置:
有两种方式, 选一种进行即可
git config --global http.proxy http://用户名:密码@代理服务器:端口
git config --global https.proxy https://用户名:密码@代理服务器:端口
如果你想查看你的配置,可以使用:
git config --global --get http.proxy
git config --global --get https.proxy
如果你需要删除这些代理设置,可以使用:
git config --global --unset http.proxy
git config --global --unset https.proxy
编辑C:\Users\yours\.gitconfig
文件中的内容即可.
其内容示意:
[user]
email = 你的邮箱
name = 名字
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[credential "https://gitee.com"]
provider = generic
[credential]
helper = store
[credential "https://huggingface.co"]
provider = generic
[http]
proxy = http://127.0.0.1:7890
[https]
proxy = https://127.0.0.1:7890