huggingface/transformers · error · ValueError
Unsupported input image type {image_type}
Error message
Unsupported input image type {image_type} What it means
Error "Unsupported input image type {image_type}" thrown in huggingface/transformers.
Source
Thrown at src/transformers/image_processing_backends.py:127
elif isinstance(image_url_or_urls, str):
return load_image_as_tensor(image_url_or_urls)
elif is_valid_image(image_url_or_urls):
return image_url_or_urls
else:
raise TypeError(f"only a single or a list of entries is supported but got type={type(image_url_or_urls)}")
def process_image(
self,
image: ImageInput,
do_convert_rgb: bool | None = None,
input_data_format: str | ChannelDimension | None = None,
device: Optional["torch.device"] = None,
**kwargs: Unpack[ImagesKwargs],
) -> "torch.Tensor":
"""Process a single image for torchvision backend."""
image_type = get_image_type(image)
if image_type not in [ImageType.PIL, ImageType.TORCH, ImageType.NUMPY]:
raise ValueError(f"Unsupported input image type {image_type}")
if do_convert_rgb:
image = self.convert_to_rgb(image)
if image_type == ImageType.PIL:
image = tvF.pil_to_tensor(image)
elif image_type == ImageType.NUMPY:
image = torch.from_numpy(image).contiguous()
if image.ndim == 2:
image = image.unsqueeze(0)
if input_data_format is None:
input_data_format = infer_channel_dimension_format(image)
if input_data_format == ChannelDimension.LAST:
image = image.permute(2, 0, 1).contiguous()
View on GitHub (pinned to a597f97485)
Solutions
- Pass images as PIL images, numpy arrays, or torch tensors.
- Convert the input with `load_image` or `Image.open` first.
When it happens
Trigger: Raised in image processing backend dispatch when the input image type has no registered backend handler.
Common situations: Feeding an unsupported object (e.g. a raw bytes buffer or unknown array type) as an image to the processor.
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/bdf237e14b581e75.
Report an issue: GitHub.