Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
f71b00a1
Unverified
Commit
f71b00a1
authored
Mar 05, 2025
by
Isotr0py
Committed by
GitHub
Mar 05, 2025
Browse files
[Bugfix] Fix broken vision language example (#14292)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
8f808cf8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
examples/offline_inference/vision_language.py
examples/offline_inference/vision_language.py
+18
-22
No files found.
examples/offline_inference/vision_language.py
View file @
f71b00a1
...
@@ -152,15 +152,13 @@ def run_h2ovl(questions: list[str], modality: str):
...
@@ -152,15 +152,13 @@ def run_h2ovl(questions: list[str], modality: str):
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
trust_remote_code
=
True
)
trust_remote_code
=
True
)
prompts
=
[
messages
=
[[{
tokenizer
.
apply_chat_template
([{
'role'
:
'user'
,
'role'
:
'user'
,
'content'
:
f
"<image>
\n
{
question
}
"
'content'
:
f
"<image>
\n
{
question
}
"
}],
}]
for
question
in
questions
]
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
tokenize
=
False
,
tokenize
=
False
,
add_generation_prompt
=
True
)
add_generation_prompt
=
True
)
for
question
in
questions
]
# Stop tokens for H2OVL-Mississippi
# Stop tokens for H2OVL-Mississippi
# https://huggingface.co/h2oai/h2ovl-mississippi-800m
# https://huggingface.co/h2oai/h2ovl-mississippi-800m
...
@@ -209,15 +207,13 @@ def run_internvl(questions: list[str], modality: str):
...
@@ -209,15 +207,13 @@ def run_internvl(questions: list[str], modality: str):
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
trust_remote_code
=
True
)
trust_remote_code
=
True
)
prompts
=
[
messages
=
[[{
tokenizer
.
apply_chat_template
([{
'role'
:
'user'
,
'role'
:
'user'
,
'content'
:
f
"<image>
\n
{
question
}
"
'content'
:
f
"<image>
\n
{
question
}
"
}],
}]
for
question
in
questions
]
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
tokenize
=
False
,
tokenize
=
False
,
add_generation_prompt
=
True
)
add_generation_prompt
=
True
)
for
question
in
questions
]
# Stop tokens for InternVL
# Stop tokens for InternVL
# models variants may have different stop tokens
# models variants may have different stop tokens
...
@@ -399,7 +395,7 @@ def run_mllama(questions: list[str], modality: str):
...
@@ -399,7 +395,7 @@ def run_mllama(questions: list[str], modality: str):
)
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
)
messages
=
[{
messages
=
[
[{
"role"
:
"role"
:
"user"
,
"user"
,
"content"
:
[{
"content"
:
[{
...
@@ -408,7 +404,7 @@ def run_mllama(questions: list[str], modality: str):
...
@@ -408,7 +404,7 @@ def run_mllama(questions: list[str], modality: str):
"type"
:
"text"
,
"type"
:
"text"
,
"text"
:
f
"
{
question
}
"
"text"
:
f
"
{
question
}
"
}]
}]
}
for
question
in
questions
]
}
]
for
question
in
questions
]
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
add_generation_prompt
=
True
,
add_generation_prompt
=
True
,
tokenize
=
False
)
tokenize
=
False
)
...
@@ -454,10 +450,10 @@ def run_nvlm_d(questions: list[str], modality: str):
...
@@ -454,10 +450,10 @@ def run_nvlm_d(questions: list[str], modality: str):
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_name
,
trust_remote_code
=
True
)
trust_remote_code
=
True
)
messages
=
[{
messages
=
[
[{
'role'
:
'user'
,
'role'
:
'user'
,
'content'
:
f
"<image>
\n
{
question
}
"
'content'
:
f
"<image>
\n
{
question
}
"
}
for
question
in
questions
]
}
]
for
question
in
questions
]
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
prompts
=
tokenizer
.
apply_chat_template
(
messages
,
tokenize
=
False
,
tokenize
=
False
,
add_generation_prompt
=
True
)
add_generation_prompt
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment