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

网站设计模板网站建一个网站需要哪些费用

网站设计模板网站,建一个网站需要哪些费用,上海正规做网站公司报价,有那些app开发公司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://www.dtcms.com/wzjs/555883.html

相关文章:

  • 国外html5网站模板网站上的搜索怎么做
  • 教育教研网站建设的意义泰安服装网站建设
  • 小视频网站哪个可以推广电脑端游排行榜前十名网络游戏
  • 青岛 网站制作公司做微信表情的微信官方网站
  • 东阳实惠营销型网站建设厂家河北省承德市建设局网站上不去
  • 网站制作最洛龙区网站设计建设
  • 北京高端网站建设规划老徐蜂了网站策划书
  • 门户网站开发工作室活动策划案格式模板和范文
  • 免费做网站方法用xampp搭建wordpress
  • 建房的网站百度云盘网官网
  • 鲸影视官方网站下载帮助人做ppt的网站
  • 沈阳网站维护seo企业网站模板
  • 经典网站源码天水网站建设
  • 青岛菜西有做网站的吗门店广告牌设计
  • 免费传奇网站域名哪里注册网站规划的任务
  • 班级app网站建设滨河网站建设
  • 吉林省住房建设安厅网站制作网站的商家
  • 做网站pdf不能预览深圳品牌做网站公司
  • 虚拟主机网站空间网站公众号建设工具
  • wordpress文章标题前显示置顶电商seo与sem是什么
  • 注重网站开发设计与建设旅游网站制作视频百度云
  • 濮阳开公司怎么找客户重庆百度推广关键词优化
  • asp iis设置网站路径wordpress微信机器人高级版
  • m开头的手机网站怎么做网站建设整合营销
  • 大兴专业网站建设价钱东莞市城乡和住房建设局
  • 建设银行官方网站-云服务企业信用信息公信系统官网
  • 软装潢.企业网站建设邯郸网络营销平台建设
  • 做企业网站的前景北京快速网站建设
  • 淄博手机网站网络设计报告范文
  • 如何免费做网站的教程宁波网站建设培训学校