{"record":{"id":"9f838699bfb105a5","repo":"huggingface/transformers","slug":"size-must-contain-height-and-width-keys-or-m","errorCode":null,"errorMessage":"Size must contain 'height' and 'width' keys, or 'max_height' and 'max_width', or 'shortest_edge' key. Got {size}.","messagePattern":"Size must contain 'height' and 'width' keys, or 'max_height' and 'max_width', or 'shortest_edge' key\\. Got (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_processing_backends.py","lineNumber":249,"sourceCode":"        if size.shortest_edge and size.longest_edge:\n            new_size = get_size_with_aspect_ratio(\n                image.size()[-2:],\n                size.shortest_edge,\n                size.longest_edge,\n            )\n        elif size.shortest_edge:\n            new_size = get_resize_output_image_size(\n                image,\n                size=size.shortest_edge,\n                default_to_square=False,\n                input_data_format=ChannelDimension.FIRST,\n            )\n        elif size.max_height and size.max_width:\n            new_size = get_image_size_for_max_height_width(image.size()[-2:], size.max_height, size.max_width)\n        elif size.height and size.width:\n            new_size = (size.height, size.width)\n        else:\n            raise ValueError(\n                \"Size must contain 'height' and 'width' keys, or 'max_height' and 'max_width', or 'shortest_edge' key. Got\"\n                f\" {size}.\"\n            )\n\n        # Workaround for torch.compile issue with uint8 on AMD GPUs\n        if is_torchdynamo_compiling() and is_rocm_platform():\n            return self._compile_friendly_resize(image, new_size, interpolation, antialias)\n        return tvF.resize(image, new_size, interpolation=interpolation, antialias=antialias)\n\n    @staticmethod\n    def _compile_friendly_resize(\n        image: \"torch.Tensor\",\n        new_size: tuple[int, int],\n        interpolation: Optional[\"tvF.InterpolationMode\"] = None,\n        antialias: bool = True,\n    ) -> \"torch.Tensor\":\n        \"\"\"A wrapper around tvF.resize for torch.compile compatibility with uint8 tensors.\"\"\"\n        if image.dtype == torch.uint8:","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_processing_backends.py#L231-L267","documentation":"Error \"Size must contain 'height' and 'width' keys, or 'max_height' and 'max_width', or 'shortest_edge' key. Got {size}.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in image resize preprocessing when the size dict lacks a recognized key combination.","commonSituations":"size dict without ('height','width'), ('max_height','max_width'), or 'shortest_edge' keys passed to a resize backend.","solutions":["Provide size with 'height'/'width', 'max_height'/'max_width', or 'shortest_edge' keys.","Use `get_size_dict` to normalize the size argument."],"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-15T17:31:12.345Z"}