From f83689cb493b1872648e1506c3a2ee5552602195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Farr=C3=A9?= Date: Fri, 20 Dec 2024 19:54:37 +0100 Subject: [PATCH] Update src/transformers/models/idefics3/processing_idefics3.py Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com> --- src/transformers/models/idefics3/processing_idefics3.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transformers/models/idefics3/processing_idefics3.py b/src/transformers/models/idefics3/processing_idefics3.py index a64d62cef012a9..7ca5829e2063d8 100644 --- a/src/transformers/models/idefics3/processing_idefics3.py +++ b/src/transformers/models/idefics3/processing_idefics3.py @@ -325,6 +325,10 @@ def __call__( inputs.update(text_inputs) elif text is not None: + if any(n_images_in_text): + raise ValueError( + f"Found {sum(n_images_in_text)} {self.image_token.content} tokens in the text but no images were passed." + ) text_inputs = self.tokenizer(text=text, **output_kwargs["text_kwargs"]) inputs.update(text_inputs)