Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

如何在本地安装和配置InternVL以进行多模态对话?

2025-08-24 1.0 K

Preparation for installation

首先需要配置Python 3.9环境,建议使用conda管理虚拟环境。

Installation steps

  1. clone warehouse: Run it in the terminalgit clone https://github.com/OpenGVLab/InternVL.gitand enter the catalog
  2. Creating a Virtual Environment: Useconda create -n internvl python=3.9 -yCreating the Environment
  3. Installation of basic dependencies: Runpip install -r requirements.txtInstallation 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内存,处理高分辨率图像时可能需要更多资源。

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish