{"record":{"id":"005a846e3c2e6e07","repo":"huggingface/transformers","slug":"the-size-dictionary-must-have-keys-height-and-w-005a84","errorCode":null,"errorMessage":"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}","messagePattern":"The size dictionary must have keys 'height' and 'width'\\. Got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_processing_utils.py","lineNumber":522,"sourceCode":"        Args:\n            image (`np.ndarray`):\n                Image to center crop.\n            size (`dict[str, int]`):\n                Size of the output image.\n            data_format (`str` or `ChannelDimension`, *optional*):\n                The channel dimension format for the output image. If unset, the channel dimension format of the input\n                image is used. Can be one of:\n                - `\"channels_first\"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.\n                - `\"channels_last\"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.\n            input_data_format (`ChannelDimension` or `str`, *optional*):\n                The channel dimension format for the input image. If unset, the channel dimension format is inferred\n                from the input image. Can be one of:\n                - `\"channels_first\"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.\n                - `\"channels_last\"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.\n        \"\"\"\n        size = get_size_dict(size)\n        if \"height\" not in size or \"width\" not in size:\n            raise ValueError(f\"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}\")\n        return center_crop(\n            image,\n            size=(size[\"height\"], size[\"width\"]),\n            data_format=data_format,\n            input_data_format=input_data_format,\n            **kwargs,\n        )\n\n\nVALID_SIZE_DICT_KEYS = (\n    {\"height\", \"width\"},\n    {\"shortest_edge\"},\n    {\"shortest_edge\", \"longest_edge\"},\n    {\"longest_edge\"},\n    {\"max_height\", \"max_width\"},\n)\n\n","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_processing_utils.py#L504-L540","documentation":"Error \"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}\" thrown in huggingface/transformers.","triggerScenarios":"Raised in BaseImageProcessor size validation when the size dict lacks 'height' and 'width' keys.","commonSituations":"Custom image processor calls with size given as a dict missing the canonical height/width keys.","solutions":["Provide a size dict with 'height' and 'width' keys.","Call `convert_to_size_dict` to normalize the size input."],"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"}