np.random.seed(42)Utilities
validate_boxes
def validate_boxes(
coords, image_sz, feature_sz, clip:bool=True, min_visibility:float=0.25
):Validate calculated anchor box coords. :param coords: anchor box coordinates :param image_sz: tuple of (width, height) of an image :param feature_sz: tuple of (width, height) of a channel :param clip: whether to apply np.clip :param min_visibility: minimum visibility dictates the condition for a box to be considered valid. The value corresponds to the ratio of expected area to the calculated area after clipping to image dimensions. :return: anchor box coordinates in [pascal_voc] format
get_edges
def get_edges(
image_sz:tuple, feature_sz:tuple, op:str='noop'
):Generate offsetted top (x_min, y_min) or bottom edges (x_max, y_max) coordinates of a given feature size based on op. if op is noop, gets the top edges. if op is add, gets the bottom edges. :param op: operation for calculating edges, either ‘add’ ‘sub’ ‘noop’ :param image_sz: tuple of (W, H) of an image :param feature_sz: tuple of (W, H) of a channel :return: offsetted edges of each feature
Generate (x_min, y_min) corners.
as_tuple
def as_tuple(
x, # Item that needs to be converted to a tuple.
):Get x as a tuple (x, x) if not already a tuple.
as_tuple(2)(2, 2)
reassign_label
def reassign_label(
gt_bx:BaseBx, label:NoneType=None
):Update the label of the bounding box.
Args: gt_bx (BaseBx): A pybx bounding box of type BaseBx. label (list, optional): New label as a list of single item. Defaults to None.
Returns: type: description