Which image format is preferred? Error during inference
#26
by
skye0402
- opened
It seems some image formats are not working well (e.g. PNG)
File "/code/.local/lib/python3.10/site-packages/transformers/models/clip/image_processing_clip.py", line 320, in preprocess
input_data_format = infer_channel_dimension_format(images[0])
File "/code/.local/lib/python3.10/site-packages/transformers/image_utils.py", line 209, in infer_channel_dimension_format
raise ValueError("Unable to infer channel dimension format")
Is there a spec somewhere which defines which format is preferred by the model?
hi, can you check if your image mode is color-channeled (BGR/RGB).
@haipingwu can you check this attached png? It was one that didn't work for me.
It doesn't like the alpha channel in the PNG. Convert it like this:
from PIL import Image
image_from_url = Image.open(requests.get(url, stream=True).raw).convert("RGB")
image_from_file = Image.open(file).convert("RGB")