PhiCookBook
PhiCookBook copied to clipboard
Phi4 Multimodal - No Image error - StopIteration
inputs = processor(text=prompt, images=None, audios=[audio], return_tensors='pt').to('cuda:0')
When images is set to None the following error occurs
Traceback (most recent call last):
File "/opt/phi4mm/main5.py", line 50, in <module>
inputs = processor(text=prompt, images=None, audios=[audio], return_tensors='pt').to('cuda:0')
File "/home/brennon/.cache/huggingface/modules/transformers_modules/microsoft/Phi-4-multimodal-instruct/39125531cc274876704bb1ef2eb84fdf8f37a419/processing_phi4mm.py", line 573, in __call__
inputs = self._convert_images_audios_text_to_inputs(
File "/home/brennon/.cache/huggingface/modules/transformers_modules/microsoft/Phi-4-multimodal-instruct/39125531cc274876704bb1ef2eb84fdf8f37a419/processing_phi4mm.py", line 654, in _convert_images_audios_text_to_inputs
token_count = next(image_token_count_iter)
StopIteration
(venv) brennon@BIG-DOG:/opt/phi4mm$
Update - this error occurs when an <|Image_1|> tag is present in the system prompt. Still, it should handle this a bit better.
Hi @OldManMeta
Could you please confirm which sample this issue is related too?
Hi @leestott - pretty sure this will happen in any sample that contains a system prompt tag without a supplied image input.
Apologies but all my code is base, not using your samples - though they have been very helpful. Thanks.