Example #1
0
                new_key = old_key.replace("conv2.{}".format(param),
                                          "conv2.conv.{}".format(param))
                logger.info("pattern: {}, old_key: {}, new_key: {}".format(
                    pattern, old_key, new_key))
                state_dict[new_key] = state_dict[old_key]
                del state_dict[old_key]
    return state_dict


_C2_STAGE_NAMES = {
    "R-50": ["1.2", "2.3", "3.5", "4.2"],
    "R-101": ["1.2", "2.3", "3.22", "4.2"],
    "R-152": ["1.2", "2.7", "3.35", "4.2"],
}

C2_FORMAT_LOADER = Registry()


@C2_FORMAT_LOADER.register("R-50-C4")
@C2_FORMAT_LOADER.register("R-50-C5")
@C2_FORMAT_LOADER.register("R-101-C4")
@C2_FORMAT_LOADER.register("R-101-C5")
@C2_FORMAT_LOADER.register("R-50-FPN")
@C2_FORMAT_LOADER.register("R-50-FPN-RETINANET")
@C2_FORMAT_LOADER.register("R-101-FPN")
@C2_FORMAT_LOADER.register("R-101-FPN-RETINANET")
@C2_FORMAT_LOADER.register("R-152-FPN")
def load_resnet_c2_format(cfg, f):
    state_dict = _load_c2_pickled_weights(f)
    conv_body = cfg.MODEL.BACKBONE.CONV_BODY
    arch = conv_body.replace("-C4", "").replace("-C5", "").replace("-FPN", "")
Example #2
0
    'block_per_stage': [1, 1, 4, 3]
}


VoVNet93FPNStagesTo5 = {
    'config_stage_ch': [128, 160, 192, 224],
    'config_concat_ch': [256, 512, 768, 1024],
    'layer_per_block': 5,
    'block_per_stage': [1, 3, 8, 3]
}

_STAGE_SPECS = Registry({
    "V-27-FPN": VoVNet27FPNStagesTo5,
    "V-39-FPN": VoVNet39FPNStagesTo5,
    "V-57-FPN": VoVNet57FPNStagesTo5,
    "V-93-FPN": VoVNet93FPNStagesTo5,
    "V-27-FPN-RETINANET": VoVNet27FPNStagesTo5,
    "V-39-FPN-RETINANET": VoVNet39FPNStagesTo5,
    "V-57-FPN-RETINANET": VoVNet57FPNStagesTo5,
    "V-93-FPN-RETINANET": VoVNet93FPNStagesTo5
})

def freeze_bn_params(m):
    """Freeze all the weights by setting requires_grad to False
    """
    m.eval()
    for p in m.parameters():
        p.requires_grad = False

def conv3x3(in_channels, out_channels, module_name, postfix, stride=1, groups=1, kernel_size=3, padding=1):
    """3x3 convolution with padding"""
    return [
Example #3
0
              self).__init__(cfg, norm_func=FrozenBatchNorm2d)


class StemWithBatchNorm(BaseStem):
    def __init__(self, cfg):
        super(StemWithBatchNorm, self).__init__(cfg, norm_func=nn.BatchNorm2d)


class StemWithGN(BaseStem):
    def __init__(self, cfg):
        super(StemWithGN, self).__init__(cfg, norm_func=group_norm)


_TRANSFORMATION_MODULES = Registry({
    "BottleneckWithFixedBatchNorm": BottleneckWithFixedBatchNorm,
    "BottleneckWithBatchNorm": BottleneckWithBatchNorm,
    "BottleneckWithGN": BottleneckWithGN,
})

_STEM_MODULES = Registry({
    "StemWithFixedBatchNorm": StemWithFixedBatchNorm,
    "StemWithBatchNorm": StemWithBatchNorm,
    "StemWithGN": StemWithGN,
})

_STAGE_SPECS = Registry({
    "R-50-C4": ResNet50StagesTo4,
    "R-50-C5": ResNet50StagesTo5,
    "R-101-C4": ResNet101StagesTo4,
    "R-101-C5": ResNet101StagesTo5,
    "R-50-FPN": ResNet50FPNStagesTo5,
Example #4
0
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

from fcos_core.utils.registry import Registry

BACKBONES = Registry()
RPN_HEADS = Registry()
ROI_BOX_FEATURE_EXTRACTORS = Registry()
ROI_BOX_PREDICTOR = Registry()
ROI_KEYPOINT_FEATURE_EXTRACTORS = Registry()
ROI_KEYPOINT_PREDICTOR = Registry()
ROI_MASK_FEATURE_EXTRACTORS = Registry()
ROI_MASK_PREDICTOR = Registry()