{"record":{"id":"d7983508f8f99a58","repo":"huggingface/transformers","slug":"invalid-coco-detection-annotations-annotations-mu","errorCode":null,"errorMessage":"Invalid COCO detection annotations. Annotations must a dict (single image) or list of dicts (batch of images) with the following keys: `image_id` and `annotations`, with the latter being a list of annotations in the COCO format.","messagePattern":"Invalid COCO detection annotations\\. Annotations must a dict \\(single image\\) or list of dicts \\(batch of images\\) with the following keys: `image_id` and `annotations`, with the latter being a list of annotations in the COCO format\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_utils.py","lineNumber":989,"sourceCode":"        if not isinstance(image, PIL.Image.Image):\n            image = self.to_pil_image(image)\n\n        return image.rotate(\n            angle, resample=resample, expand=expand, center=center, translate=translate, fillcolor=fillcolor\n        )\n\n\ndef validate_annotations(\n    annotation_format: AnnotationFormat,\n    supported_annotation_formats: tuple[AnnotationFormat, ...],\n    annotations: list[dict],\n) -> None:\n    if annotation_format not in supported_annotation_formats:\n        raise ValueError(f\"Unsupported annotation format: {format} must be one of {supported_annotation_formats}\")\n\n    if annotation_format is AnnotationFormat.COCO_DETECTION:\n        if not valid_coco_detection_annotations(annotations):\n            raise ValueError(\n                \"Invalid COCO detection annotations. Annotations must a dict (single image) or list of dicts \"\n                \"(batch of images) with the following keys: `image_id` and `annotations`, with the latter \"\n                \"being a list of annotations in the COCO format.\"\n            )\n\n    if annotation_format is AnnotationFormat.COCO_PANOPTIC:\n        if not valid_coco_panoptic_annotations(annotations):\n            raise ValueError(\n                \"Invalid COCO panoptic annotations. Annotations must a dict (single image) or list of dicts \"\n                \"(batch of images) with the following keys: `image_id`, `file_name` and `segments_info`, with \"\n                \"the latter being a list of annotations in the COCO format.\"\n            )\n\n\ndef validate_kwargs(valid_processor_keys: list[str], captured_kwargs: list[str]):\n    unused_keys = set(captured_kwargs).difference(set(valid_processor_keys))\n    if unused_keys:\n        unused_key_str = \", \".join(unused_keys)","sourceCodeStart":971,"sourceCodeEnd":1007,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_utils.py#L971-L1007","documentation":"Error \"Invalid COCO detection annotations. Annotations must a dict (single image) or list of dicts (batch of images) with the following keys: `image_id` and `annotations`, with the latter being a list of annotations in the COCO format.\" thrown in huggingface/transformers.","triggerScenarios":"Raised in COCO detection annotation validation when annotations lack image_id/annotations structure.","commonSituations":"Malformed detection annotations, e.g. a flat list of boxes instead of the COCO dict layout.","solutions":["Provide annotations as dict(s) with 'image_id' and 'annotations' keys in COCO detection format."],"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"}