Preparation for installation
首先需要配置Python 3.9环境,建议使用conda管理虚拟环境。
Installation steps
- clone warehouse: Run it in the terminal
git clone https://github.com/OpenGVLab/InternVL.git
and enter the catalog - Creating a Virtual Environment: Use
conda create -n internvl python=3.9 -y
Creating the Environment - Installation of basic dependencies: Run
pip install -r requirements.txt
Installation of core libraries
Optional Mounting
- mountingFlash-Attention以加速推理:
pip install flash-attn==2.3.6
- 安装MMDeploy用于生产部署:
mim install mmdeploy
多模态对话使用
下载模型(如InternVL2_5-8B)后,可以使用以下代码进行多模态对话:
from lmdeploy import pipeline
from lmdeploy.vl import load_image
model = 'OpenGVLab/InternVL2_5-8B'
image = load_image('tiger.jpeg')
pipe = pipeline(model)
response = pipe(('描述这张图片', image))
print(response.text)
caveat
8B模型约需16GB GPU内存,处理高分辨率图像时可能需要更多资源。
This answer comes from the articleInternVL: Open Source Multimodal Large Model with Image, Video and Text Processing SupportThe