如何快速部署本地训练的 Bert-VITS2 语音模型到 Hugging Face

简介: Hugging Face是一个机器学习(ML)和数据科学平台和社区,帮助用户构建、部署和训练机器学习模型。它提供基础设施,用于在实时应用中演示、运行和部署人工智能(AI)。用户还可以浏览其他用户上传的模型和数据集。Hugging Face通常被称为机器学习界的GitHub,因为它让开发人员公开分享和测试他们所训练的模型。 本次分享如何快速部署本地训练的 Bert-VITS2 语音模型到 Hugging Face。

hg.jpg

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的优势包括可访问性、集成性、快速原型设计和部署、社区和成本效益,是不可多得的机器学习交流平台。

相关文章
|
4月前
|
PyTorch 算法框架/工具
Bert Pytorch 源码分析:五、模型架构简图 REV1
Bert Pytorch 源码分析:五、模型架构简图 REV1
33 0
|
4月前
|
PyTorch 算法框架/工具
Bert Pytorch 源码分析:五、模型架构简图
Bert Pytorch 源码分析:五、模型架构简图
27 0
|
5月前
|
JavaScript
Bert-vits2-v2.2新版本本地训练推理整合包(原神八重神子英文模型miko)
近日,Bert-vits2-v2.2如约更新,该新版本v2.2主要把Emotion 模型换用CLAP多模态模型,推理支持输入text prompt提示词和audio prompt提示语音来进行引导风格化合成,让推理音色更具情感特色,并且推出了新的预处理webuI,操作上更加亲民和接地气。
Bert-vits2-v2.2新版本本地训练推理整合包(原神八重神子英文模型miko)
|
5月前
|
人工智能 语音技术
Bert-vits2新版本V2.1英文模型本地训练以及中英文混合推理(mix)
中英文混合输出是文本转语音(TTS)项目中很常见的需求场景,尤其在技术文章或者技术视频领域里,其中文文本中一定会夹杂着海量的英文单词,我们当然不希望AI口播只会念中文,Bert-vits2老版本(2.0以下版本)并不支持英文训练和推理,但更新了底模之后,V2.0以上版本支持了中英文混合推理(mix)模式。
Bert-vits2新版本V2.1英文模型本地训练以及中英文混合推理(mix)
|
4月前
|
机器学习/深度学习 数据采集 人工智能
【NLP】Datawhale-AI夏令营Day3打卡:Bert模型
【NLP】Datawhale-AI夏令营Day3打卡:Bert模型
|
4月前
|
机器学习/深度学习 自然语言处理 数据格式
训练你自己的自然语言处理深度学习模型,Bert预训练模型下游任务训练:情感二分类
训练你自己的自然语言处理深度学习模型,Bert预训练模型下游任务训练:情感二分类
55 0
|
5月前
|
机器学习/深度学习 自然语言处理 数据挖掘
预训练语言模型中Transfomer模型、自监督学习、BERT模型概述(图文解释)
预训练语言模型中Transfomer模型、自监督学习、BERT模型概述(图文解释)
63 0
|
5月前
|
自然语言处理 Python
BERT模型基本理念、工作原理、配置讲解(图文解释)
BERT模型基本理念、工作原理、配置讲解(图文解释)
377 0
|
5月前
|
机器学习/深度学习 人工智能 自然语言处理
极智AI | 变形金刚大家族Transformer ViT CLIP BLIP BERT模型结构
大家好,我是极智视界,本文整理介绍一下 Transformer ViT CLIP BLIP BERT 模型结构。
162 0
|
6月前
lda模型和bert模型的文本主题情感分类实战
lda模型和bert模型的文本主题情感分类实战
111 0

热门文章

最新文章