ValidCOCO#

class ethology.annotations.validators.ValidCOCO(path)[source]#

Bases: object

Class for valid COCO JSON files.

It checks the input file is a valid JSON file, matches the COCO schema and contains the required keys.

path#

Path to the COCO JSON file, passed as an input.

Type:

Path | str

schema#

The JSON schema is set to the default COCO schema.

Type:

dict

required_keys#

The required keys for the COCO JSON file.

Type:

dict

Raises:
  • ValueError – If the JSON file cannot be decoded.

  • jsonschema.exceptions.ValidationError – If the type of any of the keys in the JSON file does not match the type specified in the schema.

  • jsonschema.exceptions.SchemaError – If the schema is invalid.

  • ValueError – If the COCO JSON file is missing any of the required keys.