{"record":{"id":"e101674744ff7a87","repo":"huggingface/transformers","slug":"got-type-type-image-which-is-not-supported-onl","errorCode":null,"errorMessage":"Got type {type(image)} which is not supported, only `PIL.Image.Image`, `np.ndarray` and `torch.Tensor` are.","messagePattern":"Got type (.+?) which is not supported, only `PIL\\.Image\\.Image`, `np\\.ndarray` and `torch\\.Tensor` are\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_utils.py","lineNumber":635,"sourceCode":"\n    if do_normalize and (image_mean is None or image_std is None):\n        raise ValueError(\"`image_mean` and `image_std` must both be specified if `do_normalize` is `True`.\")\n\n    if do_center_crop and crop_size is None:\n        raise ValueError(\"`crop_size` must be specified if `do_center_crop` is `True`.\")\n\n    if do_resize and not (size is not None and resample is not None):\n        raise ValueError(\"`size` and `resample` must be specified if `do_resize` is `True`.\")\n\n\nclass ImageFeatureExtractionMixin:\n    \"\"\"\n    Mixin that contain utilities for preparing image features.\n    \"\"\"\n\n    def _ensure_format_supported(self, image):\n        if not isinstance(image, (PIL.Image.Image, np.ndarray)) and not is_torch_tensor(image):\n            raise ValueError(\n                f\"Got type {type(image)} which is not supported, only `PIL.Image.Image`, `np.ndarray` and \"\n                \"`torch.Tensor` are.\"\n            )\n\n    def to_pil_image(self, image, rescale=None):\n        \"\"\"\n        Converts `image` to a PIL Image. Optionally rescales it and puts the channel dimension back as the last axis if\n        needed.\n\n        Args:\n            image (`PIL.Image.Image` or `numpy.ndarray` or `torch.Tensor`):\n                The image to convert to the PIL Image format.\n            rescale (`bool`, *optional*):\n                Whether or not to apply the scaling factor (to make pixel values integers between 0 and 255). Will\n                default to `True` if the image type is a floating type, `False` otherwise.\n        \"\"\"\n        self._ensure_format_supported(image)\n","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_utils.py#L617-L653","documentation":"Error \"Got type {type(image)} which is not supported, only `PIL.Image.Image`, `np.ndarray` and `torch.Tensor` are.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in image type validation when input is not a PIL image, numpy array, or torch tensor.","commonSituations":"Passing lists, scalars, or TensorFlow/JAX tensors where only PIL/np/torch images are accepted.","solutions":["Convert the image to PIL.Image.Image, np.ndarray, or torch.Tensor before processing.","Use `load_image` for URLs, paths, or base64 strings."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}