Skip to content

Commit

Permalink
fix variable undefined bug when return_tensors is not specified in ll…
Browse files Browse the repository at this point in the history
…ava processing (#34953)

* fix variable undefined bug when return_tensors is not specified in llava processor

* improve readability
  • Loading branch information
chenweize1998 authored Dec 2, 2024
1 parent 3480cbb commit 9ab8c5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/transformers/models/llava_next/processing_llava_next.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def __call__(
image_size = next(image_sizes)
if not isinstance(image_size, (list, tuple)):
# cast to list to avoid numerical precision errors when calculating unpadding
orig_height, orig_width = image_size.tolist()
image_size = image_size.tolist()
orig_height, orig_width = image_size
num_image_tokens = self._get_number_of_features(orig_height, orig_width, height, width)
if self.vision_feature_select_strategy == "default":
num_image_tokens -= self.num_additional_image_tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def __call__(
image_size = next(image_sizes)
if not isinstance(image_size, (list, tuple)):
# cast to list to avoid numerical precision errors when calculating unpadding
orig_height, orig_width = image_size.tolist()
image_size = image_size.tolist()
orig_height, orig_width = image_size
num_image_tokens = self._get_number_of_features(orig_height, orig_width, height, width)
if self.vision_feature_select_strategy == "default":
num_image_tokens -= self.num_additional_image_tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def _expand_image_tokens(
original_size = image_size_list[0] if num_frames != 1 else image_size_list
if not isinstance(original_size, (list, tuple)):
# cast to list to avoid numerical precision errors when calculating unpadding
orig_height, orig_width = original_size.tolist()
original_size = original_size.tolist()
orig_height, orig_width = original_size
num_image_tokens = self._get_number_of_features(orig_height, orig_width, height, width)
if self.vision_feature_select_strategy == "default":
num_image_tokens -= 1
Expand Down

0 comments on commit 9ab8c5b

Please sign in to comment.