PhiCookBook icon indicating copy to clipboard operation
PhiCookBook copied to clipboard

Phi4 Multimodal - No Image error - StopIteration

Open OldManMeta opened this issue 9 months ago • 3 comments

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$ 

OldManMeta avatar Mar 01 '25 10:03 OldManMeta

Update - this error occurs when an <|Image_1|> tag is present in the system prompt. Still, it should handle this a bit better.

OldManMeta avatar Mar 01 '25 19:03 OldManMeta

Hi @OldManMeta

Could you please confirm which sample this issue is related too?

leestott avatar Mar 02 '25 10:03 leestott

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.

OldManMeta avatar Mar 05 '25 07:03 OldManMeta