Fix the structure of images output by the processor

This commit is contained in:
Matt 2024-12-05 18:31:08 +00:00
parent 49055e150d
commit ed0b4303e3

View file

@ -206,7 +206,11 @@ class PixtralProcessor(ProcessorMixin):
if is_image_or_image_url(images):
images = [[images]]
elif isinstance(images, list) and is_image_or_image_url(images[0]):
images = [images]
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 only a flat list of images. 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: