code
stringlengths
17
6.64M
@INITIALIZERS.register_module(name='Uniform') class UniformInit(BaseInit): 'Initialize module parameters with values drawn from the uniform\n distribution :math:`\\mathcal{U}(a, b)`.\n\n Args:\n a (int | float): the lower bound of the uniform distribution.\n Defaults to 0.\n b (int ...
@INITIALIZERS.register_module(name='Kaiming') class KaimingInit(BaseInit): "Initialize module parameters with the values according to the method\n described in `Delving deep into rectifiers: Surpassing human-level\n performance on ImageNet classification - He, K. et al. (2015).\n <https://www.cv-foundati...
@INITIALIZERS.register_module(name='Caffe2Xavier') class Caffe2XavierInit(KaimingInit): def __init__(self, **kwargs): super().__init__(a=1, mode='fan_in', nonlinearity='leaky_relu', distribution='uniform', **kwargs) def __call__(self, module): super().__call__(module)
@INITIALIZERS.register_module(name='Pretrained') class PretrainedInit(object): "Initialize module by loading a pretrained model.\n\n Args:\n checkpoint (str): the checkpoint file of the pretrained model should\n be load.\n prefix (str, optional): the prefix of a sub-module in the pretr...
def _initialize(module, cfg, wholemodule=False): func = build_from_cfg(cfg, INITIALIZERS) func.wholemodule = wholemodule func(module)
def _initialize_override(module, override, cfg): if (not isinstance(override, (dict, list))): raise TypeError(f'override must be a dict or a list of dict, but got {type(override)}') override = ([override] if isinstance(override, dict) else override) for override_ in override: ...
def initialize(module, init_cfg): 'Initialize a module.\n\n Args:\n module (``torch.nn.Module``): the module will be initialized.\n init_cfg (dict | list[dict]): initialization configuration dict to\n define initializer. OpenMMLab has implemented 6 initializers\n including `...
def _no_grad_trunc_normal_(tensor: Tensor, mean: float, std: float, a: float, b: float) -> Tensor: def norm_cdf(x): return ((1.0 + math.erf((x / math.sqrt(2.0)))) / 2.0) if ((mean < (a - (2 * std))) or (mean > (b + (2 * std)))): warnings.warn('mean is more than 2 std from [a, b] in nn.init.tr...
def trunc_normal_(tensor: Tensor, mean: float=0.0, std: float=1.0, a: float=(- 2.0), b: float=2.0) -> Tensor: 'Fills the input Tensor with values drawn from a truncated\n normal distribution. The values are effectively drawn from the\n normal distribution :math:`\\mathcal{N}(\\text{mean}, \\text{std}^2)`\n ...
def conv3x3(in_planes, out_planes, dilation=1): '3x3 convolution with padding.' return nn.Conv2d(in_planes, out_planes, kernel_size=3, padding=dilation, dilation=dilation)
def make_vgg_layer(inplanes, planes, num_blocks, dilation=1, with_bn=False, ceil_mode=False): layers = [] for _ in range(num_blocks): layers.append(conv3x3(inplanes, planes, dilation)) if with_bn: layers.append(nn.BatchNorm2d(planes)) layers.append(nn.ReLU(inplace=True)) ...
class VGG(nn.Module): 'VGG backbone.\n\n Args:\n depth (int): Depth of vgg, from {11, 13, 16, 19}.\n with_bn (bool): Use BatchNorm or not.\n num_classes (int): number of classes for classification.\n num_stages (int): VGG stages, normally 5.\n dilations (Sequence[int]): Dilat...
def single_gpu_test(model, data_loader): 'Test model with a single gpu.\n\n This method tests model with a single gpu and displays test progress bar.\n\n Args:\n model (nn.Module): Model to be tested.\n data_loader (nn.Dataloader): Pytorch data loader.\n\n Returns:\n list: The predic...
def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): 'Test model with multiple gpus.\n\n This method tests model with multiple gpus and collects the results\n under two different modes: gpu and cpu modes. By setting\n ``gpu_collect=True``, it encodes results to gpu tensors and use gpu\...
def collect_results_cpu(result_part, size, tmpdir=None): 'Collect results under cpu mode.\n\n On cpu mode, this function will save the results on different gpus to\n ``tmpdir`` and collect them by the rank 0 worker.\n\n Args:\n result_part (list): Result list containing result parts\n t...
def collect_results_gpu(result_part, size): 'Collect results under gpu mode.\n\n On gpu mode, this function will encode results to gpu tensors and use gpu\n communication for results collection.\n\n Args:\n result_part (list): Result list containing result parts\n to be collected.\n ...
class BaseStorageBackend(metaclass=ABCMeta): 'Abstract class of storage backends.\n\n All backends need to implement two apis: ``get()`` and ``get_text()``.\n ``get()`` reads the file as a byte stream and ``get_text()`` reads the file\n as texts.\n ' _allow_symlink = False @property def n...
class CephBackend(BaseStorageBackend): "Ceph storage backend (for internal use).\n\n Args:\n path_mapping (dict|None): path mapping dict from local path to Petrel\n path. When ``path_mapping={'src': 'dst'}``, ``src`` in ``filepath``\n will be replaced by ``dst``. Default: None.\n\n...
class PetrelBackend(BaseStorageBackend): "Petrel storage backend (for internal use).\n\n PetrelBackend supports reading and writing data to multiple clusters.\n If the file path contains the cluster name, PetrelBackend will read data\n from specified cluster or write data to it. Otherwise, PetrelBackend ...
class MemcachedBackend(BaseStorageBackend): 'Memcached storage backend.\n\n Attributes:\n server_list_cfg (str): Config file for memcached server list.\n client_cfg (str): Config file for memcached client.\n sys_path (str | None): Additional path to be appended to `sys.path`.\n ...
class LmdbBackend(BaseStorageBackend): 'Lmdb storage backend.\n\n Args:\n db_path (str): Lmdb database path.\n readonly (bool, optional): Lmdb environment parameter. If True,\n disallow any write operations. Default: True.\n lock (bool, optional): Lmdb environment parameter. If ...
class HardDiskBackend(BaseStorageBackend): 'Raw hard disks storage backend.' _allow_symlink = True def get(self, filepath: Union[(str, Path)]) -> bytes: "Read data from a given ``filepath`` with 'rb' mode.\n\n Args:\n filepath (str or Path): Path to read data.\n\n Returns...
class HTTPBackend(BaseStorageBackend): 'HTTP and HTTPS storage bachend.' def get(self, filepath): value_buf = urlopen(filepath).read() return value_buf def get_text(self, filepath, encoding='utf-8'): value_buf = urlopen(filepath).read() return value_buf.decode(encoding) ...
class FileClient(): 'A general file client to access files in different backends.\n\n The client loads a file or text in a specified backend from its path\n and returns it as a binary or text file. There are two ways to choose a\n backend, the name of backend and the prefix of path. Although both of them...
class BaseFileHandler(metaclass=ABCMeta): str_like = True @abstractmethod def load_from_fileobj(self, file, **kwargs): pass @abstractmethod def dump_to_fileobj(self, obj, file, **kwargs): pass @abstractmethod def dump_to_str(self, obj, **kwargs): pass def lo...
def set_default(obj): 'Set default json values for non-serializable values.\n\n It helps convert ``set``, ``range`` and ``np.ndarray`` data types to list.\n It also converts ``np.generic`` (including ``np.int32``, ``np.float32``,\n etc.) into plain numbers of plain python built-in types.\n ' if is...
class JsonHandler(BaseFileHandler): def load_from_fileobj(self, file): return json.load(file) def dump_to_fileobj(self, obj, file, **kwargs): kwargs.setdefault('default', set_default) json.dump(obj, file, **kwargs) def dump_to_str(self, obj, **kwargs): kwargs.setdefault(...
class PickleHandler(BaseFileHandler): str_like = False def load_from_fileobj(self, file, **kwargs): return pickle.load(file, **kwargs) def load_from_path(self, filepath, **kwargs): return super(PickleHandler, self).load_from_path(filepath, mode='rb', **kwargs) def dump_to_str(self, ...
class YamlHandler(BaseFileHandler): def load_from_fileobj(self, file, **kwargs): kwargs.setdefault('Loader', Loader) return yaml.load(file, **kwargs) def dump_to_fileobj(self, obj, file, **kwargs): kwargs.setdefault('Dumper', Dumper) yaml.dump(obj, file, **kwargs) def du...
def load(file, file_format=None, file_client_args=None, **kwargs): 'Load data from json/yaml/pickle files.\n\n This method provides a unified api for loading data from serialized files.\n\n Note:\n In v1.3.16 and later, ``load`` supports loading data from serialized\n files those can be storag...
def dump(obj, file=None, file_format=None, file_client_args=None, **kwargs): "Dump data to json/yaml/pickle strings or files.\n\n This method provides a unified api for dumping data as strings or to files,\n and also supports custom arguments for each file format.\n\n Note:\n In v1.3.16 and later,...
def _register_handler(handler, file_formats): 'Register a handler for some file extensions.\n\n Args:\n handler (:obj:`BaseFileHandler`): Handler to be registered.\n file_formats (str or list[str]): File formats to be handled by this\n handler.\n ' if (not isinstance(handler, Ba...
def register_handler(file_formats, **kwargs): def wrap(cls): _register_handler(cls(**kwargs), file_formats) return cls return wrap
def list_from_file(filename, prefix='', offset=0, max_num=0, encoding='utf-8', file_client_args=None): "Load a text file and parse the content as a list of strings.\n\n Note:\n In v1.3.16 and later, ``list_from_file`` supports loading a text file\n which can be storaged in different backends and ...
def dict_from_file(filename, key_type=str, encoding='utf-8', file_client_args=None): "Load a text file and parse the content as a dict.\n\n Each line of the text file will be two or more columns split by\n whitespaces or tabs. The first column will be parsed as dict keys, and\n the following columns will...
def imconvert(img, src, dst): "Convert an image from the src colorspace to dst colorspace.\n\n Args:\n img (ndarray): The input image.\n src (str): The source colorspace, e.g., 'rgb', 'hsv'.\n dst (str): The destination colorspace, e.g., 'rgb', 'hsv'.\n\n Returns:\n ndarray: The ...
def bgr2gray(img, keepdim=False): 'Convert a BGR image to grayscale image.\n\n Args:\n img (ndarray): The input image.\n keepdim (bool): If False (by default), then return the grayscale image\n with 2 dims, otherwise 3 dims.\n\n Returns:\n ndarray: The converted grayscale ima...
def rgb2gray(img, keepdim=False): 'Convert a RGB image to grayscale image.\n\n Args:\n img (ndarray): The input image.\n keepdim (bool): If False (by default), then return the grayscale image\n with 2 dims, otherwise 3 dims.\n\n Returns:\n ndarray: The converted grayscale ima...
def gray2bgr(img): 'Convert a grayscale image to BGR image.\n\n Args:\n img (ndarray): The input image.\n\n Returns:\n ndarray: The converted BGR image.\n ' img = (img[(..., None)] if (img.ndim == 2) else img) out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) return out_img
def gray2rgb(img): 'Convert a grayscale image to RGB image.\n\n Args:\n img (ndarray): The input image.\n\n Returns:\n ndarray: The converted RGB image.\n ' img = (img[(..., None)] if (img.ndim == 2) else img) out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB) return out_img
def _convert_input_type_range(img): 'Convert the type and range of the input image.\n\n It converts the input image to np.float32 type and range of [0, 1].\n It is mainly used for pre-processing the input image in colorspace\n conversion functions such as rgb2ycbcr and ycbcr2rgb.\n\n Args:\n im...
def _convert_output_type_range(img, dst_type): 'Convert the type and range of the image according to dst_type.\n\n It converts the image to desired type and range. If `dst_type` is np.uint8,\n images will be converted to np.uint8 type with range [0, 255]. If\n `dst_type` is np.float32, it converts the im...
def rgb2ycbcr(img, y_only=False): "Convert a RGB image to YCbCr image.\n\n This function produces the same results as Matlab's `rgb2ycbcr` function.\n It implements the ITU-R BT.601 conversion for standard-definition\n television. See more details in\n https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_...
def bgr2ycbcr(img, y_only=False): 'Convert a BGR image to YCbCr image.\n\n The bgr version of rgb2ycbcr.\n It implements the ITU-R BT.601 conversion for standard-definition\n television. See more details in\n https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion.\n\n It differs from a similar...
def ycbcr2rgb(img): "Convert a YCbCr image to RGB image.\n\n This function produces the same results as Matlab's ycbcr2rgb function.\n It implements the ITU-R BT.601 conversion for standard-definition\n television. See more details in\n https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion.\n\n ...
def ycbcr2bgr(img): 'Convert a YCbCr image to BGR image.\n\n The bgr version of ycbcr2rgb.\n It implements the ITU-R BT.601 conversion for standard-definition\n television. See more details in\n https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion.\n\n It differs from a similar function in c...
def convert_color_factory(src, dst): code = getattr(cv2, f'COLOR_{src.upper()}2{dst.upper()}') def convert_color(img): out_img = cv2.cvtColor(img, code) return out_img convert_color.__doc__ = f'''Convert a {src.upper()} image to {dst.upper()} image. Args: img (ndarray...
def tensor2imgs(tensor, mean=None, std=None, to_rgb=True): 'Convert tensor to 3-channel images or 1-channel gray images.\n\n Args:\n tensor (torch.Tensor): Tensor that contains multiple images, shape (\n N, C, H, W). :math:`C` can be either 3 or 1.\n mean (tuple[float], optional): Mean...
def is_custom_op_loaded(): (bright_style, reset_style) = ('\x1b[1m', '\x1b[0m') (red_text, blue_text) = ('\x1b[31m', '\x1b[34m') white_background = '\x1b[107m' msg = ((white_background + bright_style) + red_text) msg += 'DeprecationWarning: This function will be deprecated in future. ' msg += ...
def _parse_arg(value, desc): if (desc == 'none'): return value if ((desc == 'v') or (not _is_value(value))): return value if value.node().mustBeNone(): return None if (value.node().kind() == 'onnx::Constant'): tval = value.node()['value'] if (desc == 'i'): ...
def _maybe_get_const(value, desc): if (_is_value(value) and (value.node().kind() == 'onnx::Constant')): return _parse_arg(value, desc) return value
def _maybe_get_scalar(value): value_t = _maybe_get_const(value, 't') if (isinstance(value_t, torch.Tensor) and (value_t.shape == ())): return value_t return value
def _get_const(value, desc, arg_name): if (_is_value(value) and (value.node().kind() not in ('onnx::Constant', 'prim::Constant'))): raise RuntimeError('ONNX symbolic expected a constant value of the {} argument, got `{}`'.format(arg_name, value)) return _parse_arg(value, desc)
def _unpack_list(list_value): list_node = list_value.node() assert (list_node.kind() == 'prim::ListConstruct') return list(list_node.inputs())
def _is_packed_list(list_value): return (_is_value(list_value) and (list_value.node().kind() == 'prim::ListConstruct'))
def parse_args(*arg_descriptors): def decorator(fn): fn._arg_descriptors = arg_descriptors def wrapper(g, *args): assert (len(arg_descriptors) >= len(args)) args = [_parse_arg(arg, arg_desc) for (arg, arg_desc) in zip(args, arg_descriptors)] return fn(g, *args...
def _scalar(x): 'Convert a scalar tensor into a Python value.' assert (x.numel() == 1) return x.item()
def _if_scalar_type_as(g, self, tensor): 'Convert self into the same type of tensor, as necessary.' if isinstance(self, torch._C.Value): return self scalar_type = tensor.type().scalarType() if scalar_type: ty = scalar_type.lower() return getattr(self, ty)() return self
def _is_none(x): return x.node().mustBeNone()
def _is_value(x): return isinstance(x, torch._C.Value)
def _is_tensor_list(x): return x.type().isSubtypeOf(ListType.ofTensors())
def _unimplemented(op, msg): warnings.warn((((('ONNX export failed on ' + op) + ' because ') + msg) + ' not supported'))
def _try_get_scalar_type(*args): for arg in args: try: return arg.type().scalarType() except RuntimeError: pass return None
def _topk_helper(g, input, k, dim, largest=True, sorted=False, out=None): if (out is not None): _unimplemented('TopK', 'Out parameter is not supported') if (not _is_value(k)): k = g.op('Constant', value_t=torch.tensor([k], dtype=torch.int64)) else: k = g.op('Reshape', k, g.op('Cons...
def _slice_helper(g, input, axes, starts, ends, steps=None, dynamic_slice=False): from torch.onnx.symbolic_opset10 import _slice return _slice(g, input, axes, starts, ends, steps, dynamic_slice)
def _unsqueeze_helper(g, input, dim): from torch.onnx.symbolic_opset9 import unsqueeze return unsqueeze(g, input, dim)
def _interpolate_size_to_scales(g, input, output_size, dim): output_size = _maybe_get_const(output_size, 'is') if _is_value(output_size): offset = 2 offsets = g.op('Constant', value_t=torch.ones(offset, dtype=torch.float32)) dividend = g.op('Cast', output_size, to_i=cast_pytorch_to_onn...
def _interpolate_get_scales_if_available(g, scales): if (len(scales) == 0): return None scale_desc = ('fs' if ((scales[0].type().kind() == 'ListType') or ((scales[0].type().kind() == 'TensorType') and (sum(scales[0].type().sizes()) > 1))) else 'f') available_scales = ((_maybe_get_const(scales[0], ...
def _get_interpolate_attributes(g, mode, args): if (mode == 'nearest'): align_corners = None scales = args[0:] else: align_corners = args[0] scales = args[1:] scales = _interpolate_get_scales_if_available(g, scales) return (scales, align_corners)
def _interpolate_get_scales(g, scale_factor, dim): offsets = g.op('Constant', value_t=torch.ones(2, dtype=torch.float32)) if isinstance(scale_factor.type(), torch._C.ListType): return g.op('Concat', offsets, scale_factor, axis_i=0) else: scale_factor = _unsqueeze_helper(g, scale_factor, 0)...
def _size_helper(g, self, dim): full_shape = g.op('Shape', self) from torch.onnx.symbolic_opset9 import select return select(g, full_shape, g.op('Constant', value_t=torch.tensor([0])), dim)
def _avgpool_helper(tuple_fn, padding, kernel_size, stride, divisor_override, name): if (divisor_override and (divisor_override.node().kind() != 'prim::Constant')): return _unimplemented(name, 'divisor_override') if (not stride): stride = kernel_size padding = tuple(tuple_fn(padding)) ...
def _interpolate(name, dim, interpolate_mode): def symbolic_fn(g, input, output_size, *args): (scales, align_corners) = sym_help._get_interpolate_attributes(g, interpolate_mode, args) align_corners = sym_help._maybe_get_scalar(align_corners) transformation_mode = ('asymmetric' if (interpo...
@parse_args('v', 'v', 'i', 'i', 'i', 'none') def topk(g, self, k, dim, largest, sorted, out=None): return sym_help._topk_helper(g, self, k, dim, largest=largest, sorted=sorted, out=out)
def masked_select(g, self, mask): from torch.onnx.symbolic_opset9 import expand_as, nonzero index = nonzero(g, expand_as(g, mask, self)) return g.op('GatherND', self, index)
def _prepare_onnx_paddings(g, dim, pad): pad_len = torch.onnx.symbolic_opset9.size(g, pad, g.op('Constant', value_t=torch.tensor([0]))) extension = g.op('Sub', g.op('Mul', g.op('Constant', value_t=torch.tensor(dim, dtype=torch.int64)), g.op('Constant', value_t=torch.tensor(2, dtype=torch.int64))), pad_len) ...
def constant_pad_nd(g, input, padding, value=None): mode = 'constant' value = sym_help._maybe_get_scalar(value) value = sym_help._if_scalar_type_as(g, value, input) pad = _prepare_onnx_paddings(g, input.type().dim(), padding) return g.op('Pad', input, pad, value, mode_s=mode)
def reflection_pad(g, input, padding): mode = 'reflect' paddings = _prepare_onnx_paddings(g, input.type().dim(), padding) return g.op('Pad', input, paddings, mode_s=mode)
def _avg_pool(name, tuple_fn): @parse_args('v', 'is', 'is', 'is', 'i', 'i', 'none') def symbolic_fn(g, input, kernel_size, stride, padding, ceil_mode, count_include_pad, divisor_override=None): padding = sym_help._avgpool_helper(tuple_fn, padding, kernel_size, stride, divisor_override, name) ...
def _get_im2col_indices_along_dim(g, input_d, kernel_size_d, dilation_d, padding_d, stride_d): blocks_d = g.op('Add', input_d, g.op('Constant', value_t=torch.tensor((padding_d * 2)))) blocks_d = g.op('Sub', blocks_d, g.op('Constant', value_t=torch.tensor((dilation_d * (kernel_size_d - 1))))) blocks_d_indi...
def _get_im2col_padded_input(g, input, padding_h, padding_w): pad = g.op('Constant', value_t=torch.LongTensor(([0, 0, padding_h, padding_w] * 2))) return g.op('Pad', input, pad)
def _get_im2col_output_shape(g, input, kernel_h, kernel_w): batch_dim = size(g, input, g.op('Constant', value_t=torch.tensor(0))) channel_dim = size(g, input, g.op('Constant', value_t=torch.tensor(1))) channel_unfolded = g.op('Mul', channel_dim, g.op('Constant', value_t=torch.tensor((kernel_h * kernel_w))...
def size(g, self, dim=None): if (dim is None): return g.op('Shape', self) return sym_help._size_helper(g, self, dim)
@parse_args('v', 'is', 'is', 'is', 'is') def im2col(g, input, kernel_size, dilation, padding, stride): input_h = size(g, input, g.op('Constant', value_t=torch.tensor(2))) input_w = size(g, input, g.op('Constant', value_t=torch.tensor(3))) (stride_h, stride_w) = (stride[0], stride[1]) (padding_h, paddi...
@parse_args('v', 'i') def one_hot(g, self, num_classes): values = g.op('Constant', value_t=torch.LongTensor([0, 1])) depth = g.op('Constant', value_t=torch.LongTensor([num_classes])) return g.op('OneHot', self, depth, values, axis_i=(- 1))
@parse_args('v', 'i', 'none') def softmax(g, input, dim, dtype=None): input_dim = input.type().dim() if input_dim: if (dim < 0): dim = (input_dim + dim) if (input_dim == (dim + 1)): softmax = g.op('Softmax', input, axis_i=dim) if (dtype and (dtype.node().kin...
def _adaptive_pool(name, type, tuple_fn, fn=None): @parse_args('v', 'is') def symbolic_fn(g, input, output_size): if ((output_size == ([1] * len(output_size))) and (type == 'AveragePool')): return g.op('GlobalAveragePool', input) if (not input.isCompleteTensor()): if (...
def new_full(g, self, size, fill_value, dtype, layout, device, pin_memory=False): from torch.onnx.symbolic_opset9 import full if ((dtype is None) and self.isCompleteTensor()): dtype = self.type().scalarType() dtype = sym_help.scalar_type_to_onnx.index(sym_help.cast_pytorch_to_onnx[dtype]) ...
@parse_args('v', 'v', 'i', 'i', 'i') def grid_sampler(g, input, grid, interpolation_mode, padding_mode, align_corners=False): return g.op('mmcv::grid_sampler', input, grid, interpolation_mode_i=interpolation_mode, padding_mode_i=padding_mode, align_corners_i=align_corners)
@parse_args('v', 'i') def cummax(g, input, dim): return g.op('mmcv::cummax', input, dim_i=dim, outputs=2)
@parse_args('v', 'i') def cummin(g, input, dim): return g.op('mmcv::cummin', input, dim_i=dim, outputs=2)
@parse_args('v', 'v', 'is') def roll(g, input, shifts, dims): from packaging import version from torch.onnx.symbolic_opset9 import squeeze input_shape = g.op('Shape', input) need_flatten = (len(dims) == 0) if need_flatten: resize_shape = input_shape input = g.op('Reshape', input, g...
def register_extra_symbolics(opset=11): (bright_style, reset_style) = ('\x1b[1m', '\x1b[0m') (red_text, blue_text) = ('\x1b[31m', '\x1b[34m') white_background = '\x1b[107m' msg = ((white_background + bright_style) + red_text) msg += 'DeprecationWarning: This function will be deprecated in future. ...
class ActiveRotatedFilterFunction(Function): 'Encoding the orientation information and generating orientation-\n sensitive features.\n\n The details are described in the paper `Align Deep Features for Oriented\n Object Detection <https://arxiv.org/abs/2008.09397>_`.\n ' @staticmethod def for...
class AssignScoreWithK(Function): 'Perform weighted sum to generate output features according to scores.\n Modified from `PAConv <https://github.com/CVMI-Lab/PAConv/tree/main/\n scene_seg/lib/paconv_lib/src/gpu>`_.\n\n This is a memory-efficient CUDA implementation of assign_scores operation,\n which ...
class BallQuery(Function): 'Find nearby points in spherical space.' @staticmethod def forward(ctx, min_radius: float, max_radius: float, sample_num: int, xyz: torch.Tensor, center_xyz: torch.Tensor) -> torch.Tensor: '\n Args:\n min_radius (float): minimum radius of the balls.\n ...
def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0): 'Calculate overlap between two set of bboxes.\n\n If ``aligned`` is ``False``, then calculate the ious between each bbox\n of bboxes1 and bboxes2, otherwise the ious between each aligned pair of\n bboxes1 and bboxes2.\n\n Args:\...
class BorderAlignFunction(Function): @staticmethod def symbolic(g, input, boxes, pool_size): return g.op('mmcv::MMCVBorderAlign', input, boxes, pool_size_i=pool_size) @staticmethod def forward(ctx, input, boxes, pool_size): ctx.pool_size = pool_size ctx.input_shape = input.si...
class BorderAlign(nn.Module): "Border align pooling layer.\n\n Applies border_align over the input feature based on predicted bboxes.\n The details were described in the paper\n `BorderDet: Border Feature for Dense Object Detection\n <https://arxiv.org/abs/2007.11056>`_.\n\n For each border line (e...
def box_iou_rotated(bboxes1, bboxes2, mode='iou', aligned=False, clockwise=True): 'Return intersection-over-union (Jaccard index) of boxes.\n\n Both sets of boxes are expected to be in\n (x_center, y_center, width, height, angle) format.\n\n If ``aligned`` is ``False``, then calculate the ious between ea...