(self, cfg = None, phase = 'train')
:param cfg:  Network related settings.
        :param phase: train or test.
:param cfg:  Network related settings.
        :param phase: train or test.
: param cfg : Network related settings . : param phase : train or test .
def __init__(self, cfg = None, phase = 'train'):
        """
        :param cfg:  Network related settings.
        :param phase: train or test.
        """
        super(RetinaFace,self).__init__()
        self.phase = phase
        backbone = None
        if cfg['name'] == 'mobilenet0.25':
            backbone = MobileNetV1()
            if cfg['pretrain']:
                checkpoint = torch.load("./weights/mobilenetV1X0.25_pretrain.tar", map_location=torch.device('cpu'))
                from collections import OrderedDict
                new_state_dict = OrderedDict()
                for k, v in checkpoint['state_dict'].items():
                    name = k[7:]  # remove module.
                    new_state_dict[name] = v
                # load params
                backbone.load_state_dict(new_state_dict)
        elif cfg['name'] == 'Resnet50':
            import torchvision.models as models
            backbone = models.resnet50(pretrained=cfg['pretrain'])

        self.body = _utils.IntermediateLayerGetter(backbone, cfg['return_layers'])
        in_channels_stage2 = cfg['in_channel']
        in_channels_list = [
            in_channels_stage2 * 2,
            in_channels_stage2 * 4,
            in_channels_stage2 * 8,
        ]
        out_channels = cfg['out_channel']
        self.fpn = FPN(in_channels_list,out_channels)
        self.ssh1 = SSH(out_channels, out_channels)
        self.ssh2 = SSH(out_channels, out_channels)
        self.ssh3 = SSH(out_channels, out_channels)

        self.ClassHead = self._make_class_head(fpn_num=3, inchannels=cfg['out_channel'])
        self.BboxHead = self._make_bbox_head(fpn_num=3, inchannels=cfg['out_channel'])
        self.LandmarkHead = self._make_landmark_head(fpn_num=3, inchannels=cfg['out_channel'])
def __init__ ( self , cfg = None , phase = 'train' ) : super ( RetinaFace , self ) . __init__ ( ) self . phase = phase backbone = None if cfg [ 'name' ] == 'mobilenet0.25' : backbone = MobileNetV1 ( ) if cfg [ 'pretrain' ] : checkpoint = torch . load ( "./weights/mobilenetV1X0.25_pretrain.tar" , map_location = torch . device ( 'cpu' ) ) from collections import OrderedDict new_state_dict = OrderedDict ( ) for k , v in checkpoint [ 'state_dict' ] . items ( ) : name = k [ 7 : ] # remove module. new_state_dict [ name ] = v # load params backbone . load_state_dict ( new_state_dict ) elif cfg [ 'name' ] == 'Resnet50' : import torchvision . models as models backbone = models . resnet50 ( pretrained = cfg [ 'pretrain' ] ) self . body = _utils . IntermediateLayerGetter ( backbone , cfg [ 'return_layers' ] ) in_channels_stage2 = cfg [ 'in_channel' ] in_channels_list = [ in_channels_stage2 * 2 , in_channels_stage2 * 4 , in_channels_stage2 * 8 , ] out_channels = cfg [ 'out_channel' ] self . fpn = FPN ( in_channels_list , out_channels ) self . ssh1 = SSH ( out_channels , out_channels ) self . ssh2 = SSH ( out_channels , out_channels ) self . ssh3 = SSH ( out_channels , out_channels ) self . ClassHead = self . _make_class_head ( fpn_num = 3 , inchannels = cfg [ 'out_channel' ] ) self . BboxHead = self . _make_bbox_head ( fpn_num = 3 , inchannels = cfg [ 'out_channel' ] ) self . LandmarkHead = self . _make_landmark_head ( fpn_num = 3 , inchannels = cfg [ 'out_channel' ] )