utils

Utility functions for working with YOLOX models

source

multi_apply

 multi_apply (func:Callable[...,Any], *args:Any, **kwargs:Any)

*Applies the function func to each set of arguments in *args, possibly using keyword arguments **kwargs.

Based on OpenMMLab’s implementation in the mmdetection library:

Type Details
func Callable Function to apply.
args Any
kwargs Any
Returns Tuple
multi_apply(lambda a, b: (a*2, b/2), [1, 2, 3, 4], [5, 6, 7, 8])
([2, 4, 6, 8], [2.5, 3.0, 3.5, 4.0])

source

generate_output_grids

 generate_output_grids (height, width, strides=[8, 16, 32])

*Generate a tensor containing grid coordinates and strides for a given height and width.

Args: height (int): The height of the image. width (int): The width of the image.

Returns: torch.Tensor: A tensor containing grid coordinates and strides.*

generate_output_grids(32, 32)
tensor([[ 0,  0,  8],
        [ 1,  0,  8],
        [ 2,  0,  8],
        [ 3,  0,  8],
        [ 0,  1,  8],
        [ 1,  1,  8],
        [ 2,  1,  8],
        [ 3,  1,  8],
        [ 0,  2,  8],
        [ 1,  2,  8],
        [ 2,  2,  8],
        [ 3,  2,  8],
        [ 0,  3,  8],
        [ 1,  3,  8],
        [ 2,  3,  8],
        [ 3,  3,  8],
        [ 0,  0, 16],
        [ 1,  0, 16],
        [ 0,  1, 16],
        [ 1,  1, 16],
        [ 0,  0, 32]])