Resize
- class cocohelper.transforms.resize.Resize[source]
Bases:
Transform
Method List
_resize_bbox
(bbox, ratios)Resize bounding box with the given ratios.
_resize_image_array
(image, output_size)Resize image array to the given output size.
_resize_segmentations
(segmentations, ratios)Resize the segmentation with the given ratios.
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
Methods Details
- static _resize_bbox(bbox, ratios)[source]
Resize bounding box with the given ratios.
- Parameters:
bbox (List[int]) –
ratios (List[float]) –
- Return type:
List[int]
- static _resize_image_array(image, output_size)[source]
Resize image array to the given output size.
- Parameters:
image (ndarray) –
output_size (List[int]) –
- Return type:
ndarray
- static _resize_segmentations(segmentations, ratios)[source]
Resize the segmentation with the given ratios.
- Parameters:
segmentations (List[List]) –
ratios (List[float]) –
- Return type:
List[List]
- 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)
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)
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:
Attribute Details
- _abc_impl = <_abc._abc_data object>