当前位置: 首页 > wzjs >正文

简述网站的建站流程wordpress插件问题

简述网站的建站流程,wordpress插件问题,扬州手机网站开发,网上商店的优势和缺陷Helsinki-NLP/opus-mt-{en}-{zh}系列翻译模型可以实现200多种语言翻译,Helsinki-NLP/opus-mt-en-zh是其中英互译模型。由于项目需要,在本地进行搭建,并记录下搭建过程,方便后人。 1. 基本硬件环境 CPU:N年前的 Intel…

Helsinki-NLP/opus-mt-{en}-{zh}系列翻译模型可以实现200多种语言翻译,Helsinki-NLP/opus-mt-en-zh是其中英互译模型。由于项目需要,在本地进行搭建,并记录下搭建过程,方便后人。

1. 基本硬件环境

  • CPU:N年前的 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz, 32G内存
  • GPU:N年前的 NVIDIA GeForce GTX 1080 Ti,11G显存

2. 基本软件环境

  • 操作系统:Ubuntu20.04 LTS,是为了跟老旧的硬件相匹配,专门降级到20.04的,更高版本存在各种软件兼容性问题,等有钱了全部换新!!!
  • CUDA:cuda_12.0.0_525.60.13_linux.run,虽然能支持到12.2甚至12.4,保险起见还是选择了12.0
  • Cudnn:libcudnn8_8.8.0.121-1+cuda12.0_amd64.deb,对应CUDA版本
  • NCCL:libnccl2_2.19.3-1+cuda12.0_amd64.deb对应CUDA版本,多显卡需要
  • miniconda:Miniconda3-py312_24.9.2-0-Linux-x86_64.sh

3. 克隆fishspeech代码并安装本地依赖包

git clone https://gitclone.com/github.com/fishaudio/fish-speech.gitsudo apt-get install ffmpeg libsm6 libxext6 portaudio19-dev -y

4. 创建虚拟环境

conda create -n huggingface python==3.10 -y
conda activate huggingface

5. conda安装基础包

conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=11.8

6. 安装huggingface组件,transformers包

pip install transformers -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -U huggingface_hub -i https://pypi.tuna.tsinghua.edu.cn/simple设置环境变量,用于加速
HF_ENDPOINT=https://hf-mirror.com

7. 以python脚本方式运行

# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLMtokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-zh")
model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-en-zh")def translate(text):inputs = tokenizer(text, return_tensors="pt", padding=True)translated = model.generate(**inputs)return [tokenizer.decode(t, skip_special_tokens=True) for t in translated]print(tokenizer.supported_language_codes)
text = ">>cmn_Hans<< Due to a bug fix in https://github.com/huggingface/transformers/pull/28687 transcription using a multilingual Whisper will default to language detection followed by transcription instead of translation to English.This might be a breaking change for your use case. If you want to instead always translate your audio to English, make sure to pass `language='en'`. The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results."
translated_text = translate(text)
print(translated_text)

首次运行会报错,因为缺少两个依赖包,安装即可

pip install sentencepiece sacremoses -i https://pypi.tuna.tsinghua.edu.cn/simple

8. 以FastAPI方式运行

# 安装fastapi ubicorn组件
pip install fastapi uvicorn -i https://pypi.tuna.tsinghua.edu.cn/simple

服务脚本如下:

# Load model directly
from fastapi import FastAPI
from pydantic import BaseModel
from transformers import AutoTokenizer, AutoModelForSeq2SeqLMapp = FastAPI()tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-zh")
model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-en-zh")def translate(text):inputs = tokenizer(text, return_tensors="pt", padding=True)translated = model.generate(**inputs)return [tokenizer.decode(t, skip_special_tokens=True) for t in translated]# print(tokenizer.supported_language_codes)
# text = ">>cmn_Hans<< Due to a bug fix in https://github.com/huggingface/transformers/pull/28687 transcription using a multilingual Whisper will default to language detection followed by transcription instead of translation to English.This might be a breaking change for your use case. If you want to instead always translate your audio to English, make sure to pass `language='en'`. The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results."
# translated_text = translate(text)
# print(translated_text)class TextRequest(BaseModel):text: str@app.post("/predict")
async def predict(request: TextRequest):# 预处理和预测translated_text = translate(request.text)# 返回结果return {"text": request.text,"predictions": translated_text}

运行服务

uvicorn fastapi_app:app --host 0.0.0.0 --port 8000


文章转载自:

http://tIsyOv1k.fhddr.cn
http://BDFOfooR.fhddr.cn
http://RupINhZr.fhddr.cn
http://HkedyaNE.fhddr.cn
http://eNSm8e6e.fhddr.cn
http://8Q5bKGP1.fhddr.cn
http://vw5GEJsn.fhddr.cn
http://bDgh2GbY.fhddr.cn
http://dDZdU1Iy.fhddr.cn
http://vaVOYVSo.fhddr.cn
http://xF7HnV4j.fhddr.cn
http://tjnZy8VI.fhddr.cn
http://eUXM1j2Z.fhddr.cn
http://Z84gqXqy.fhddr.cn
http://9xG824SK.fhddr.cn
http://YCXukLgG.fhddr.cn
http://44pilXMf.fhddr.cn
http://CReKtFzx.fhddr.cn
http://BfHt9OcA.fhddr.cn
http://XYA5eBoz.fhddr.cn
http://xHb8fbEy.fhddr.cn
http://WU6CPAMA.fhddr.cn
http://ynCOmof6.fhddr.cn
http://aEPs6BLw.fhddr.cn
http://fWCX6Nkr.fhddr.cn
http://ehr1kPBx.fhddr.cn
http://UGfUuaJM.fhddr.cn
http://HDsPP9ZP.fhddr.cn
http://1Usxp9SE.fhddr.cn
http://YkDdk3IU.fhddr.cn
http://www.dtcms.com/wzjs/647885.html

相关文章:

  • 湖州网站建设策划微信开发者工具官网下载电脑版
  • 专业营销网站为什么邮箱突然进不去了总提示正在进入不安全网站
  • 金融企业类网站模板百度图片识别在线使用
  • 南昌网站推广策划邯郸城融网络技术有限公司
  • 微信网站建设公司首选wordpress清除redis缓存
  • 网站建设框架图做网站发布信息
  • 东莞定制网站建设盐城网站建设要多少钱
  • seo伪原创工具seo工具共享网站
  • 阿里巴巴如何建设网站抚顺网站推广
  • 国外网站素材模拟建筑
  • 免费做简单网站WordPress搜索不支持中文
  • 手工做衣服的网站南京网站设计公司兴田德润电话多少
  • 公司做网站哪个公司做得好丹阳企业网站建设
  • 企业网站管理系统推荐广州网站提升排名
  • 做中学数学教案有哪些好的网站导航类wordpress主题
  • 四合一网站建设模板网站可以做备案吗
  • 网站弹窗是怎么做的网页制作怎么上传到网站
  • 网站版权模板wordpress 影视采集
  • 廊坊那家做网站排行榜携程旅行的网站建设
  • 中核工建设集团有限公司网站太原网站建设的公司
  • 购物展示网站开发的背景网站统计平台
  • 网站建设推广方法凡客诚品官网怎么登录
  • 微信群领券网站怎么做济南装饰行业网站建设
  • ps网站轮播图怎么做wordpress 首页设置幻灯片
  • 医院网站建设价格营销推广模式
  • vs2010网站开发登录代码应用商店下载安装电脑
  • 个人做当地旅游网站游戏开发需要什么学历
  • 如何百度到自己的网站万网域名查询网
  • 甘肃省建设厅特种工查询网站关于介绍网页设计的演讲稿
  • 网站建设的核心是学校网站建设工作总结