Пример #1
0
    def __init__(self, load_path=None):
        """Construct MobileNetV3Tiny class.

        :param load_path: path for saved model
        """
        super(MobileNetV3Tiny, self).__init__()
        input_channel = 9
        features = [
            conv_bn_relu6(inchannel=3,
                          outchannel=input_channel,
                          kernel=3,
                          stride=2)
        ]
        for _, lst in enumerate(self.inverted_residual_setting):
            output_channel = lst[1]
            features.append(
                InvertedResidual(inp=input_channel,
                                 oup=output_channel,
                                 stride=lst[2],
                                 expand_ratio=lst[0]))
            input_channel = output_channel
        self.block = OutlistSequential(*features, out_list=[3, 6, 13, 17])
        if load_path is not None and is_torch_backend():
            import torch
            self.load_state_dict(torch.load(load_path), strict=False)
Пример #2
0
    def __init__(self, load_path=None, width_mult=1.0, round_nearest=8):
        """Construct MobileNetV3Tiny class.

        :param load_path: path for saved model
        """
        super(MobileNetV2Tiny, self).__init__()
        input_channel = 32
        input_channel = _make_divisible(input_channel * width_mult,
                                        round_nearest)
        features = [conv_bn_relu6(3, input_channel, 3, 2)]
        for t, c, n, s in self.inverted_residual_setting:
            output_channel = _make_divisible(c * width_mult, round_nearest)
            for i in range(n):
                stride = s if i == 0 else 1
                features.append(
                    InvertedResidual(inp=input_channel,
                                     oup=output_channel,
                                     stride=stride,
                                     expand_ratio=t))
                input_channel = output_channel
        self.block = OutlistSequential(*features[:18], out_list=[3, 6, 13, 17])