Python maskrcnn_benchmark.modeling.make_layers.group_norm() Examples

The following are 30 code examples of maskrcnn_benchmark.modeling.make_layers.group_norm(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maskrcnn_benchmark.modeling.make_layers , or try the search function .
Example #1
Source File: resnet.py    From Res2Net-maskrcnn with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #2
Source File: resnet.py    From sampling-free with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        dcn_config={}
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm,
            dcn_config=dcn_config
        ) 
Example #3
Source File: resnet.py    From maskrcnn-benchmark with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        dcn_config={}
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm,
            dcn_config=dcn_config
        ) 
Example #4
Source File: resnet.py    From remote_sensing_object_detection_2019 with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #5
Source File: resnet.py    From training with Apache License 2.0 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #6
Source File: resnet.py    From NAS-FCOS with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #7
Source File: resnet.py    From DetNAS with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        dcn_config={}
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm,
            dcn_config=dcn_config
        ) 
Example #8
Source File: resnet.py    From Clothing-Detection with GNU General Public License v3.0 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        dcn_config={}
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm,
            dcn_config=dcn_config
        ) 
Example #9
Source File: resnet.py    From RRPN_pytorch with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #10
Source File: resnet.py    From R2CNN.pytorch with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #11
Source File: resnet.py    From DF-Traffic-Sign-Identification with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        dcn_config={}
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm,
            dcn_config=dcn_config
        ) 
Example #12
Source File: res2net.py    From Res2Net-maskrcnn with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1,
        scale=4
    ):
        super(Bottle2neckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            scale=4,
            norm_func=group_norm
        ) 
Example #13
Source File: resnet.py    From TinyBenchmark with MIT License 6 votes vote down vote up
def __init__(
        self,
        in_channels,
        bottleneck_channels,
        out_channels,
        num_groups=1,
        stride_in_1x1=True,
        stride=1,
        dilation=1
    ):
        super(BottleneckWithGN, self).__init__(
            in_channels=in_channels,
            bottleneck_channels=bottleneck_channels,
            out_channels=out_channels,
            num_groups=num_groups,
            stride_in_1x1=stride_in_1x1,
            stride=stride,
            dilation=dilation,
            norm_func=group_norm
        ) 
Example #14
Source File: resnet.py    From RRPN_pytorch with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #15
Source File: roi_rec_predictors.py    From RRPN_pytorch with MIT License 5 votes vote down vote up
def __init__(self, in_channels, out_channels, kernel_size, stride=1, relu=True, same_padding=False, gn=False):
        super(Conv2dGroup, self).__init__()
        padding = int((kernel_size - 1) / 2) if same_padding else 0
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding=padding)
        self.gn = GN(out_channels) if gn else None # nn.BatchNorm2d(out_channels, eps=0.001, momentum=0, affine=True) if gn else None #
        self.relu = nn.ReLU(inplace=True) if relu else None 
Example #16
Source File: resnet.py    From NAS-FCOS with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #17
Source File: resnet.py    From training with Apache License 2.0 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #18
Source File: resnet.py    From DF-Traffic-Sign-Identification with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #19
Source File: resnet.py    From maskrcnn-benchmark with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #20
Source File: resnet.py    From sampling-free with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #21
Source File: resnet.py    From TinyBenchmark with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm)


# add by hui copy from https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py #################### 
Example #22
Source File: resnet.py    From remote_sensing_object_detection_2019 with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #23
Source File: roi_rec_predictors.py    From remote_sensing_object_detection_2019 with MIT License 5 votes vote down vote up
def __init__(self, in_channels, out_channels, kernel_size, stride=1, relu=True, same_padding=False, gn=False):
        super(Conv2dGroup, self).__init__()
        padding = int((kernel_size - 1) / 2) if same_padding else 0
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding=padding)
        self.gn = GN(out_channels) if gn else None # nn.BatchNorm2d(out_channels, eps=0.001, momentum=0, affine=True) if gn else None #
        self.relu = nn.ReLU(inplace=True) if relu else None 
Example #24
Source File: resnet.py    From Res2Net-maskrcnn with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #25
Source File: res2net.py    From Res2Net-maskrcnn with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #26
Source File: resnet.py    From DetNAS with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #27
Source File: resnet.py    From R2CNN.pytorch with MIT License 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #28
Source File: resnet.py    From Clothing-Detection with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm) 
Example #29
Source File: roi_box_feature_extractors.py    From RRPN_pytorch with MIT License 4 votes vote down vote up
def __init__(self, cfg):
        super(FPNXconv1fcFeatureExtractor, self).__init__()

        resolution = cfg.MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION
        scales = cfg.MODEL.ROI_BOX_HEAD.POOLER_SCALES
        sampling_ratio = cfg.MODEL.ROI_BOX_HEAD.POOLER_SAMPLING_RATIO
        pooler = Pooler(
            output_size=(resolution, resolution),
            scales=scales,
            sampling_ratio=sampling_ratio,
        )
        self.pooler = pooler
        
        use_gn = cfg.MODEL.ROI_BOX_HEAD.USE_GN
        in_channels = cfg.MODEL.BACKBONE.OUT_CHANNELS
        conv_head_dim = cfg.MODEL.ROI_BOX_HEAD.CONV_HEAD_DIM
        num_stacked_convs = cfg.MODEL.ROI_BOX_HEAD.NUM_STACKED_CONVS
        dilation = cfg.MODEL.ROI_BOX_HEAD.DILATION

        xconvs = []
        for ix in range(num_stacked_convs):
            xconvs.append(
                nn.Conv2d(
                    in_channels,
                    conv_head_dim,
                    kernel_size=3,
                    stride=1,
                    padding=dilation,
                    dilation=dilation,
                    bias=False if use_gn else True
                )
            )
            in_channels = conv_head_dim
            if use_gn:
                xconvs.append(group_norm(in_channels))
            xconvs.append(nn.ReLU(inplace=True))

        self.add_module("xconvs", nn.Sequential(*xconvs))
        for modules in [self.xconvs,]:
            for l in modules.modules():
                if isinstance(l, nn.Conv2d):
                    torch.nn.init.normal_(l.weight, std=0.01)
                    if not use_gn:
                        torch.nn.init.constant_(l.bias, 0)

        input_size = conv_head_dim * resolution ** 2
        representation_size = cfg.MODEL.ROI_BOX_HEAD.MLP_HEAD_DIM
        self.fc6 = make_fc(input_size, representation_size, use_gn=False) 
Example #30
Source File: roi_box_feature_extractors.py    From Res2Net-maskrcnn with MIT License 4 votes vote down vote up
def __init__(self, cfg, in_channels):
        super(FPNXconv1fcFeatureExtractor, self).__init__()

        resolution = cfg.MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION
        scales = cfg.MODEL.ROI_BOX_HEAD.POOLER_SCALES
        sampling_ratio = cfg.MODEL.ROI_BOX_HEAD.POOLER_SAMPLING_RATIO
        pooler = Pooler(
            output_size=(resolution, resolution),
            scales=scales,
            sampling_ratio=sampling_ratio,
        )
        self.pooler = pooler

        use_gn = cfg.MODEL.ROI_BOX_HEAD.USE_GN
        conv_head_dim = cfg.MODEL.ROI_BOX_HEAD.CONV_HEAD_DIM
        num_stacked_convs = cfg.MODEL.ROI_BOX_HEAD.NUM_STACKED_CONVS
        dilation = cfg.MODEL.ROI_BOX_HEAD.DILATION

        xconvs = []
        for ix in range(num_stacked_convs):
            xconvs.append(
                nn.Conv2d(
                    in_channels,
                    conv_head_dim,
                    kernel_size=3,
                    stride=1,
                    padding=dilation,
                    dilation=dilation,
                    bias=False if use_gn else True
                )
            )
            in_channels = conv_head_dim
            if use_gn:
                xconvs.append(group_norm(in_channels))
            xconvs.append(nn.ReLU(inplace=True))

        self.add_module("xconvs", nn.Sequential(*xconvs))
        for modules in [self.xconvs,]:
            for l in modules.modules():
                if isinstance(l, nn.Conv2d):
                    torch.nn.init.normal_(l.weight, std=0.01)
                    if not use_gn:
                        torch.nn.init.constant_(l.bias, 0)

        input_size = conv_head_dim * resolution ** 2
        representation_size = cfg.MODEL.ROI_BOX_HEAD.MLP_HEAD_DIM
        self.fc6 = make_fc(input_size, representation_size, use_gn=False)
        self.out_channels = representation_size