ToBBoxes

class hybrid_learning.datasets.transforms.image_transforms.ToBBoxes(bbox_size, iou_threshold=0.5, batch_wise=False)[source]

Bases: BatchWiseImageTransform

Treat pixels of given mask as scores of constant-size bounding boxes, and return a mask with the non-max-suppressed bounding boxes.

Public Data Attributes:

bbox_size

The constant size to be assumed for all bounding boxes in pixels.

settings

Settings to reproduce the instance.

Inherited from : py: class:BatchWiseImageTransform

settings

Settings to reproduce the instance.

Inherited from : py: class:Transform

IDENTITY_CLASS

The identity class or classes for composition / addition.

settings

Settings to reproduce the instance.

Public Methods:

apply_to_batch(score_masks)

Bloat the score_masks to a mask of non-max-suppressed bounding boxes.

Inherited from : py: class:BatchWiseImageTransform

apply_to(mask)

Apply trafo to the mask (either considered as batch of mask or single mask).

apply_to_batch(score_masks)

Bloat the score_masks to a mask of non-max-suppressed bounding boxes.

Inherited from : py: class:ImageTransform

apply_to(mask)

Apply trafo to the mask (either considered as batch of mask or single mask).

Inherited from : py: class:Transform

apply_to(mask)

Apply trafo to the mask (either considered as batch of mask or single mask).

Special Methods:

__init__(bbox_size[, iou_threshold, batch_wise])

Init.

Inherited from : py: class:BatchWiseImageTransform

__init__(bbox_size[, iou_threshold, batch_wise])

Init.

Inherited from : py: class:ImageTransform

__call__(img)

Application of transformation.

Inherited from : py: class:Transform

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

__copy__()

Return a shallow copy of self using settings.

__add__(other)

Return a flat composition of self with other.

__radd__(other)

Return a flat composition of other and self.

__call__(img)

Application of transformation.


Parameters
__init__(bbox_size, iou_threshold=0.5, batch_wise=False)[source]

Init.

Parameters
apply_to_batch(score_masks)[source]

Bloat the score_masks to a mask of non-max-suppressed bounding boxes. Each pixel in score_masks should represent the score of a bounding box of fixed size anchored at this pixel. The box size is derived from bbox_size. score_masks should be a mask of size (..., height, width). For non-max-suppression of the bounding boxes, torchvision.ops.nms() is used.

Returns

a mask of the same size as mask with each anchor in mask bloated to a bounding box filled with the score value; for overlapping boxes, the higher scored one is up front

Parameters

score_masks (Tensor) –

Return type

Tensor

batch_wise: bool

Whether to assume a batch of masks is given (True) or a single mask (False).

property bbox_size: Tuple[int, int]

The constant size to be assumed for all bounding boxes in pixels. Give as (height, width).

bloater: BatchBoxBloat

The bloating operation used to create a mask with bounding boxes from anchors and scores.

iou_threshold: float

The threshold for the intersection over union between two bounding boxes above which the lower-scored box is pruned. See also torchvision.ops.nms().

property settings: Dict[str, Any]

Settings to reproduce the instance.