huggingface/transformers · error · ValueError
Invalid COCO panoptic annotations. Annotations must a dict (
Error message
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.
What it means
Error "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." thrown in huggingface/transformers.
Source
Thrown at src/transformers/image_utils.py:997
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."
)
def validate_kwargs(valid_processor_keys: list[str], captured_kwargs: list[str]):
unused_keys = set(captured_kwargs).difference(set(valid_processor_keys))
if unused_keys:
unused_key_str = ", ".join(unused_keys)
# TODO raise a warning here instead of simply logging?
logger.warning(f"Unused or unrecognized kwargs: {unused_key_str}.")
@dataclass()
class SizeDict:
"""
Hashable dictionary to store image size information.View on GitHub (pinned to a597f97485)
Solutions
- Provide annotations as dict(s) with 'image_id', 'file_name', and 'segments_info' keys in COCO panoptic format.
When it happens
Trigger: Raised in COCO panoptic annotation validation when annotations lack image_id/file_name/segments_info structure.
Common situations: Malformed panoptic annotations missing segments_info or file_name in the COCO panoptic format.
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/d59d49892e172025.
Report an issue: GitHub.