{"record":{"id":"df36d07fbf100430","repo":"huggingface/transformers","slug":"pad-size-must-contain-height-and-width-keys-on","errorCode":null,"errorMessage":"Pad size must contain 'height' and 'width' keys only. Got pad_size={pad_size}.","messagePattern":"Pad size must contain 'height' and 'width' keys only\\. Got pad_size=(.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_processing_backends.py","lineNumber":169,"sourceCode":"    def convert_to_rgb(self, image: ImageInput) -> ImageInput:\n        \"\"\"Convert an image to RGB format.\"\"\"\n        return convert_to_rgb(image)\n\n    def pad(\n        self,\n        images: list[\"torch.Tensor\"],\n        pad_size: SizeDict = None,\n        fill_value: int | None = 0,\n        padding_mode: str | None = \"constant\",\n        return_mask: bool = False,\n        disable_grouping: bool | None = False,\n        is_nested: bool | None = False,\n        **kwargs,\n    ) -> Union[tuple[\"torch.Tensor\", \"torch.Tensor\"], \"torch.Tensor\"]:\n        \"\"\"Pad images using Torchvision with batched operations.\"\"\"\n        if pad_size is not None:\n            if not (pad_size.height and pad_size.width):\n                raise ValueError(f\"Pad size must contain 'height' and 'width' keys only. Got pad_size={pad_size}.\")\n            pad_size = (pad_size.height, pad_size.width)\n        else:\n            pad_size = get_max_height_width(images)\n\n        grouped_images, grouped_images_index = group_images_by_shape(\n            images, disable_grouping=disable_grouping, is_nested=is_nested\n        )\n        processed_images_grouped = {}\n        processed_masks_grouped = {}\n        for shape, stacked_images in grouped_images.items():\n            image_size = stacked_images.shape[-2:]\n            padding_height = pad_size[0] - image_size[0]\n            padding_width = pad_size[1] - image_size[1]\n            if padding_height < 0 or padding_width < 0:\n                raise ValueError(\n                    f\"Padding dimensions are negative. Please make sure that the `pad_size` is larger than the \"\n                    f\"image size. Got pad_size={pad_size}, image_size={image_size}.\"\n                )","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_processing_backends.py#L151-L187","documentation":"Error \"Pad size must contain 'height' and 'width' keys only. Got pad_size={pad_size}.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in image padding when pad_size dict contains keys other than 'height' and 'width'.","commonSituations":"Passing pad_size with size-style keys like 'shortest_edge' or extra entries instead of exactly height/width.","solutions":["Pass `pad_size` as a dict with only 'height' and 'width' keys."],"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"}