コード例 #1
0
ファイル: ssd300.py プロジェクト: gsrujana89/training
    def __init__(self,
                 label_num,
                 backbone='resnet34',
                 model_path="./resnet34-333f7ec4.pth"):

        super(SSD300, self).__init__()

        self.label_num = label_num

        if backbone == 'resnet34':
            self.model = ResNet34()
            out_channels = 256
            out_size = 38
            self.out_chan = [out_channels, 512, 512, 256, 256, 256]
        else:
            raise ValueError('Invalid backbone chosen')

        self._build_additional_features(out_size, self.out_chan)

        # after l2norm, conv7, conv8_2, conv9_2, conv10_2, conv11_2
        # classifer 1, 2, 3, 4, 5 ,6

        self.num_defaults = [4, 6, 6, 6, 4, 4]
        self.loc = []
        self.conf = []

        for nd, oc in zip(self.num_defaults, self.out_chan):
            self.loc.append(nn.Conv2d(oc, nd * 4, kernel_size=3, padding=1))
            self.conf.append(
                nn.Conv2d(oc, nd * label_num, kernel_size=3, padding=1))

        self.loc = nn.ModuleList(self.loc)
        self.conf = nn.ModuleList(self.conf)
        # intitalize all weights
        self._init_weights()
コード例 #2
0
    def __init__(self, label_num, backbone='resnet34', use_nhwc=False, pad_input=False):

        super(SSD300, self).__init__()

        self.label_num = label_num
        self.use_nhwc = use_nhwc
        self.pad_input = pad_input

        if backbone == 'resnet18':
            self.model = ResNet18(self.use_nhwc, self.pad_input)
            out_channels = 256
            out_size = 38
            self.out_chan = [out_channels, 512, 512, 256, 256, 128]
        elif backbone == 'resnet34':
            self.model = ResNet34(self.use_nhwc, self.pad_input)
            ssd_print(key=mlperf_log.BACKBONE, value='resnet34')
            out_channels = 256
            out_size = 38
            self.out_chan = [out_channels, 512, 512, 256, 256, 256]
            ssd_print(key=mlperf_log.LOC_CONF_OUT_CHANNELS,
                                  value=self.out_chan)
        elif backbone == 'resnet50':
            self.model = ResNet50(self.use_nhwc, self.pad_input)
            out_channels = 1024
            out_size = 38
            self.l2norm4 = L2Norm()
            self.out_chan = [out_channels, 1024, 512, 512, 256, 256]
        else:
            print('Invalid backbone chosen')

        self._build_additional_features(out_size, self.out_chan)

        # after l2norm, conv7, conv8_2, conv9_2, conv10_2, conv11_2
        # classifer 1, 2, 3, 4, 5 ,6

        self.num_defaults = [4, 6, 6, 6, 4, 4]
        ssd_print(key=mlperf_log.NUM_DEFAULTS_PER_CELL,
                             value=self.num_defaults)
        self.loc = []
        self.conf = []

        for nd, oc in zip(self.num_defaults, self.out_chan):
            self.loc.append(nn.Conv2d(oc, nd*4, kernel_size=3, padding=1))
            self.conf.append(nn.Conv2d(oc, nd*label_num, kernel_size=3, padding=1))


        self.loc = nn.ModuleList(self.loc)
        self.conf = nn.ModuleList(self.conf)
        # intitalize all weights
        self._init_weights()
コード例 #3
0
    def __init__(self,
                 label_num,
                 backbone='resnet34',
                 model_path="./resnet34-333f7ec4.pth"):

        super(SSD300, self).__init__()

        self.label_num = label_num

        if backbone == 'resnet34':
            self.model = ResNet34()
            mlperf_log.ssd_print(key=mlperf_log.BACKBONE, value='resnet34')
            out_channels = 256
            out_size = 38
            self.out_chan = [out_channels, 512, 512, 256, 256, 256]
            mlperf_log.ssd_print(key=mlperf_log.LOC_CONF_OUT_CHANNELS,
                                 value=self.out_chan)

        else:
            raise ValueError('Invalid backbone chosen')

        self._build_additional_features(out_size, self.out_chan)

        # after l2norm, conv7, conv8_2, conv9_2, conv10_2, conv11_2
        # classifer 1, 2, 3, 4, 5 ,6

        self.num_defaults = [4, 6, 6, 6, 4, 4]
        mlperf_log.ssd_print(key=mlperf_log.NUM_DEFAULTS_PER_CELL,
                             value=self.num_defaults)
        self.loc = []
        self.conf = []

        for nd, oc in zip(self.num_defaults, self.out_chan):
            #self.loc.append(bf16cutfp_mod())
            self.loc.append(nn.Conv2d(oc, nd * 4, kernel_size=3, padding=1))
            #self.loc.append(bf16cutbp_mod())
            #self.conf.append(bf16cutfp_mod())
            self.conf.append(
                nn.Conv2d(oc, nd * label_num, kernel_size=3, padding=1))
            #self.conf.append(bf16cutbp_mod())

        self.loc = nn.ModuleList(self.loc)
        self.conf = nn.ModuleList(self.conf)
        # intitalize all weights
        self._init_weights()