Skip to content

Commit

Permalink
handle slow and fast processor for qwen2vl
Browse files Browse the repository at this point in the history
Signed-off-by: isotr0py <[email protected]>
  • Loading branch information
Isotr0py committed Feb 14, 2025
1 parent 8319423 commit 43c24d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vllm/model_executor/models/qwen2_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange, repeat
from packaging.version import Version
from transformers import BatchFeature
from transformers import __version__ as TRANSFORMERS_VERSION
from transformers.models.qwen2_vl import (Qwen2VLImageProcessor,
Qwen2VLProcessor)
from transformers.models.qwen2_vl.configuration_qwen2_vl import (
Expand Down Expand Up @@ -759,7 +761,13 @@ def get_image_processor(
hf_processor = self.get_hf_processor(min_pixels=min_pixels,
max_pixels=max_pixels)
image_processor = hf_processor.image_processor # type: ignore
assert isinstance(image_processor, Qwen2VLImageProcessor)
if Version(TRANSFORMERS_VERSION) >= Version("4.49"):
from transformers.models.qwen2_vl import Qwen2VLImageProcessorFast
assert isinstance(
image_processor,
(Qwen2VLImageProcessor, Qwen2VLImageProcessorFast))
else:
assert isinstance(image_processor, Qwen2VLImageProcessor)
return image_processor

def get_supported_mm_limits(self) -> Mapping[str, Optional[int]]:
Expand Down

0 comments on commit 43c24d8

Please sign in to comment.