ValidCOCOKeypointAnnotations#
- class movement.validators.files.ValidCOCOKeypointAnnotations(file)[source]#
Bases:
objectClass for validating COCO keypoint annotations (.json) files.
The validator ensures that the file:
is well-formed JSON,
contains the
images,annotationsandcategorieslists, each with the keys required by the COCO annotations format,defines at least one category, each with a non-empty list of keypoint names, and
defines the same keypoint names, in the same order, for all categories, as
movementcurrently requires all individuals to share the same set of keypoints.
The parsed annotations are stored in
data. The categories are accessible by ID viacategories, and the shared keypoint names viakeypoint_names.- Raises:
ValueError – If the file is not valid JSON or does not match the expected schema.
- property categories: dict[int, dict[str, Any]]#
COCO categories from the annotations file, keyed by ID.
- schema: ClassVar[Mapping[str, Any]] = {'$schema': 'https://json-schema.org/draft/2020-12/schema', 'description': 'Schema for validating COCO keypoint detection annotations JSON files', 'properties': {'annotations': {'items': {'properties': {'category_id': {'type': 'integer'}, 'id': {'type': 'integer'}, 'image_id': {'type': 'integer'}, 'keypoints': {'items': {'type': 'number'}, 'minItems': 3, 'type': 'array'}}, 'required': ['id', 'image_id', 'category_id', 'keypoints'], 'type': 'object'}, 'type': 'array'}, 'categories': {'items': {'properties': {'id': {'type': 'integer'}, 'keypoints': {'items': {'type': 'string'}, 'minItems': 1, 'type': 'array'}, 'name': {'type': 'string'}}, 'required': ['id', 'name', 'keypoints'], 'type': 'object'}, 'minItems': 1, 'type': 'array'}, 'images': {'items': {'properties': {'id': {'type': 'integer'}}, 'required': ['id'], 'type': 'object'}, 'type': 'array'}}, 'required': ['images', 'annotations', 'categories'], 'title': 'COCO Keypoint Annotations', 'type': 'object'}#
JSON schema for validating the structure of the COCO annotations file.