Compare commits

...

7 Commits

Author SHA1 Message Date
f3ff530a45 [run-slow] pixtral 2024-12-05 18:45:21 +00:00
6769700a16 Correct nesting in test 2024-12-05 18:41:21 +00:00
af9f67c9d9 Correct nesting in test 2024-12-05 18:40:35 +00:00
3406432db3 More error handling 2024-12-05 18:36:06 +00:00
031fdd5e10 make fixup 2024-12-05 18:32:42 +00:00
ed0b4303e3 Fix the structure of images output by the processor 2024-12-05 18:31:08 +00:00
49055e150d Fix the structure of images output by the processor 2024-12-05 18:19:10 +00:00
2 changed files with 14 additions and 5 deletions

View File

@ -204,12 +204,21 @@ class PixtralProcessor(ProcessorMixin):
if images is not None:
if is_image_or_image_url(images):
images = [[images]]
elif isinstance(images, list) and is_image_or_image_url(images[0]):
if isinstance(text, list):
images = [[im] for im in images]
if isinstance(text, str) or isinstance(text, list) and len(text) == 1:
# If there's a single sample, the image must belong to it
images = [[images]]
else:
raise ValueError(
"You have supplied multiple text samples, but `images` is not a nested list. When processing multiple samples, `images` should be a list of lists of images, one list per sample."
)
elif isinstance(images, list) and is_image_or_image_url(images[0]):
if isinstance(text, str) or isinstance(text, list) and len(text) == 1:
# If there's a single sample, all images must belong to it
images = [images]
else:
raise ValueError(
"You have supplied multiple text samples, but `images` is not a nested list. When processing multiple samples, `images` should be a list of lists of images, one list per sample."
)
elif isinstance(images, list) and isinstance(images[0], list) and is_image_or_image_url(images[0][0]):
pass
else:

View File

@ -253,7 +253,7 @@ class PixtralProcessorTest(ProcessorTesterMixin, unittest.TestCase):
"USER: [IMG]\nWhat's the content of the image? ASSISTANT:",
] * 5
processor.tokenizer.pad_token = "</s>"
image_inputs = [self.image_0] * 5
image_inputs = [[self.image_0]] * 5
# Make small for checking image token expansion
processor.image_processor.size = {"longest_edge": 30}