Skip to content

Commit

Permalink
fix: refactor/simplify conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
drbh committed Feb 18, 2025
1 parent e4e6ea2 commit 05333b7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions server/text_generation_server/models/vlm_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ def batch_tokenized_inputs(
image = Image.open(BytesIO(chunk.image.data))
# qwen2_vl expects images to be greater than 20 pixels, this is for warmup since the
# default warmup image is 20x20
if (
config.model_type == "qwen2_vl"
or config.model_type == "qwen2_5_vl"
):
if config.model_type in {"qwen2_vl", "qwen2_5_vl"}:
if image.width <= 20:
w = image.width * 2
h = image.height * 2
Expand Down Expand Up @@ -430,10 +427,7 @@ def forward(
max_s = batch.max_current_length
lm_head_indices = batch.prefill_head_indices

if (
self.model.config.model_type == "qwen2_vl"
or self.model.config.model_type == "qwen2_5_vl"
):
if self.model.config.model_type in {"qwen2_vl", "qwen2_5_vl"}:
if position_ids.dim() == 1 and batch.prefilling:
position_ids = self.model.get_position_ids(
input_ids, batch.image_grid_thw
Expand Down

0 comments on commit 05333b7

Please sign in to comment.