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
996aa70f
Unverified
Commit
996aa70f
authored
Dec 19, 2024
by
Isotr0py
Committed by
GitHub
Dec 18, 2024
Browse files
[Bugfix] Fix broken phi3-v mm_processor_kwargs tests (#11263)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
60508ffd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
tests/models/decoder_only/vision_language/mm_processor_kwargs/test_phi3v.py
...er_only/vision_language/mm_processor_kwargs/test_phi3v.py
+5
-7
vllm/model_executor/models/phi3v.py
vllm/model_executor/models/phi3v.py
+12
-5
No files found.
tests/models/decoder_only/vision_language/mm_processor_kwargs/test_phi3v.py
View file @
996aa70f
...
@@ -58,16 +58,14 @@ def test_max_tokens_override(get_max_phi3v_image_tokens, model: str,
...
@@ -58,16 +58,14 @@ def test_max_tokens_override(get_max_phi3v_image_tokens, model: str,
@
pytest
.
mark
.
parametrize
(
"model"
,
models
)
@
pytest
.
mark
.
parametrize
(
"model"
,
models
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
"num_crops,expected_toks_per_img
,num_imgs
"
,
"num_crops,expected_toks_per_img"
,
[
[
(
4
,
757
,
1
),
(
4
,
757
),
(
4
,
757
,
2
),
(
16
,
1921
),
(
16
,
1921
,
1
),
(
16
,
1921
,
2
),
# the default num_crops of phi-3.5-vision is 4
# the default num_crops of phi-3.5-vision is 4
(
None
,
757
,
2
),
(
None
,
757
),
(
None
,
757
,
2
),
])
])
@
pytest
.
mark
.
parametrize
(
"num_imgs"
,
[
1
,
2
])
def
test_processor_override
(
processor_for_phi3v
,
image_assets
:
_ImageAssets
,
def
test_processor_override
(
processor_for_phi3v
,
image_assets
:
_ImageAssets
,
model
:
str
,
num_crops
:
Optional
[
int
],
model
:
str
,
num_crops
:
Optional
[
int
],
expected_toks_per_img
:
int
,
num_imgs
:
int
):
expected_toks_per_img
:
int
,
num_imgs
:
int
):
...
...
vllm/model_executor/models/phi3v.py
View file @
996aa70f
...
@@ -302,11 +302,18 @@ class Phi3HDImageEmbedding(Phi3ImageEmbeddingBase):
...
@@ -302,11 +302,18 @@ class Phi3HDImageEmbedding(Phi3ImageEmbeddingBase):
return
image_features_hd_newline
return
image_features_hd_newline
def
get_max_phi3v_image_tokens
(
ctx
:
InputContext
)
->
int
:
def
get_max_phi3v_image_tokens
(
processor
=
ctx
.
get_hf_processor
()
ctx
:
InputContext
,
image_processor
=
processor
.
image_processor
# type: ignore
*
,
num_crops
:
Optional
[
int
]
=
None
,
return
image_processor
.
calc_num_image_tokens_from_image_size
(
)
->
int
:
mm_processor_kwargs
=
{}
if
num_crops
:
mm_processor_kwargs
[
"num_crops"
]
=
num_crops
processor
=
ctx
.
get_hf_processor
(
**
mm_processor_kwargs
)
return
processor
.
calc_num_image_tokens_from_image_size
(
width
=
MAX_IMAGE_FEATURE_SIZE_WIDTH
,
width
=
MAX_IMAGE_FEATURE_SIZE_WIDTH
,
height
=
MAX_IMAGE_FEATURE_SIZE_HEIGHT
,
height
=
MAX_IMAGE_FEATURE_SIZE_HEIGHT
,
)
)
...
...
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