如何快速部署本地训练的 Bert-VITS2 语音模型到 Hugging Face
Hugging Face是一個機器學習(ML)和數據科學平臺和社區,幫助用戶構建、部署和訓練機器學習模型。它提供基礎設施,用于在實時應用中演示、運行和部署人工智能(AI)。用戶還可以瀏覽其他用戶上傳的模型和數據集。Hugging Face通常被稱為機器學習界的GitHub,因為它讓開發人員公開分享和測試他們所訓練的模型。
本次分享如何快速部署本地訓練的 Bert-VITS2 語音模型到 Hugging Face。
本地配置HuggingFace
首先注冊HuggingFace平臺:
https://huggingface.co/join
隨后在用戶的設置界面新建token,也就是令牌:
這里令牌有兩種權限類型,一種是寫權限,另外一種是讀權限。
隨后本地安裝Huggingface客戶端:
pip install huggingface_hub
隨后運行命令登錄Huggingface賬號:
huggingface-cli login
此時需要用到剛剛創建的token,復制寫token,粘貼到命令行中:
E:\work>huggingface-cli login
_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
Setting a new token will erase the existing one.
To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token can be pasted using 'Right-Click'.
Token:
Add token as git credential? (Y/n) y
Token is valid (permission: write).
Cannot authenticate through git-credential as no helper is defined on your machine.
You might have to re-authenticate when pushing to the Hugging Face Hub.
Run the following command in your terminal in case you want to set the 'store' credential helper as default.
git config --global credential.helper store
Read https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage for more details.
Token has not been saved to git credential helper.
Your token has been saved to C:\Users\zcxey\.cache\huggingface\token
Login successful
顯示Login successful即代表登錄成功。
隨后,可以使用命令來創建模型的repo項目:
huggingface-cli repo create wizard3
這里創建巫師3系列角色模型。
程序返回:
E:\work>huggingface-cli repo create wizard3
git version 2.31.0.windows.1
git-lfs/2.13.2 (GitHub; windows amd64; go 1.14.13; git fc664697)
You are about to create v3ucn/wizard3
Proceed? [Y/n] y
Your repo now lives at:
https://huggingface.co/v3ucn/wizard3
You can clone it locally with the command below, and commit/push as usual.
git clone https://huggingface.co/v3ucn/wizard3
說明已經創建好模型項目了。
當然,過程中可能會報443的錯誤,如果您身在國內,這是十分合理的現象。
此時,可以通過給git配置代理來解決:
配置socks5
git config --global http.proxy socks5 127.0.0.1:7890
git config --global https.proxy socks5 127.0.0.1:7890
配置http
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
其中7890為您在國內學術上網用的端口號,啥叫學術上網?很抱歉這里無法多做解釋。
同時也可以通過命令取消git學術上網:
git config --global --unset http.proxy
git config --global --unset https.proxy
接著本地克隆項目:
git clone https://huggingface.co/v3ucn/wizard3
隨后將模型本體和配置文件config.json放入wizard3目錄。
提交后,推送即可:
E:\work>cd wizard3
E:\work\wizard3>git add -A
E:\work\wizard3>git commit -m "commit from liuyue "
[main cd327b9] commit from liuyue
2 files changed, 114 insertions(+)
create mode 100644 G_200.pth
create mode 100644 config.json
E:\work\wizard3>git push
Uploading LFS objects: 0% (0/1), 925 MB | 2.4 MB/s
此時,git就會把模型推送到Huggingface云端。
推送完畢后,訪問線上地址,即可查看模型:
https://huggingface.co/v3ucn/wizard3/tree/main
結語
Hugging Face的優勢包括可訪問性、集成性、快速原型設計和部署、社區和成本效益,是不可多得的機器學習交流平臺。
總結
以上是生活随笔為你收集整理的如何快速部署本地训练的 Bert-VITS2 语音模型到 Hugging Face的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设计模式(二十一)策略
- 下一篇: STM32CubeMX教程14 ADC