下载源代码
yeqiang@yeqiang-MS-7B23:~/Downloads/src$ git clone https://gh-proxy.com/https://github.com/QwenLM/Qwen-VL
正克隆到 'Qwen-VL'...
remote: Enumerating objects: 584, done.
remote: Counting objects: 100% (305/305), done.
remote: Compressing objects: 100% (129/129), done.
remote: Total 584 (delta 273), reused 177 (delta 176), pack-reused 279
接收对象中: 100% (584/584), 26.69 MiB | 1.50 MiB/s, 完成.
处理 delta 中: 100% (334/334), 完成.
下载模型
yeqiang@yeqiang-MS-7B23:~/Downloads/ai$ git clone https://www.modelscope.cn/qwen/Qwen-VL-Chat.git
正克隆到 'Qwen-VL-Chat'...
remote: Enumerating objects: 205, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 205 (delta 17), reused 17 (delta 2), pack-reused 157
接收对象中: 100% (205/205), 15.59 MiB | 1.57 MiB/s, 完成.
处理 delta 中: 100% (82/82), 完成.
yeqiang@yeqiang-MS-7B23:~/Downloads/ai$ cd Qwen-VL-Chat/
yeqiang@yeqiang-MS-7B23:~/Downloads/ai/Qwen-VL-Chat$ ll
总用量 2776
-rw-rw-r-- 1 yeqiang yeqiang 1159 2024-04-07 14:10:32 config.json
-rw-rw-r-- 1 yeqiang yeqiang 73 2024-04-07 14:10:32 configuration.json
-rw-rw-r-- 1 yeqiang yeqiang 2087 2024-04-07 14:10:32 configuration_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 221 2024-04-07 14:10:32 generation_config.json
-rw-rw-r-- 1 yeqiang yeqiang 44654 2024-04-07 14:10:32 modeling_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00001-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00002-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00003-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00004-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00005-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00006-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00007-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00008-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00009-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 135 2024-04-07 14:10:32 pytorch_model-00010-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 79941 2024-04-07 14:10:32 pytorch_model.bin.index.json
-rw-rw-r-- 1 yeqiang yeqiang 14873 2024-04-07 14:10:32 qwen_generation_utils.py
-rw-rw-r-- 1 yeqiang yeqiang 2561218 2024-04-07 14:10:32 qwen.tiktoken
-rw-rw-r-- 1 yeqiang yeqiang 25351 2024-04-07 14:10:32 README.md
-rw-rw-r-- 1 yeqiang yeqiang 133 2024-04-07 14:10:32 SimSun.ttf
-rw-rw-r-- 1 yeqiang yeqiang 21915 2024-04-07 14:10:32 tokenization_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 173 2024-04-07 14:10:32 tokenizer_config.json
-rw-rw-r-- 1 yeqiang yeqiang 14555 2024-04-07 14:10:32 visual.py
git拉取modescope.cn的镜像大小不正确,使用git lfs pull拉取大文件
sudo apt install git-lfs
在Qwen-VL-Chat目录下执行
git lfs install
git lfs pull
效果
yeqiang@yeqiang-MS-7B23:~/Downloads/ai/Qwen-VL-Chat$ ll -h
总用量 19G
-rw-rw-r-- 1 yeqiang yeqiang 1.2K 2024-04-07 14:10:32 config.json
-rw-rw-r-- 1 yeqiang yeqiang 73 2024-04-07 14:10:32 configuration.json
-rw-rw-r-- 1 yeqiang yeqiang 2.1K 2024-04-07 14:10:32 configuration_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 221 2024-04-07 14:10:32 generation_config.json
-rw-rw-r-- 1 yeqiang yeqiang 44K 2024-04-07 14:10:32 modeling_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:11:56 pytorch_model-00001-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:00:18 pytorch_model-00002-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:15:37 pytorch_model-00003-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:11:06 pytorch_model-00004-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.8G 2024-04-07 15:19:55 pytorch_model-00005-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:02:08 pytorch_model-00006-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:08:07 pytorch_model-00007-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:02:31 pytorch_model-00008-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.9G 2024-04-07 15:15:58 pytorch_model-00009-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 1.7G 2024-04-07 15:20:21 pytorch_model-00010-of-00010.bin
-rw-rw-r-- 1 yeqiang yeqiang 79K 2024-04-07 14:10:32 pytorch_model.bin.index.json
-rw-rw-r-- 1 yeqiang yeqiang 15K 2024-04-07 14:10:32 qwen_generation_utils.py
-rw-rw-r-- 1 yeqiang yeqiang 2.5M 2024-04-07 14:10:32 qwen.tiktoken
-rw-rw-r-- 1 yeqiang yeqiang 25K 2024-04-07 14:10:32 README.md
-rw-rw-r-- 1 yeqiang yeqiang 11M 2024-04-07 15:02:44 SimSun.ttf
-rw-rw-r-- 1 yeqiang yeqiang 22K 2024-04-07 14:10:32 tokenization_qwen.py
-rw-rw-r-- 1 yeqiang yeqiang 173 2024-04-07 14:10:32 tokenizer_config.json
-rw-rw-r-- 1 yeqiang yeqiang 15K 2024-04-07 14:10:32 visual.py
yeqiang@yeqiang-MS-7B23:~/Downloads/ai/Qwen-VL-Chat$ du -sh
37G .
检查python3版本
yeqiang@yeqiang-MS-7B23:~/Downloads/ai/Qwen-VL-Chat$ python3 -V
Python 3.10.12
创建venv环境
sudo apt install python3.10-venv
cd ~/Downloads/src/Qwen-VL/
python3 -m venv venv
加载env
yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ source venv/bin/activate
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ python -V
Python 3.10.12
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ pip -V
pip 22.0.2 from /home/yeqiang/Downloads/src/Qwen-VL/venv/lib/python3.10/site-packages/pip (python 3.10)
安装依赖
pip install -r requirements.txt
安装好的清单
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ pip list
Package Version
----------------------------- -----------
absl-py 2.1.0
accelerate 0.29.1
certifi 2024.2.2
charset-normalizer 3.3.2
contourpy 1.2.1
cycler 0.12.1
einops 0.7.0
filelock 3.13.3
fonttools 4.51.0
fsspec 2024.3.1
grpcio 1.62.1
huggingface-hub 0.22.2
idna 3.6
Jinja2 3.1.3
kiwisolver 1.4.5
Markdown 3.6
MarkupSafe 2.1.5
matplotlib 3.8.4
mpmath 1.3.0
networkx 3.3
numpy 1.26.4
nvidia-cublas-cu12 12.1.3.1
nvidia-cuda-cupti-cu12 12.1.105
nvidia-cuda-nvrtc-cu12 12.1.105
nvidia-cuda-runtime-cu12 12.1.105
nvidia-cudnn-cu12 8.9.2.26
nvidia-cufft-cu12 11.0.2.54
nvidia-curand-cu12 10.3.2.106
nvidia-cusolver-cu12 11.4.5.107
nvidia-cusparse-cu12 12.1.0.106
nvidia-nccl-cu12 2.19.3
nvidia-nvjitlink-cu12 12.4.127
nvidia-nvtx-cu12 12.1.105
packaging 24.0
pillow 10.3.0
pip 22.0.2
protobuf 5.26.1
psutil 5.9.8
pyparsing 3.1.2
python-dateutil 2.9.0.post0
PyYAML 6.0.1
regex 2023.12.25
requests 2.31.0
safetensors 0.4.2
scipy 1.13.0
setuptools 59.6.0
six 1.16.0
sympy 1.12
tensorboard 2.16.2
tensorboard-data-server 0.7.2
tiktoken 0.6.0
tokenizers 0.13.3
torch 2.2.2
torchvision 0.17.2
tqdm 4.66.2
transformers 4.32.0
transformers-stream-generator 0.0.4
triton 2.2.0
typing_extensions 4.11.0
urllib3 2.2.1
Werkzeug 3.0.2
下载字体
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ wget https://gh-proxy.com/https://github.com/StellarCN/scp_zh/raw/master/fonts/SimSun.ttf
给模型做个软连接
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ ln -s ~/Downloads/ai/Qwen-VL-Chat .
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ ll
总用量 10628
drwxrwxr-x 3 yeqiang yeqiang 4096 2024-04-07 13:58:32 assets
-rw-rw-r-- 1 yeqiang yeqiang 1029 2024-04-07 13:58:32 BUILD.md
-rw-rw-r-- 1 yeqiang yeqiang 1686 2024-04-07 13:58:32 Dockerfile.qwendemo
-rw-rw-r-- 1 yeqiang yeqiang 2209 2024-04-07 13:58:32 Dockerfile.qwenint4openai
-rw-rw-r-- 1 yeqiang yeqiang 1821 2024-04-07 13:58:32 Dockerfile.qwenopenai
drwxrwxr-x 5 yeqiang yeqiang 4096 2024-04-07 13:58:32 eval_mm
-rw-rw-r-- 1 yeqiang yeqiang 2540 2024-04-07 13:58:32 FAQ_ja.md
-rw-rw-r-- 1 yeqiang yeqiang 2235 2024-04-07 13:58:32 FAQ_ko.md
-rw-rw-r-- 1 yeqiang yeqiang 1809 2024-04-07 13:58:32 FAQ.md
-rw-rw-r-- 1 yeqiang yeqiang 2208 2024-04-07 13:58:32 FAQ_zh.md
drwxrwxr-x 2 yeqiang yeqiang 4096 2024-04-07 13:58:32 finetune
-rw-rw-r-- 1 yeqiang yeqiang 12479 2024-04-07 13:58:32 finetune.py
-rw-rw-r-- 1 yeqiang yeqiang 6903 2024-04-07 13:58:32 LICENSE
-rw-rw-r-- 1 yeqiang yeqiang 2703 2024-04-07 13:58:32 NOTICE
-rw-rw-r-- 1 yeqiang yeqiang 17688 2024-04-07 13:58:32 openai_api.py
lrwxrwxrwx 1 yeqiang yeqiang 39 2024-04-07 16:19:51 Qwen-VL-Chat -> /home/yeqiang/Downloads/ai/Qwen-VL-Chat
-rw-rw-r-- 1 yeqiang yeqiang 42732 2024-04-07 13:58:32 README_CN.md
-rw-rw-r-- 1 yeqiang yeqiang 43566 2024-04-07 13:58:32 README_JA.md
-rw-rw-r-- 1 yeqiang yeqiang 42118 2024-04-07 13:58:32 README_KO.md
-rw-rw-r-- 1 yeqiang yeqiang 45050 2024-04-07 13:58:32 README.md
-rw-rw-r-- 1 yeqiang yeqiang 46 2024-04-07 13:58:32 requirements_openai_api.txt
-rw-rw-r-- 1 yeqiang yeqiang 133 2024-04-07 13:58:32 requirements.txt
-rw-rw-r-- 1 yeqiang yeqiang 18 2024-04-07 13:58:32 requirements_web_demo.txt
-rw-rw-r-- 1 yeqiang yeqiang 10518768 2024-04-07 16:18:51 SimSun.ttf
drwxrwxr-x 2 yeqiang yeqiang 103 2024-04-07 13:58:32 touchstone
-rw-rw-r-- 1 yeqiang yeqiang 13203 2024-04-07 13:58:32 TUTORIAL_ja.md
-rw-rw-r-- 1 yeqiang yeqiang 14132 2024-04-07 13:58:32 TUTORIAL_ko.md
-rw-rw-r-- 1 yeqiang yeqiang 13391 2024-04-07 13:58:32 TUTORIAL.md
-rw-rw-r-- 1 yeqiang yeqiang 11423 2024-04-07 13:58:32 TUTORIAL_zh.md
drwxrwxr-x 6 yeqiang yeqiang 115 2024-04-07 16:15:50 venv
-rw-rw-r-- 1 yeqiang yeqiang 9695 2024-04-07 13:58:32 web_demo_mm.py
启动web界面
(venv) yeqiang@yeqiang-MS-7B23:~/Downloads/src/Qwen-VL$ python3 web_demo_mm.py -c ./Qwen-VL-Chat --server-name 0.0.0.0 --server-port 8000
Traceback (most recent call last):
File "/home/yeqiang/Downloads/src/Qwen-VL/web_demo_mm.py", line 12, in <module>
import gradio as gr
ModuleNotFoundError: No module named 'gradio'
漏了web的依赖
pip install -r requirements_web_demo.txt
2060带不动
参考资料
魔搭社区
通义千问
Qwen-VL/README_CN.md at master · QwenLM/Qwen-VL · GitHub