supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Proposal for lazy-loaded annotations.

Open LinasKo opened this issue 1 year ago • 0 comments

This branch contains a proposal for lazy-loading annotations for DetectionsDataset.

It's been tested scarcely - enough to show that memory usage does not grow when loading a large YOLO dataset. The main purpose is to have a code reference for further discussions.

Description

  • A LazyDict data structure calls a loading function when values are retrieved
  • This enables us to conceptualize a lazy_detections objects, which store masks as polygons until loaded.
  • Such polygons are placed in data along with resolution_xy
  • The dataset can take either lazy-loaded or normal Detections
  • So far, only yolo_annotations_to_detections was changed to produce lazy values.
  • The dataset can still function as before - the main different users will see is the datatype for annotations input: Union[Dict[str, Detections], LazyDict[str, Detections, Detections].

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

pytest + loaded yolo dataset with it, comparing memory use and outputs with non-lazy method.

The memory use does not grow, and the results are the same.

I did not test this thoroughly so far.

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • [ ] Docs updated? What were the changes:

LinasKo avatar Aug 27 '24 08:08 LinasKo