code
stringlengths
17
6.64M
@DATASETS.register_module() class XMLDataset(CustomDataset): 'XML dataset for detection.\n\n Args:\n min_size (int | float, optional): The minimum size of bounding\n boxes in the images. If the size of a bounding box is less than\n ``min_size``, it would be add to ignored field.\n ...
class ResBlock(BaseModule): "The basic residual block used in Darknet. Each ResBlock consists of two\n ConvModules and the input is added to the final output. Each ConvModule is\n composed of Conv, BN, and LeakyReLU. In YoloV3 paper, the first convLayer\n has half of the number of the filters as much as ...
@BACKBONES.register_module() class Darknet(BaseModule): "Darknet backbone.\n\n Args:\n depth (int): Depth of Darknet. Currently only support 53.\n out_indices (Sequence[int]): Output from which stages.\n frozen_stages (int): Stages to be frozen (stop grad and set eval mode).\n -...
class Bottleneck(_Bottleneck): 'Bottleneck for the ResNet backbone in `DetectoRS\n <https://arxiv.org/pdf/2006.02334.pdf>`_.\n\n This bottleneck allows the users to specify whether to use\n SAC (Switchable Atrous Convolution) and RFP (Recursive Feature Pyramid).\n\n Args:\n inplanes (int): The...
class ResLayer(Sequential): "ResLayer to build ResNet style backbone for RPF in detectoRS.\n\n The difference between this module and base class is that we pass\n ``rfp_inplanes`` to the first block.\n\n Args:\n block (nn.Module): block used to build ResLayer.\n inplanes (int): inplanes of ...
@BACKBONES.register_module() class DetectoRS_ResNet(ResNet): 'ResNet backbone for DetectoRS.\n\n Args:\n sac (dict, optional): Dictionary to construct SAC (Switchable Atrous\n Convolution). Default: None.\n stage_with_sac (list): Which stage to use sac. Default: (False, False,\n ...
class Bottleneck(_Bottleneck): expansion = 4 def __init__(self, inplanes, planes, groups=1, base_width=4, base_channels=64, **kwargs): 'Bottleneck block for ResNeXt.\n\n If style is "pytorch", the stride-two layer is the 3x3 conv layer, if\n it is "caffe", the stride-two layer is the fi...
@BACKBONES.register_module() class DetectoRS_ResNeXt(DetectoRS_ResNet): 'ResNeXt backbone for DetectoRS.\n\n Args:\n groups (int): The number of groups in ResNeXt.\n base_width (int): The base width of ResNeXt.\n ' arch_settings = {50: (Bottleneck, (3, 4, 6, 3)), 101: (Bottleneck, (3, 4, 2...
class HourglassModule(BaseModule): "Hourglass Module for HourglassNet backbone.\n\n Generate module recursively and use BasicBlock as the base unit.\n\n Args:\n depth (int): Depth of current HourglassModule.\n stage_channels (list[int]): Feature channels of sub-modules in current\n ...
@BACKBONES.register_module() class HourglassNet(BaseModule): 'HourglassNet backbone.\n\n Stacked Hourglass Networks for Human Pose Estimation.\n More details can be found in the `paper\n <https://arxiv.org/abs/1603.06937>`_ .\n\n Args:\n downsample_times (int): Downsample times in a HourglassMo...
class HRModule(BaseModule): 'High-Resolution Module for HRNet.\n\n In this module, every branch has 4 BasicBlocks/Bottlenecks. Fusion/Exchange\n is in this module.\n ' def __init__(self, num_branches, blocks, num_blocks, in_channels, num_channels, multiscale_output=True, with_cp=False, conv_cfg=None...
@BACKBONES.register_module() class HRNet(BaseModule): "HRNet backbone.\n\n `High-Resolution Representations for Labeling Pixels and Regions\n arXiv: <https://arxiv.org/abs/1904.04514>`_.\n\n Args:\n extra (dict): Detailed configuration for each stage of HRNet.\n There must be 4 stages, ...
@BACKBONES.register_module() class MobileNetV2(BaseModule): "MobileNetV2 backbone.\n\n Args:\n widen_factor (float): Width multiplier, multiply number of\n channels in each layer by this amount. Default: 1.0.\n out_indices (Sequence[int], optional): Output from which stages.\n ...
@BACKBONES.register_module() class RegNet(ResNet): 'RegNet backbone.\n\n More details can be found in `paper <https://arxiv.org/abs/2003.13678>`_ .\n\n Args:\n arch (dict): The parameter of RegNets.\n\n - w0 (int): initial width\n - wa (float): slope of width\n - wm (...
class Bottle2neck(_Bottleneck): expansion = 4 def __init__(self, inplanes, planes, scales=4, base_width=26, base_channels=64, stage_type='normal', **kwargs): 'Bottle2neck block for Res2Net.\n\n If style is "pytorch", the stride-two layer is the 3x3 conv layer, if\n it is "caffe", the st...
class Res2Layer(Sequential): "Res2Layer to build Res2Net style backbone.\n\n Args:\n block (nn.Module): block used to build ResLayer.\n inplanes (int): inplanes of block.\n planes (int): planes of block.\n num_blocks (int): number of blocks.\n stride (int): stride of the firs...
@BACKBONES.register_module() class Res2Net(ResNet): 'Res2Net backbone.\n\n Args:\n scales (int): Scales used in Res2Net. Default: 4\n base_width (int): Basic width of each scale. Default: 26\n depth (int): Depth of res2net, from {50, 101, 152}.\n in_channels (int): Number of input i...
class RSoftmax(nn.Module): 'Radix Softmax module in ``SplitAttentionConv2d``.\n\n Args:\n radix (int): Radix of input.\n groups (int): Groups of input.\n ' def __init__(self, radix, groups): super().__init__() self.radix = radix self.groups = groups def forwar...
class SplitAttentionConv2d(BaseModule): 'Split-Attention Conv2d in ResNeSt.\n\n Args:\n in_channels (int): Number of channels in the input feature map.\n channels (int): Number of intermediate channels.\n kernel_size (int | tuple[int]): Size of the convolution kernel.\n stride (int ...
class Bottleneck(_Bottleneck): 'Bottleneck block for ResNeSt.\n\n Args:\n inplane (int): Input planes of this block.\n planes (int): Middle planes of this block.\n groups (int): Groups of conv2.\n base_width (int): Base of width in terms of base channels. Default: 4.\n base_c...
@BACKBONES.register_module() class ResNeSt(ResNetV1d): 'ResNeSt backbone.\n\n Args:\n groups (int): Number of groups of Bottleneck. Default: 1\n base_width (int): Base width of Bottleneck. Default: 4\n radix (int): Radix of SplitAttentionConv2d. Default: 2\n reduction_factor (int): ...
class BasicBlock(BaseModule): expansion = 1 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, style='pytorch', with_cp=False, conv_cfg=None, norm_cfg=dict(type='BN'), dcn=None, plugins=None, init_cfg=None): super(BasicBlock, self).__init__(init_cfg) assert (dcn is No...
class Bottleneck(BaseModule): expansion = 4 def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, style='pytorch', with_cp=False, conv_cfg=None, norm_cfg=dict(type='BN'), dcn=None, plugins=None, init_cfg=None): 'Bottleneck block for ResNet.\n\n If style is "pytorch", the ...
@BACKBONES.register_module() class ResNet(BaseModule): 'ResNet backbone.\n\n Args:\n depth (int): Depth of resnet, from {18, 34, 50, 101, 152}.\n stem_channels (int | None): Number of stem channels. If not specified,\n it will be the same as `base_channels`. Default: None.\n bas...
@BACKBONES.register_module() class ResNetV1d(ResNet): 'ResNetV1d variant described in `Bag of Tricks\n <https://arxiv.org/pdf/1812.01187.pdf>`_.\n\n Compared with default ResNet(ResNetV1b), ResNetV1d replaces the 7x7 conv in\n the input stem with three 3x3 convs. And in the downsampling block, a 2x2\n ...
class Bottleneck(_Bottleneck): expansion = 4 def __init__(self, inplanes, planes, groups=1, base_width=4, base_channels=64, **kwargs): 'Bottleneck block for ResNeXt.\n\n If style is "pytorch", the stride-two layer is the 3x3 conv layer, if\n it is "caffe", the stride-two layer is the fi...
@BACKBONES.register_module() class ResNeXt(ResNet): 'ResNeXt backbone.\n\n Args:\n depth (int): Depth of resnet, from {18, 34, 50, 101, 152}.\n in_channels (int): Number of input image channels. Default: 3.\n num_stages (int): Resnet stages. Default: 4.\n groups (int): Group of resn...
@BACKBONES.register_module() class SSDVGG(VGG, BaseModule): 'VGG Backbone network for single-shot-detection.\n\n Args:\n depth (int): Depth of vgg, from {11, 13, 16, 19}.\n with_last_pool (bool): Whether to add a pooling layer at the last\n of the model\n ceil_mode (bool): When ...
class L2Norm(ssd_neck.L2Norm): def __init__(self, **kwargs): super(L2Norm, self).__init__(**kwargs) warnings.warn('DeprecationWarning: L2Norm in ssd_vgg.py is deprecated, please use L2Norm in mmdet/models/necks/ssd_neck.py instead')
class TridentConv(BaseModule): 'Trident Convolution Module.\n\n Args:\n in_channels (int): Number of channels in input.\n out_channels (int): Number of channels in output.\n kernel_size (int): Size of convolution kernel.\n stride (int, optional): Convolution stride. Default: 1.\n ...
class TridentBottleneck(Bottleneck): 'BottleBlock for TridentResNet.\n\n Args:\n trident_dilations (tuple[int, int, int]): Dilations of different\n trident branch.\n test_branch_idx (int): In inference, all 3 branches will be used\n if `test_branch_idx==-1`, otherwise only b...
def make_trident_res_layer(block, inplanes, planes, num_blocks, stride=1, trident_dilations=(1, 2, 3), style='pytorch', with_cp=False, conv_cfg=None, norm_cfg=dict(type='BN'), dcn=None, plugins=None, test_branch_idx=(- 1)): 'Build Trident Res Layers.' downsample = None if ((stride != 1) or (inplanes != (p...
@BACKBONES.register_module() class TridentResNet(ResNet): 'The stem layer, stage 1 and stage 2 in Trident ResNet are identical to\n ResNet, while in stage 3, Trident BottleBlock is utilized to replace the\n normal BottleBlock to yield trident output. Different branch shares the\n convolution weight but u...
def build_backbone(cfg): 'Build backbone.' return BACKBONES.build(cfg)
def build_neck(cfg): 'Build neck.' return NECKS.build(cfg)
def build_roi_extractor(cfg): 'Build roi extractor.' return ROI_EXTRACTORS.build(cfg)
def build_shared_head(cfg): 'Build shared head.' return SHARED_HEADS.build(cfg)
def build_head(cfg): 'Build head.' return HEADS.build(cfg)
def build_loss(cfg): 'Build loss.' return LOSSES.build(cfg)
def build_detector(cfg, train_cfg=None, test_cfg=None): 'Build detector.' if ((train_cfg is not None) or (test_cfg is not None)): warnings.warn('train_cfg and test_cfg is deprecated, please specify them in model', UserWarning) assert ((cfg.get('train_cfg') is None) or (train_cfg is None)), 'train_...
@HEADS.register_module() class AnchorFreeHead(BaseDenseHead, BBoxTestMixin): 'Anchor-free head (FCOS, Fovea, RepPoints, etc.).\n\n Args:\n num_classes (int): Number of categories excluding the background\n category.\n in_channels (int): Number of channels in the input feature map.\n ...
class BaseMaskHead(BaseModule, metaclass=ABCMeta): 'Base class for mask heads used in One-Stage Instance Segmentation.' def __init__(self, init_cfg): super(BaseMaskHead, self).__init__(init_cfg) @abstractmethod def loss(self, **kwargs): pass @abstractmethod def get_results(s...
@HEADS.register_module() class GARetinaHead(GuidedAnchorHead): 'Guided-Anchor-based RetinaNet head.' def __init__(self, num_classes, in_channels, stacked_convs=4, conv_cfg=None, norm_cfg=None, init_cfg=None, **kwargs): if (init_cfg is None): init_cfg = dict(type='Normal', layer='Conv2d', ...
@HEADS.register_module() class LADHead(PAAHead): 'Label Assignment Head from the paper: `Improving Object Detection by\n Label Assignment Distillation <https://arxiv.org/pdf/2108.10520.pdf>`_' @force_fp32(apply_to=('cls_scores', 'bbox_preds', 'iou_preds')) def get_label_assignment(self, cls_scores, bb...
@HEADS.register_module() class NASFCOSHead(FCOSHead): 'Anchor-free head used in `NASFCOS <https://arxiv.org/abs/1906.04423>`_.\n\n It is quite similar with FCOS head, except for the searched structure of\n classification branch and bbox regression branch, where a structure of\n "dconv3x3, conv3x3, dconv3...
@HEADS.register_module() class PISARetinaHead(RetinaHead): 'PISA Retinanet Head.\n\n The head owns the same structure with Retinanet Head, but differs in two\n aspects:\n 1. Importance-based Sample Reweighting Positive (ISR-P) is applied to\n change the positive loss weights.\n ...
@HEADS.register_module() class PISASSDHead(SSDHead): def loss(self, cls_scores, bbox_preds, gt_bboxes, gt_labels, img_metas, gt_bboxes_ignore=None): 'Compute losses of the head.\n\n Args:\n cls_scores (list[Tensor]): Box scores for each scale level\n Has shape (N, num_anc...
@HEADS.register_module() class RetinaHead(AnchorHead): 'An anchor-based head used in `RetinaNet\n <https://arxiv.org/pdf/1708.02002.pdf>`_.\n\n The head contains two subnetworks. The first classifies anchor boxes and\n the second regresses deltas for the anchors.\n\n Example:\n >>> import torch...
@HEADS.register_module() class RetinaSepBNHead(AnchorHead): '"RetinaHead with separate BN.\n\n In RetinaHead, conv/norm layers are shared across different FPN levels,\n while in RetinaSepBNHead, conv layers are shared across different FPN\n levels, but BN layers are separated.\n ' def __init__(se...
@HEADS.register_module() class SSDHead(AnchorHead): 'SSD head used in https://arxiv.org/abs/1512.02325.\n\n Args:\n num_classes (int): Number of categories excluding the background\n category.\n in_channels (int): Number of channels in the input feature map.\n stacked_convs (int...
@DETECTORS.register_module() class ATSS(SingleStageDetector): 'Implementation of `ATSS <https://arxiv.org/abs/1912.02424>`_.' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(ATSS, self).__init__(backbone, neck, bbox_head, train_cfg, ...
@DETECTORS.register_module() class AutoAssign(SingleStageDetector): 'Implementation of `AutoAssign: Differentiable Label Assignment for Dense\n Object Detection <https://arxiv.org/abs/2007.03496>`_.' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None): sup...
class BaseDetector(BaseModule, metaclass=ABCMeta): 'Base class for detectors.' def __init__(self, init_cfg=None): super(BaseDetector, self).__init__(init_cfg) self.fp16_enabled = False @property def with_neck(self): 'bool: whether the detector has a neck' return (hasa...
@DETECTORS.register_module() class CascadeRCNN(TwoStageDetector): 'Implementation of `Cascade R-CNN: Delving into High Quality Object\n Detection <https://arxiv.org/abs/1906.09756>`_' def __init__(self, backbone, neck=None, rpn_head=None, roi_head=None, train_cfg=None, test_cfg=None, pretrained=None, init...
@DETECTORS.register_module() class CenterNet(SingleStageDetector): 'Implementation of CenterNet(Objects as Points)\n\n <https://arxiv.org/abs/1904.07850>.\n ' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(CenterNet, self).__i...
@DETECTORS.register_module() class DeformableDETR(DETR): def __init__(self, *args, **kwargs): super(DETR, self).__init__(*args, **kwargs)
@DETECTORS.register_module() class DETR(SingleStageDetector): 'Implementation of `DETR: End-to-End Object Detection with\n Transformers <https://arxiv.org/pdf/2005.12872>`_' def __init__(self, backbone, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(DETR, self).__...
@DETECTORS.register_module() class FastRCNN(TwoStageDetector): 'Implementation of `Fast R-CNN <https://arxiv.org/abs/1504.08083>`_' def __init__(self, backbone, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(FastRCNN, self).__init__(backbone=backbone, neck=neck, roi_...
@DETECTORS.register_module() class FasterRCNN(TwoStageDetector): 'Implementation of `Faster R-CNN <https://arxiv.org/abs/1506.01497>`_' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(FasterRCNN, self).__init__(backbone=backbone,...
@DETECTORS.register_module() class FCOS(SingleStageDetector): 'Implementation of `FCOS <https://arxiv.org/abs/1904.01355>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(FCOS, self).__init__(backbone, neck, bbox_head, train_cfg, t...
@DETECTORS.register_module() class FOVEA(SingleStageDetector): 'Implementation of `FoveaBox <https://arxiv.org/abs/1904.03797>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(FOVEA, self).__init__(backbone, neck, bbox_head, train_...
@DETECTORS.register_module() class FSAF(SingleStageDetector): 'Implementation of `FSAF <https://arxiv.org/abs/1903.00621>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(FSAF, self).__init__(backbone, neck, bbox_head, train_cfg, t...
@DETECTORS.register_module() class GFL(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(GFL, self).__init__(backbone, neck, bbox_head, train_cfg, test_cfg, pretrained, init_cfg)
@DETECTORS.register_module() class GridRCNN(TwoStageDetector): 'Grid R-CNN.\n\n This detector is the implementation of:\n - Grid R-CNN (https://arxiv.org/abs/1811.12030)\n - Grid R-CNN Plus: Faster and Better (https://arxiv.org/abs/1906.05688)\n ' def __init__(self, backbone, rpn_head, roi_head, ...
@DETECTORS.register_module() class HybridTaskCascade(CascadeRCNN): 'Implementation of `HTC <https://arxiv.org/abs/1901.07518>`_' def __init__(self, **kwargs): super(HybridTaskCascade, self).__init__(**kwargs) @property def with_semantic(self): 'bool: whether the detector has a semant...
@DETECTORS.register_module() class KnowledgeDistillationSingleStageDetector(SingleStageDetector): 'Implementation of `Distilling the Knowledge in a Neural Network.\n <https://arxiv.org/abs/1503.02531>`_.\n\n Args:\n teacher_config (str | dict): Config file path\n or the config object of te...
@DETECTORS.register_module() class LAD(KnowledgeDistillationSingleStageDetector): 'Implementation of `LAD <https://arxiv.org/pdf/2108.10520.pdf>`_.' def __init__(self, backbone, neck, bbox_head, teacher_backbone, teacher_neck, teacher_bbox_head, teacher_ckpt, eval_teacher=True, train_cfg=None, test_cfg=None,...
@DETECTORS.register_module() class MaskRCNN(TwoStageDetector): 'Implementation of `Mask R-CNN <https://arxiv.org/abs/1703.06870>`_' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(MaskRCNN, self).__init__(backbone=backbone, neck=...
@DETECTORS.register_module() class MaskScoringRCNN(TwoStageDetector): 'Mask Scoring RCNN.\n\n https://arxiv.org/abs/1903.00241\n ' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(MaskScoringRCNN, self).__init__(backbone=bac...
@DETECTORS.register_module() class NASFCOS(SingleStageDetector): 'NAS-FCOS: Fast Neural Architecture Search for Object Detection.\n\n https://arxiv.org/abs/1906.0442\n ' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(NASFCOS, ...
@DETECTORS.register_module() class PAA(SingleStageDetector): 'Implementation of `PAA <https://arxiv.org/pdf/2007.08103.pdf>`_.' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(PAA, self).__init__(backbone, neck, bbox_head, train_cfg,...
@DETECTORS.register_module() class PanopticFPN(TwoStagePanopticSegmentor): 'Implementation of `Panoptic feature pyramid\n networks <https://arxiv.org/pdf/1901.02446>`_' def __init__(self, backbone, neck=None, rpn_head=None, roi_head=None, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None, sema...
@DETECTORS.register_module() class PointRend(TwoStageDetector): 'PointRend: Image Segmentation as Rendering\n\n This detector is the implementation of\n `PointRend <https://arxiv.org/abs/1912.08193>`_.\n\n ' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=...
@DETECTORS.register_module() class QueryInst(SparseRCNN): 'Implementation of\n `Instances as Queries <http://arxiv.org/abs/2105.01928>`_' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(QueryInst, self).__init__(backbone=backb...
@DETECTORS.register_module() class RepPointsDetector(SingleStageDetector): 'RepPoints: Point Set Representation for Object Detection.\n\n This detector is the implementation of:\n - RepPoints detector (https://arxiv.org/pdf/1904.11490)\n ' def __init__(self, backbone, neck, bbox_head, train_...
@DETECTORS.register_module() class RetinaNet(SingleStageDetector): 'Implementation of `RetinaNet <https://arxiv.org/abs/1708.02002>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(RetinaNet, self).__init__(backbone, neck, bbox_hea...
@DETECTORS.register_module() class SCNet(CascadeRCNN): 'Implementation of `SCNet <https://arxiv.org/abs/2012.10150>`_' def __init__(self, **kwargs): super(SCNet, self).__init__(**kwargs)
@DETECTORS.register_module() class SingleStageDetector(BaseDetector): 'Base class for single-stage detectors.\n\n Single-stage detectors directly and densely predict bounding boxes on the\n output features of the backbone+neck.\n ' def __init__(self, backbone, neck=None, bbox_head=None, train_cfg=No...
@DETECTORS.register_module() class SOLO(SingleStageInstanceSegmentor): '`SOLO: Segmenting Objects by Locations\n <https://arxiv.org/abs/1912.04488>`_\n\n ' def __init__(self, backbone, neck=None, bbox_head=None, mask_head=None, train_cfg=None, test_cfg=None, init_cfg=None, pretrained=None): sup...
@DETECTORS.register_module() class SparseRCNN(TwoStageDetector): 'Implementation of `Sparse R-CNN: End-to-End Object Detection with\n Learnable Proposals <https://arxiv.org/abs/2011.12450>`_' def __init__(self, *args, **kwargs): super(SparseRCNN, self).__init__(*args, **kwargs) assert self...
@DETECTORS.register_module() class TOOD(SingleStageDetector): 'Implementation of `TOOD: Task-aligned One-stage Object Detection.\n <https://arxiv.org/abs/2108.07755>`_.' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(TOOD, self)....
@DETECTORS.register_module() class TridentFasterRCNN(FasterRCNN): 'Implementation of `TridentNet <https://arxiv.org/abs/1901.01892>`_' def __init__(self, backbone, rpn_head, roi_head, train_cfg, test_cfg, neck=None, pretrained=None, init_cfg=None): super(TridentFasterRCNN, self).__init__(backbone=bac...
@DETECTORS.register_module() class TwoStageDetector(BaseDetector): 'Base class for two-stage detectors.\n\n Two-stage detectors typically consisting of a region proposal network and a\n task-specific regression head.\n ' def __init__(self, backbone, neck=None, rpn_head=None, roi_head=None, train_cfg...
@DETECTORS.register_module() class VFNet(SingleStageDetector): 'Implementation of `VarifocalNet\n (VFNet).<https://arxiv.org/abs/2008.13367>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(VFNet, self).__init__(backbone, neck, ...
@DETECTORS.register_module() class YOLACT(SingleStageDetector): 'Implementation of `YOLACT <https://arxiv.org/abs/1904.02689>`_' def __init__(self, backbone, neck, bbox_head, segm_head, mask_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(YOLACT, self).__init__(backbone, n...
@DETECTORS.register_module() class YOLOV3(SingleStageDetector): def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None, init_cfg=None): super(YOLOV3, self).__init__(backbone, neck, bbox_head, train_cfg, test_cfg, pretrained, init_cfg) def onnx_export(self, img, ...
@DETECTORS.register_module() class YOLOF(SingleStageDetector): 'Implementation of `You Only Look One-level Feature\n <https://arxiv.org/abs/2103.09460>`_' def __init__(self, backbone, neck, bbox_head, train_cfg=None, test_cfg=None, pretrained=None): super(YOLOF, self).__init__(backbone, neck, bbox...
@mmcv.jit(coderize=True) def accuracy(pred, target, topk=1, thresh=None): 'Calculate accuracy according to the prediction and target.\n\n Args:\n pred (torch.Tensor): The model prediction, shape (N, num_class)\n target (torch.Tensor): The target of each prediction, shape (N, )\n topk (int ...
class Accuracy(nn.Module): def __init__(self, topk=(1,), thresh=None): 'Module to calculate the accuracy.\n\n Args:\n topk (tuple, optional): The criterion used to calculate the\n accuracy. Defaults to (1,).\n thresh (float, optional): If not None, predictions ...
@mmcv.jit(derivate=True, coderize=True) @weighted_loss def balanced_l1_loss(pred, target, beta=1.0, alpha=0.5, gamma=1.5, reduction='mean'): 'Calculate balanced L1 loss.\n\n Please see the `Libra R-CNN <https://arxiv.org/pdf/1904.02701.pdf>`_\n\n Args:\n pred (torch.Tensor): The prediction with shape...
@LOSSES.register_module() class BalancedL1Loss(nn.Module): 'Balanced L1 Loss.\n\n arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019)\n\n Args:\n alpha (float): The denominator ``alpha`` in the balanced L1 loss.\n Defaults to 0.5.\n gamma (float): The ``gamma`` in the balanced L...
def cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None, class_weight=None, ignore_index=(- 100)): 'Calculate the CrossEntropy loss.\n\n Args:\n pred (torch.Tensor): The prediction with shape (N, C), C is the number\n of classes.\n label (torch.Tensor): The learni...
def _expand_onehot_labels(labels, label_weights, label_channels, ignore_index): 'Expand onehot labels to match the size of prediction.' bin_labels = labels.new_full((labels.size(0), label_channels), 0) valid_mask = ((labels >= 0) & (labels != ignore_index)) inds = torch.nonzero((valid_mask & (labels <...
def binary_cross_entropy(pred, label, weight=None, reduction='mean', avg_factor=None, class_weight=None, ignore_index=(- 100)): 'Calculate the binary CrossEntropy loss.\n\n Args:\n pred (torch.Tensor): The prediction with shape (N, 1).\n label (torch.Tensor): The learning label of the prediction....
def mask_cross_entropy(pred, target, label, reduction='mean', avg_factor=None, class_weight=None, ignore_index=None): 'Calculate the CrossEntropy loss for masks.\n\n Args:\n pred (torch.Tensor): The prediction with shape (N, C, *), C is the\n number of classes. The trailing * indicates arbitr...
@LOSSES.register_module() class CrossEntropyLoss(nn.Module): def __init__(self, use_sigmoid=False, use_mask=False, reduction='mean', class_weight=None, ignore_index=None, loss_weight=1.0): 'CrossEntropyLoss.\n\n Args:\n use_sigmoid (bool, optional): Whether the prediction uses sigmoid\n...
def dice_loss(pred, target, weight=None, eps=0.001, reduction='mean', naive_dice=False, avg_factor=None): 'Calculate dice loss, there are two forms of dice loss is supported:\n\n - the one proposed in `V-Net: Fully Convolutional Neural\n Networks for Volumetric Medical Image Segmentation\n ...
@LOSSES.register_module() class DiceLoss(nn.Module): def __init__(self, use_sigmoid=True, activate=True, reduction='mean', naive_dice=False, loss_weight=1.0, eps=0.001): 'Compute dice loss.\n\n Args:\n use_sigmoid (bool, optional): Whether to the prediction is\n used for ...
@mmcv.jit(derivate=True, coderize=True) @weighted_loss def gaussian_focal_loss(pred, gaussian_target, alpha=2.0, gamma=4.0): '`Focal Loss <https://arxiv.org/abs/1708.02002>`_ for targets in gaussian\n distribution.\n\n Args:\n pred (torch.Tensor): The prediction.\n gaussian_target (torch.Tenso...
@LOSSES.register_module() class GaussianFocalLoss(nn.Module): 'GaussianFocalLoss is a variant of focal loss.\n\n More details can be found in the `paper\n <https://arxiv.org/abs/1808.01244>`_\n Code is modified from `kp_utils.py\n <https://github.com/princeton-vl/CornerNet/blob/master/models/py_utils/...