huggingface/transformers · error · ValueError

Unsupported annotation format: {format} must be one of {supp

Error message

Unsupported annotation format: {format} must be one of {supported_annotation_formats}

What it means

Error "Unsupported annotation format: {format} must be one of {supported_annotation_formats}" thrown in huggingface/transformers.

Source

Thrown at src/transformers/image_utils.py:985

        resample = resample if resample is not None else PIL.Image.NEAREST

        self._ensure_format_supported(image)

        if not isinstance(image, PIL.Image.Image):
            image = self.to_pil_image(image)

        return image.rotate(
            angle, resample=resample, expand=expand, center=center, translate=translate, fillcolor=fillcolor
        )


def validate_annotations(
    annotation_format: AnnotationFormat,
    supported_annotation_formats: tuple[AnnotationFormat, ...],
    annotations: list[dict],
) -> None:
    if annotation_format not in supported_annotation_formats:
        raise ValueError(f"Unsupported annotation format: {format} must be one of {supported_annotation_formats}")

    if annotation_format is AnnotationFormat.COCO_DETECTION:
        if not valid_coco_detection_annotations(annotations):
            raise ValueError(
                "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."
            )

    if annotation_format is AnnotationFormat.COCO_PANOPTIC:
        if not valid_coco_panoptic_annotations(annotations):
            raise ValueError(
                "Invalid COCO panoptic annotations. Annotations must a dict (single image) or list of dicts "
                "(batch of images) with the following keys: `image_id`, `file_name` and `segments_info`, with "
                "the latter being a list of annotations in the COCO format."
            )

View on GitHub (pinned to a597f97485)

Solutions

  1. Use one of the supported annotation formats (e.g. 'coco_detection' or 'coco_panoptic').
  2. Convert annotations to a supported format first.

When it happens

Trigger: Raised in annotation format validation when format is not one of the supported COCO annotation formats.

Common situations: Passing an unknown format string (not coco_detection/coco_panoptic) to annotation processing utilities.


AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14). Data as JSON: /api/errors/77c661e41989a694. Report an issue: GitHub.