本地部署 Qwen-Audio-Chat

Qwen-Audio-Chat 介绍

Qwen-Audio-Chat是通用语音多模态大规模语言模型,因此它可以完成多种音频理解任务。在本教程之中,我们会给出一些简明的例子,用以展示Qwen-Audio-Chat在语音识别,语音翻译,环境音理解,多音频理解和语音定位(根据指令截取语音中指定文本的片段)等多方面的能力。

Qwen-Audio Github 地址

https://github.com/QwenLM/Qwen-Audio

部署 Qwen-Audio-Chat

安装 ffmpeg

sudo apt install ffmpeg

克隆代码库

git clone https://github.com/QwenLM/Qwen-Audio.git
cd Qwen-Audio

创建虚拟环境

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

使用 pip 安装 pytorch

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

验证 cuda 可用,

python -c "import torch;print(torch.cuda.is_available());"

使用 pip 安装依赖

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

安装 flash-attn,

git clone https://github.com/Dao-AILab/flash-attention; cd flash-attention
# 20231209 时点最新是 flash-attn-2.3.6 版本
pip install flash-attn --no-build-isolation
# 下方安装可选,安装可能比较缓慢。
pip install csrc/layer_norm
pip install csrc/rotary

使用 ModelScope

安装 modelscope,

pip install modelscope -i https://mirrors.aliyun.com/pypi/simple/

修改 web_demo_audio.py 使用 ModelScope,

cp web_demo_audio.py webui.py 
vi webui.py 

--- add
from modelscope import (
    snapshot_download, AutoModelForCausalLM, AutoTokenizer, GenerationConfig
)
import torch
model_id = 'qwen/Qwen-Audio-Chat'
revision = 'master'

model_dir = snapshot_download(model_id, revision=revision)
torch.manual_seed(1234)
---

--- modify
    # tokenizer = AutoTokenizer.from_pretrained(
    #     args.checkpoint_path, trust_remote_code=True, resume_download=True,
    # )
    tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
    if not hasattr(tokenizer, 'model_dir'):
        tokenizer.model_dir = model_dir
---

--- modify
    # model = AutoModelForCausalLM.from_pretrained(
    #     args.checkpoint_path,
    #     device_map=device_map,
    #     trust_remote_code=True,
    #     resume_download=True,
    # ).eval()
    # model.generation_config = GenerationConfig.from_pretrained(
    #     args.checkpoint_path, trust_remote_code=True, resume_download=True,
    # )
    model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", trust_remote_code=True).eval()
---

运行 Web UI

pip install -r requirements_web_demo.txt -i https://mirrors.aliyun.com/pypi/simple/

创建 webui.sh,

eval "$(conda shell.bash hook)"
conda activate qwenaudio
CUDA_VISIBLE_DEVICES=0
python webui.py  --server-name 0.0.0.0 --server-port 8001

随后运行如下命令,并点击生成链接:

./webui.sh

完结!

相关推荐

  1. 本地部署 Qwen-Audio-Chat

    2023-12-10 09:08:02       64 阅读
  2. vLLM部署Qwen1.5-32B-Chat

    2023-12-10 09:08:02       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-10 09:08:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-10 09:08:02       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-10 09:08:02       82 阅读
  4. Python语言-面向对象

    2023-12-10 09:08:02       91 阅读

热门阅读

  1. YOLOX 学习笔记

    2023-12-10 09:08:02       51 阅读
  2. Django模板

    2023-12-10 09:08:02       53 阅读
  3. Django模型

    2023-12-10 09:08:02       51 阅读
  4. properties配置和读取

    2023-12-10 09:08:02       42 阅读
  5. React和Preact 这样处理className更优雅

    2023-12-10 09:08:02       62 阅读
  6. wordpress小记

    2023-12-10 09:08:02       53 阅读
  7. spring 单元测试 Junit

    2023-12-10 09:08:02       54 阅读
  8. Spring Boot与Redis的整合

    2023-12-10 09:08:02       46 阅读
  9. d8week17

    d8week17

    2023-12-10 09:08:02      66 阅读
  10. centos7部署docker环境

    2023-12-10 09:08:02       55 阅读
  11. CentOS 7.9--离线安装python3.9.18+virtualenv-20.25.0

    2023-12-10 09:08:02       52 阅读
  12. mysql error: #1093

    2023-12-10 09:08:02       58 阅读
  13. mybatis-config.xml的配置

    2023-12-10 09:08:02       46 阅读
  14. css顺时针旋转90°再3D中绕Y轴旋转180°

    2023-12-10 09:08:02       67 阅读
  15. ElasticSearch之cat nodes API

    2023-12-10 09:08:02       57 阅读