code stringlengths 17 6.64M |
|---|
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... |
class CARAFENaiveFunction(Function):
@staticmethod
def symbolic(g, features, masks, kernel_size, group_size, scale_factor):
return g.op('mmcv::MMCVCARAFENaive', features, masks, kernel_size_i=kernel_size, group_size_i=group_size, scale_factor_f=scale_factor)
@staticmethod
def forward(ctx, fe... |
class CARAFENaive(Module):
def __init__(self, kernel_size, group_size, scale_factor):
super(CARAFENaive, self).__init__()
assert (isinstance(kernel_size, int) and isinstance(group_size, int) and isinstance(scale_factor, int))
self.kernel_size = kernel_size
self.group_size = group_... |
class CARAFEFunction(Function):
@staticmethod
def symbolic(g, features, masks, kernel_size, group_size, scale_factor):
return g.op('mmcv::MMCVCARAFE', features, masks, kernel_size_i=kernel_size, group_size_i=group_size, scale_factor_f=scale_factor)
@staticmethod
def forward(ctx, features, ma... |
class CARAFE(Module):
' CARAFE: Content-Aware ReAssembly of FEatures\n\n Please refer to `CARAFE: Content-Aware ReAssembly of FEatures\n <https://arxiv.org/abs/1905.02188>`_ for more details.\n\n Args:\n kernel_size (int): reassemble kernel size\n group_size (int): reassemble group size\n ... |
@UPSAMPLE_LAYERS.register_module(name='carafe')
class CARAFEPack(nn.Module):
'A unified package of CARAFE upsampler that contains: 1) channel\n compressor 2) content encoder 3) CARAFE op.\n\n Official implementation of ICCV 2019 paper\n `CARAFE: Content-Aware ReAssembly of FEatures\n <https://arxiv.or... |
def contour_expand(kernel_mask, internal_kernel_label, min_kernel_area, kernel_num):
'Expand kernel contours so that foreground pixels are assigned into\n instances.\n\n Args:\n kernel_mask (np.array or torch.Tensor): The instance kernel mask with\n size hxw.\n internal_kernel_label... |
class TopPoolFunction(Function):
@staticmethod
def symbolic(g, input):
output = g.op('mmcv::MMCVCornerPool', input, mode_i=int(_mode_dict['top']))
return output
@staticmethod
def forward(ctx, input):
output = ext_module.top_pool_forward(input)
ctx.save_for_backward(in... |
class BottomPoolFunction(Function):
@staticmethod
def symbolic(g, input):
output = g.op('mmcv::MMCVCornerPool', input, mode_i=int(_mode_dict['bottom']))
return output
@staticmethod
def forward(ctx, input):
output = ext_module.bottom_pool_forward(input)
ctx.save_for_ba... |
class LeftPoolFunction(Function):
@staticmethod
def symbolic(g, input):
output = g.op('mmcv::MMCVCornerPool', input, mode_i=int(_mode_dict['left']))
return output
@staticmethod
def forward(ctx, input):
output = ext_module.left_pool_forward(input)
ctx.save_for_backward... |
class RightPoolFunction(Function):
@staticmethod
def symbolic(g, input):
output = g.op('mmcv::MMCVCornerPool', input, mode_i=int(_mode_dict['right']))
return output
@staticmethod
def forward(ctx, input):
output = ext_module.right_pool_forward(input)
ctx.save_for_backw... |
class CornerPool(nn.Module):
"Corner Pooling.\n\n Corner Pooling is a new type of pooling layer that helps a\n convolutional network better localize corners of bounding boxes.\n\n Please refer to `CornerNet: Detecting Objects as Paired Keypoints\n <https://arxiv.org/abs/1808.01244>`_ for more details.... |
class CorrelationFunction(Function):
@staticmethod
def forward(ctx, input1, input2, kernel_size=1, max_displacement=1, stride=1, padding=1, dilation=1, dilation_patch=1):
ctx.save_for_backward(input1, input2)
(kH, kW) = ctx.kernel_size = _pair(kernel_size)
patch_size = ((max_displacem... |
class Correlation(nn.Module):
"Correlation operator\n\n This correlation operator works for optical flow correlation computation.\n\n There are two batched tensors with shape :math:`(N, C, H, W)`,\n and the correlation output's shape is :math:`(N, max\\_displacement \\times\n 2 + 1, max\\_displacement... |
class DeformRoIPoolFunction(Function):
@staticmethod
def symbolic(g, input, rois, offset, output_size, spatial_scale, sampling_ratio, gamma):
return g.op('mmcv::MMCVDeformRoIPool', input, rois, offset, pooled_height_i=output_size[0], pooled_width_i=output_size[1], spatial_scale_f=spatial_scale, sampl... |
class DeformRoIPool(nn.Module):
def __init__(self, output_size, spatial_scale=1.0, sampling_ratio=0, gamma=0.1):
super(DeformRoIPool, self).__init__()
self.output_size = _pair(output_size)
self.spatial_scale = float(spatial_scale)
self.sampling_ratio = int(sampling_ratio)
... |
class DeformRoIPoolPack(DeformRoIPool):
def __init__(self, output_size, output_channels, deform_fc_channels=1024, spatial_scale=1.0, sampling_ratio=0, gamma=0.1):
super(DeformRoIPoolPack, self).__init__(output_size, spatial_scale, sampling_ratio, gamma)
self.output_channels = output_channels
... |
class ModulatedDeformRoIPoolPack(DeformRoIPool):
def __init__(self, output_size, output_channels, deform_fc_channels=1024, spatial_scale=1.0, sampling_ratio=0, gamma=0.1):
super(ModulatedDeformRoIPoolPack, self).__init__(output_size, spatial_scale, sampling_ratio, gamma)
self.output_channels = ou... |
class Conv2d_deprecated(Conv2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn('Importing Conv2d wrapper from "mmcv.ops" will be deprecated in the future. Please import them from "mmcv.cnn" instead', DeprecationWarning)
|
class ConvTranspose2d_deprecated(ConvTranspose2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn('Importing ConvTranspose2d wrapper from "mmcv.ops" will be deprecated in the future. Please import them from "mmcv.cnn" instead', DeprecationWarning)
|
class MaxPool2d_deprecated(MaxPool2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn('Importing MaxPool2d wrapper from "mmcv.ops" will be deprecated in the future. Please import them from "mmcv.cnn" instead', DeprecationWarning)
|
class Linear_deprecated(Linear):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn('Importing Linear wrapper from "mmcv.ops" will be deprecated in the future. Please import them from "mmcv.cnn" instead', DeprecationWarning)
|
class SigmoidFocalLossFunction(Function):
@staticmethod
def symbolic(g, input, target, gamma, alpha, weight, reduction):
return g.op('mmcv::MMCVSigmoidFocalLoss', input, target, gamma_f=gamma, alpha_f=alpha, weight_f=weight, reduction_s=reduction)
@staticmethod
def forward(ctx, input, target... |
class SigmoidFocalLoss(nn.Module):
def __init__(self, gamma, alpha, weight=None, reduction='mean'):
super(SigmoidFocalLoss, self).__init__()
self.gamma = gamma
self.alpha = alpha
self.register_buffer('weight', weight)
self.reduction = reduction
def forward(self, input... |
class SoftmaxFocalLossFunction(Function):
@staticmethod
def symbolic(g, input, target, gamma, alpha, weight, reduction):
return g.op('mmcv::MMCVSoftmaxFocalLoss', input, target, gamma_f=gamma, alpha_f=alpha, weight_f=weight, reduction_s=reduction)
@staticmethod
def forward(ctx, input, target... |
class SoftmaxFocalLoss(nn.Module):
def __init__(self, gamma, alpha, weight=None, reduction='mean'):
super(SoftmaxFocalLoss, self).__init__()
self.gamma = gamma
self.alpha = alpha
self.register_buffer('weight', weight)
self.reduction = reduction
def forward(self, input... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.