ValueError: Unable to infer channel dimension format

#26
by vishal1278 - opened

I am able to successfully run the code that are provided as examples (in the Model card section) using bus.png and chart.png images. However, whenever I try to run it on any other images, I get the following error message:

Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:07<00:00,  3.88s/it]
Traceback (most recent call last):
  File "/home/vishal/code/fuyu/test_2.py", line 14, in <module>
    model_inputs = processor(text_prompt, images=[image_pil], device="cuda:0")
  File "/home/vishal/code/fuyu/.venv/lib/python3.10/site-packages/transformers/models/fuyu/processing_fuyu.py", line 464, in __call__
    batch_images, image_unpadded_heights, image_unpadded_widths = self._process_images(images)
  File "/home/vishal/code/fuyu/.venv/lib/python3.10/site-packages/transformers/models/fuyu/processing_fuyu.py", line 399, in _process_images
    channel_dimension = in
![two-axis-plot.png](https://cdn-uploads.huggingface.co/production/uploads/63ed7313f765928ceeb07bf5/UDcWsj9Scc3-buc5wxncI.png)
fer_channel_dimension_format(image, 3)
  File "/home/vishal/code/fuyu/.venv/lib/python3.10/site-packages/transformers/image_utils.py", line 189, in infer_channel_dimension_format
    raise ValueError("Unable to infer channel dimension format")
ValueError: Unable to infer channel dimension format

I have attached one image that I have been trying to ask questions about using this model.

image = Image.open(image_path).convert("RGB") should fix this

I met the same question too, maybe png format like rgba image have not yet accept.

Hi @KongoCat ! The solution suggested above by @gauravverma should work fine :)

Hi @KongoCat ! The solution suggested above by @gauravverma should work fine :)

thanks!

image = Image.open(image_path).convert("RGB") should fix this

Thank you, @gauravverma !

Sign up or log in to comment