brails.processors.garage_detector.lib.efficientdet.utils module

class brails.processors.garage_detector.lib.efficientdet.utils.Anchors(anchor_scale=4.0, pyramid_levels=None, **kwargs)

Bases: Module

adapted and modified from https://github.com/google/automl/blob/master/efficientdet/anchors.py by Zylo117

forward(image, dtype=torch.float32)

Generates multiscale anchor boxes.

Args:
image_size: integer number of input image size. The input image has the

same dimension for width and height. The image_size should be divided by the largest feature stride 2^max_level.

anchor_scale: float number representing the scale of size of the base

anchor to the feature stride 2^level.

anchor_configs: a dictionary with keys as the levels of anchors and

values as a list of anchor configuration.

Returns:
anchor_boxes: a numpy array with shape [N, 4], which stacks anchors on all

feature levels.

Raises:

ValueError: input size must be the multiple of largest feature stride.

class brails.processors.garage_detector.lib.efficientdet.utils.BBoxTransform(*args, **kwargs)

Bases: Module

forward(anchors, regression)

decode_box_outputs adapted from https://github.com/google/automl/blob/master/efficientdet/anchors.py

Args:

anchors: [batchsize, boxes, (y1, x1, y2, x2)] regression: [batchsize, boxes, (dy, dx, dh, dw)]

Returns:

class brails.processors.garage_detector.lib.efficientdet.utils.ClipBoxes

Bases: Module

forward(boxes, img)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.