Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,17 @@ def _preprocess(
processed_images = []
batch_num_crops = []

for image_list in images:
for images_list in images:
if do_pan_and_scan:
images_list, num_crops = self._process_images_for_pan_and_scan(
images=image_list,
images=images_list,
do_pan_and_scan=do_pan_and_scan,
pan_and_scan_min_crop_size=pan_and_scan_min_crop_size,
pan_and_scan_max_num_crops=pan_and_scan_max_num_crops,
pan_and_scan_min_ratio_to_activate=pan_and_scan_min_ratio_to_activate,
)
else:
num_crops = [[0] for images in images_list]
num_crops = [[0] for _ in images_list]

# Group images by size for batched processing
processed_image_patches_grouped = {}
Expand Down
23 changes: 23 additions & 0 deletions tests/models/gemma3/test_image_processing_gemma3.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ def test_image_processor_from_dict_with_kwargs(self):
image_processor = image_processing_class.from_dict(self.image_processor_dict, size=84)
self.assertEqual(image_processor.size, {"height": 84, "width": 84})

def test_without_pan_and_scan(self):
"""
Disable do_pan_and_scan parameter.
"""
for image_processing_class in self.image_processor_list:
# Initialize image_processing
image_processor = image_processing_class.from_dict(self.image_processor_dict, do_pan_and_scan=False)

# create random PIL images
image_inputs = self.image_processor_tester.prepare_image_inputs(equal_resolution=True)
for image in image_inputs:
self.assertIsInstance(image, Image.Image)

# Test not batched input
encoded_images = image_processor(image_inputs[0], return_tensors="pt").pixel_values
expected_output_image_shape = (1, 3, 18, 18)
self.assertEqual(tuple(encoded_images.shape), expected_output_image_shape)

# Test batched
encoded_images = image_processor(image_inputs, return_tensors="pt").pixel_values
expected_output_image_shape = (7, 3, 18, 18)
self.assertEqual(tuple(encoded_images.shape), expected_output_image_shape)

def test_pan_and_scan(self):
"""
Enables Pan and Scan path by choosing the correct input image resolution. If you are changing
Expand Down