Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inference pipeline for VL models #1214

Merged
merged 34 commits into from
Mar 14, 2024
Merged

Conversation

irexyc
Copy link
Collaborator

@irexyc irexyc commented Feb 29, 2024

Motivation

Add vision language chat pipeline

Examples

from lmdeploy.vl import load_image_from_url
from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig

model_path = 'liuhaotian/llava-v1.6-vicuna-7b'
model_name = 'vicuna'
# model_path = 'liuhaotian/llava-v1.5-7b'
# model_name = 'vicuna'
pipe = pipeline(model_path, 
                backend_config=TurbomindEngineConfig(session_len=8192), 
                chat_template_config=ChatTemplateConfig(model_name=model_name))

im = load_image_from_url('https://img11.kcimg.cn/officialpic/0/3/onzc.jpg').convert('RGB')
pipe(('描述这个图片', [im]))
from lmdeploy.vl import load_image_from_url
from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig

model_path = 'Qwen/Qwen-VL-Chat'
model_name = 'qwen-7b'
pipe = pipeline(model_path,
                backend_config=TurbomindEngineConfig(session_len=8192),
                chat_template_config=ChatTemplateConfig(model_name=model_name))

im1 = load_image_from_url('https://raw.githubusercontent.com/QwenLM/Qwen-VL/master/assets/mm_tutorial/Shanghai.jpg').convert('RGB')
im2 = load_image_from_url('https://raw.githubusercontent.com/QwenLM/Qwen-VL/master/assets/mm_tutorial/Chongqing.jpeg').convert('RGB')
pipe(('对比一下这两个图片', [im1, im2]))

@lvhan028 lvhan028 requested a review from pppppM February 29, 2024 08:22
@lvhan028 lvhan028 changed the title vl pipeline Add inference pipeline for VL models Mar 1, 2024
@lvhan028 lvhan028 added the enhancement New feature or request label Mar 2, 2024
@lvhan028 lvhan028 requested a review from lzhangzz March 4, 2024 03:30
Copy link
Collaborator

@AllentDan AllentDan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems lmdeploy list | grep vl can only get yi models

lmdeploy/vl/model/builder.py Outdated Show resolved Hide resolved
logger = get_logger('lmdeploy')


class Record:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring and typehint

@lvhan028 lvhan028 mentioned this pull request Mar 7, 2024
@@ -156,6 +156,66 @@ def sampling_param(self):
repetition_penalty=self.repetition_penalty)


@MODELS.register_module(name='yi-vl-6b')
Copy link
Collaborator

@lvhan028 lvhan028 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

就用一个吧。name='yi-vl'

lmdeploy/vl/utils.py Outdated Show resolved Hide resolved
lmdeploy/vl/model/llava.py Outdated Show resolved Hide resolved
lmdeploy/vl/api.py Outdated Show resolved Hide resolved
lmdeploy/vl/api.py Outdated Show resolved Hide resolved
requirements/test.txt Outdated Show resolved Hide resolved
lmdeploy/api.py Outdated Show resolved Hide resolved
lmdeploy/api.py Outdated Show resolved Hide resolved
lmdeploy/api.py Outdated Show resolved Hide resolved
lmdeploy/api.py Outdated Show resolved Hide resolved
lmdeploy/api.py Outdated Show resolved Hide resolved
lmdeploy/vl/model/yi.py Outdated Show resolved Hide resolved
lmdeploy/archs.py Outdated Show resolved Hide resolved
@AllentDan AllentDan mentioned this pull request Mar 14, 2024
Copy link
Collaborator

@AllentDan AllentDan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lvhan028 lvhan028 merged commit e6fecd8 into InternLM:main Mar 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants