Skip to content

Commit

Permalink
Paligemma: revert huggingface#36084 (huggingface#36113)
Browse files Browse the repository at this point in the history
* revert

* type check
  • Loading branch information
zucchini-nlp authored and sbucaille committed Feb 14, 2025
1 parent da6e419 commit d62373e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/transformers/models/paligemma/processing_paligemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import List, Optional, Union

from ...feature_extraction_utils import BatchFeature
from ...image_utils import ImageInput, is_valid_image, make_flat_list_of_images, make_nested_list_of_images
from ...image_utils import ImageInput, is_valid_image, make_flat_list_of_images
from ...processing_utils import (
ImagesKwargs,
ProcessingKwargs,
Expand Down Expand Up @@ -256,7 +256,17 @@ def __call__(
)

# make a nested list of lists to be able to iterate over the images and text below
images = make_nested_list_of_images(images)
if is_valid_image(images):
images = [[images]]
elif isinstance(images, (list, tuple)) and is_valid_image(images[0]):
images = [[image] for image in images]
elif not (
isinstance(images, (list, tuple))
and isinstance(images[0], (list, tuple))
and is_valid_image(images[0][0])
):
raise ValueError("images must be an image, list of images or list of list of images")

input_strings = [
build_string_from_input(
prompt=prompt,
Expand Down

0 comments on commit d62373e

Please sign in to comment.