Transform

class cocohelper.transforms.transform.Transform[source]

Bases: ABC

Method List

apply(img, anns)

Apply the transformation to the image array and its annotations.

compute_bbox_area(bbox)

Compute area from a bounding box.

transform_dataset(coco, out_dir)

Apply an abstract transformation on the whole dataset.

Attributes List

_abc_impl

Methods Details

abstract apply(img, anns)[source]

Apply the transformation to the image array and its annotations.

Parameters:
  • img (ndarray) – image array

  • anns (List[dict]) – annotations for this image

Returns:

Transformed image array and annotations

Return type:

Tuple[ndarray, List[dict]]

static compute_bbox_area(bbox)[source]

Compute area from a bounding box.

Parameters:

bbox (List[int]) – bounding box.

Returns:

The area inside the given bounding box.

Return type:

int

transform_dataset(coco, out_dir)[source]

Apply an abstract transformation on the whole dataset.

TODO: should we apply on the whole dataset eagerly or use a lazy execution when the data is obtained?
  • In the first case, apply takes a COCODataset and returns a new modified COCODataset.

  • In the second case probably COCODataset should have a reference to a Transform and apply just-in-time when an element is retrieved.

Parameters:
  • coco (COCOHelper) –

  • out_dir (Union[str, Path]) –

Return type:

COCOHelper

Attribute Details

_abc_impl = <_abc._abc_data object>