(self, in_channels=3, **kwargs)
the MobilenetV3 backbone network for detection module.
        Args:
            params(dict): the super parameters for build network
the MobilenetV3 backbone network for detection module.
        Args:
            params(dict): the super parameters for build network
the MobilenetV3 backbone network for detection module . Args : params ( dict ) : the super parameters for build network
def __init__(self, in_channels=3, **kwargs):
        """
        the MobilenetV3 backbone network for detection module.
        Args:
            params(dict): the super parameters for build network
        """
        super().__init__()
        self.scale = kwargs.get('scale', 0.5)
        model_name = kwargs.get('model_name', 'large')
        self.inplanes = 16
        if model_name == "large":
            self.cfg = [
                # k, exp, c,  se,     nl,  s,
                [3, 16, 16, False, 'relu', 1],
                [3, 64, 24, False, 'relu', 2],
                [3, 72, 24, False, 'relu', 1],
                [5, 72, 40, True, 'relu', 2],
                [5, 120, 40, True, 'relu', 1],
                [5, 120, 40, True, 'relu', 1],
                [3, 240, 80, False, 'hard_swish', 2],
                [3, 200, 80, False, 'hard_swish', 1],
                [3, 184, 80, False, 'hard_swish', 1],
                [3, 184, 80, False, 'hard_swish', 1],
                [3, 480, 112, True, 'hard_swish', 1],
                [3, 672, 112, True, 'hard_swish', 1],
                [5, 672, 160, True, 'hard_swish', 2],
                [5, 960, 160, True, 'hard_swish', 1],
                [5, 960, 160, True, 'hard_swish', 1],
            ]
            self.cls_ch_squeeze = 960
            self.cls_ch_expand = 1280
        elif model_name == "small":
            self.cfg = [
                # k, exp, c,  se,     nl,  s,
                [3, 16, 16, True, 'relu', 2],
                [3, 72, 24, False, 'relu', 2],
                [3, 88, 24, False, 'relu', 1],
                [5, 96, 40, True, 'hard_swish', 2],
                [5, 240, 40, True, 'hard_swish', 1],
                [5, 240, 40, True, 'hard_swish', 1],
                [5, 120, 48, True, 'hard_swish', 1],
                [5, 144, 48, True, 'hard_swish', 1],
                [5, 288, 96, True, 'hard_swish', 2],
                [5, 576, 96, True, 'hard_swish', 1],
                [5, 576, 96, True, 'hard_swish', 1],
            ]
            self.cls_ch_squeeze = 576
            self.cls_ch_expand = 1280
        else:
            raise NotImplementedError("mode[" + model_name +
                                      "_model] is not implemented!")

        supported_scale = [0.35, 0.5, 0.75, 1.0, 1.25]
        assert self.scale in supported_scale, \
            "supported scale are {} but input scale is {}".format(supported_scale, self.scale)

        scale = self.scale
        inplanes = self.inplanes
        cfg = self.cfg
        cls_ch_squeeze = self.cls_ch_squeeze
        # conv1
        self.conv1 = ConvBNACT(in_channels=in_channels,
                               out_channels=self.make_divisible(inplanes * scale),
                               kernel_size=3,
                               stride=2,
                               padding=1,
                               groups=1,
                               act='hard_swish')
        i = 0
        inplanes = self.make_divisible(inplanes * scale)
        self.stages = nn.ModuleList()
        block_list = []
        self.out_channels = []
        for layer_cfg in cfg:
            if layer_cfg[5] == 2 and i > 2:
                self.out_channels.append(inplanes)
                self.stages.append(nn.Sequential(*block_list))
                block_list = []
            block = ResidualUnit(num_in_filter=inplanes,
                                 num_mid_filter=self.make_divisible(scale * layer_cfg[1]),
                                 num_out_filter=self.make_divisible(scale * layer_cfg[2]),
                                 act=layer_cfg[4],
                                 stride=layer_cfg[5],
                                 kernel_size=layer_cfg[0],
                                 use_se=layer_cfg[3])
            block_list.append(block)
            inplanes = self.make_divisible(scale * layer_cfg[2])
            i += 1
        self.stages.append(nn.Sequential(*block_list))
        self.conv2 = ConvBNACT(
            in_channels=inplanes,
            out_channels=self.make_divisible(scale * cls_ch_squeeze),
            kernel_size=1,
            stride=1,
            padding=0,
            groups=1,
            act='hard_swish')
        self.out_channels.append(self.make_divisible(scale * cls_ch_squeeze))
def __init__ ( self , in_channels = 3 , * * kwargs ) : super ( ) . __init__ ( ) self . scale = kwargs . get ( 'scale' , 0.5 ) model_name = kwargs . get ( 'model_name' , 'large' ) self . inplanes = 16 if model_name == "large" : self . cfg = [ # k, exp, c,  se,     nl,  s, [ 3 , 16 , 16 , False , 'relu' , 1 ] , [ 3 , 64 , 24 , False , 'relu' , 2 ] , [ 3 , 72 , 24 , False , 'relu' , 1 ] , [ 5 , 72 , 40 , True , 'relu' , 2 ] , [ 5 , 120 , 40 , True , 'relu' , 1 ] , [ 5 , 120 , 40 , True , 'relu' , 1 ] , [ 3 , 240 , 80 , False , 'hard_swish' , 2 ] , [ 3 , 200 , 80 , False , 'hard_swish' , 1 ] , [ 3 , 184 , 80 , False , 'hard_swish' , 1 ] , [ 3 , 184 , 80 , False , 'hard_swish' , 1 ] , [ 3 , 480 , 112 , True , 'hard_swish' , 1 ] , [ 3 , 672 , 112 , True , 'hard_swish' , 1 ] , [ 5 , 672 , 160 , True , 'hard_swish' , 2 ] , [ 5 , 960 , 160 , True , 'hard_swish' , 1 ] , [ 5 , 960 , 160 , True , 'hard_swish' , 1 ] , ] self . cls_ch_squeeze = 960 self . cls_ch_expand = 1280 elif model_name == "small" : self . cfg = [ # k, exp, c,  se,     nl,  s, [ 3 , 16 , 16 , True , 'relu' , 2 ] , [ 3 , 72 , 24 , False , 'relu' , 2 ] , [ 3 , 88 , 24 , False , 'relu' , 1 ] , [ 5 , 96 , 40 , True , 'hard_swish' , 2 ] , [ 5 , 240 , 40 , True , 'hard_swish' , 1 ] , [ 5 , 240 , 40 , True , 'hard_swish' , 1 ] , [ 5 , 120 , 48 , True , 'hard_swish' , 1 ] , [ 5 , 144 , 48 , True , 'hard_swish' , 1 ] , [ 5 , 288 , 96 , True , 'hard_swish' , 2 ] , [ 5 , 576 , 96 , True , 'hard_swish' , 1 ] , [ 5 , 576 , 96 , True , 'hard_swish' , 1 ] , ] self . cls_ch_squeeze = 576 self . cls_ch_expand = 1280 else : raise NotImplementedError ( "mode[" + model_name + "_model] is not implemented!" ) supported_scale = [ 0.35 , 0.5 , 0.75 , 1.0 , 1.25 ] assert self . scale in supported_scale , "supported scale are {} but input scale is {}" . format ( supported_scale , self . scale ) scale = self . scale inplanes = self . inplanes cfg = self . cfg cls_ch_squeeze = self . cls_ch_squeeze # conv1 self . conv1 = ConvBNACT ( in_channels = in_channels , out_channels = self . make_divisible ( inplanes * scale ) , kernel_size = 3 , stride = 2 , padding = 1 , groups = 1 , act = 'hard_swish' ) i = 0 inplanes = self . make_divisible ( inplanes * scale ) self . stages = nn . ModuleList ( ) block_list = [ ] self . out_channels = [ ] for layer_cfg in cfg : if layer_cfg [ 5 ] == 2 and i > 2 : self . out_channels . append ( inplanes ) self . stages . append ( nn . Sequential ( * block_list ) ) block_list = [ ] block = ResidualUnit ( num_in_filter = inplanes , num_mid_filter = self . make_divisible ( scale * layer_cfg [ 1 ] ) , num_out_filter = self . make_divisible ( scale * layer_cfg [ 2 ] ) , act = layer_cfg [ 4 ] , stride = layer_cfg [ 5 ] , kernel_size = layer_cfg [ 0 ] , use_se = layer_cfg [ 3 ] ) block_list . append ( block ) inplanes = self . make_divisible ( scale * layer_cfg [ 2 ] ) i += 1 self . stages . append ( nn . Sequential ( * block_list ) ) self . conv2 = ConvBNACT ( in_channels = inplanes , out_channels = self . make_divisible ( scale * cls_ch_squeeze ) , kernel_size = 1 , stride = 1 , padding = 0 , groups = 1 , act = 'hard_swish' ) self . out_channels . append ( self . make_divisible ( scale * cls_ch_squeeze ) )