Compose

class cocohelper.transforms.compose.Compose[source]

Bases: Transform

Combine different Transform into one.

Parameters:

transforms – The list of Transform to combine.

Method List

append(transform)

Append transformations to be applied to the COCO data.

apply(img, anns)

Apply the transformation to the image array and its annotations.

clear()

compute_bbox_area(bbox)

Compute area from a bounding box.

insert(transform[, index])

pop([index])

remove(transform)

reverse()

transform_dataset(coco, out_dir)

Apply an abstract transformation on the whole dataset.

Attributes List

_abc_impl

Methods Details

append(transform)[source]

Append transformations to be applied to the COCO data.

Parameters:

transform (Transform) – a Transformation to be applied.

Returns:

self.

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]]

clear()[source]
static compute_bbox_area(bbox)

Compute area from a bounding box.

Parameters:

bbox (List[int]) – bounding box.

Returns:

The area inside the given bounding box.

Return type:

int

insert(transform, index=0)[source]
Parameters:
pop(index=-1)[source]
Parameters:

index (int) –

remove(transform)[source]
Parameters:

transform (Transform) –

reverse()[source]
transform_dataset(coco, out_dir)

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>