Skip to content

Draft: Create specialized classes for handling annotations

Daniel CARRON requested to merge generalize-annotations into main

Created Annotation classes to process various types of annotations.

BaseAnnotations is a parent class that defines methods that specialized classes should implement, such as load() and compute_metrics(). The boundingbox-related code has been moved outside of tbx11k, into boundingbox_annotations.py, which can be reused if needed.

To use Annotations, we create a dict of {metadata_key: Annotations()} inside the datamodule constructors. For example, in tbx11k:

https://gitlab.idiap.ch/biosignal/software/mednet/-/blob/8474d57728894d8105a70809a69c3e13884fc6ce/src/mednet/config/data/tbx11k/datamodule.py#L241

annotations: dict[str, BaseAnnotations] = {
            "bounding_boxes": BoundingBoxAnnotations()
        },

The key corresponds to the one defined in the sample() method.

Some annotations will require transforms to be applied to them, for example the masks used in deepdraw. For that purpose, mask_transforms have been added. These should be defined in each model as a subset of model_transforms and only contain rotate/scale/flip/etc. transforms. They can then be used inside Annotations.load() if needed.

Merge request reports