ModelScope初体验,有哪些细节让你印象深刻?

摘要:使用环境:windows 11 前置条件:已安装 anaconda 参考文档:环境安装 step1:新建一个 conda 环境,命名为 modelscope conda create -n modelscope python=3.8 con
使用环境:windows 11 前置条件:已安装 anaconda 参考文档:环境安装 step1:新建一个 conda 环境,命名为 modelscope conda create -n modelscope python=3.8 conda activate modelscope step2: 安装 pytorch (根据自己的显卡情况进行选择 Start Locally | PyTorch) conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia 小tip:如果安装 pytorch 很慢,可以修改 .condarc 文件换源。文件位于 users 文件夹下。下面换成清华源。 channels: - defaults show_channel_urls: true default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud 换完后,使用 conda clean -i 清理一下缓存. step3: 安装 modelscope library . 先装基础库,用阿里云镜像快一些 pip install modelscope -i https://mirrors.aliyun.com/pypi/simple/ 想跑一个音频模型,所以再安装了一下 audio pip install "modelscope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html 但是 audio 我安装失败了,还没找到原因。先放放。 step4:下载模型 可以点进模型页下载模型 也可以用代码下载,官网都有介绍:模型的下载 · 文档中心 step5:阅读一下 readme,注意 寄。本文完。 等等等等,来都来了,找个能跑的模型吧。 就它了。 按照文档创建一个 py 文件,把其中的内容复制上去。如果前面手动下载了模型,需要更改模型的路径。 跑起来还是会提示缺一些库,我这边额外装了 transformers, SentencePiece, soundfile, librosa。总之提示缺啥或者找不到啥就装啥。 然后在 modelscope 的 conda 环境下,就能跑起来了。 试了下这个模型的降噪效果还可以。 使用 modelscope library 跑模型,模型文件会自动下载到 用户.cache\modelscope\hub\damo 目录下。模型的初始化代码都被封装好了,使用起来确实非常的方便。 有很多文件只支持 linux,所以在 linux 机器上使用会更加的方便。这次跑的模型比较简单,下次再在 linux 系统上尝试一下,有结果再与大家分享。