예제 #1
0
    def _get_bbox_head_logit(self, conv_feat):
        if self._head_feat is not None:
            return self._head_feat

        p = self.p

        if p.normalizer.__name__ == "fix_bn":
            conv_feat = X.convrelu(conv_feat, filter=256, kernel=3, name="bbox_conv1")
            conv_feat = X.convrelu(conv_feat, filter=256, kernel=3, name="bbox_conv2")
            conv_feat = X.convrelu(conv_feat, filter=256, kernel=3, name="bbox_conv3")
            conv_feat = X.convrelu(conv_feat, filter=256, kernel=3, name="bbox_conv4")
        elif p.normalizer.__name__ in ["sync_bn", "gn"]:
            conv_feat = X.convnormrelu(p.normalizer, conv_feat, filter=256, kernel=3, name="bbox_conv1")
            conv_feat = X.convnormrelu(p.normalizer, conv_feat, filter=256, kernel=3, name="bbox_conv2")
            conv_feat = X.convnormrelu(p.normalizer, conv_feat, filter=256, kernel=3, name="bbox_conv3")
            conv_feat = X.convnormrelu(p.normalizer, conv_feat, filter=256, kernel=3, name="bbox_conv4")
        else:
            raise NotImplementedError("Unsupported normalizer: {}".format(p.normalizer.__name__))

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten")
        reshape = X.reshape(flatten, (0, 0, 1, 1), name="bbox_feat_reshape")

        if p.normalizer.__name__ == "fix_bn":
            fc1 = X.convrelu(reshape, filter=1024, name="bbox_fc1")
        elif p.normalizer.__name__ in ["sync_bn", "gn"]:
            fc1 = X.convnormrelu(p.normalizer, reshape, filter=1024, name="bbox_fc1")
        else:
            raise NotImplementedError("Unsupported normalizer: {}".format(p.normalizer.__name__))

        self._head_feat = fc1

        return self._head_feat
예제 #2
0
    def _get_bbox_head_logit(self, conv_feat):
        if self._head_feat is not None:
            return self._head_feat

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten")
        reshape = X.reshape(flatten, (0, 0, 1, 1), name="bbox_feat_reshape")
        fc1 = X.convrelu(reshape, filter=1024, name="bbox_fc1")
        fc2 = X.convrelu(fc1, filter=1024, name="bbox_fc2")

        self._head_feat = fc2

        return self._head_feat
예제 #3
0
파일: builder.py 프로젝트: zt706/simpledet
    def _cls_head(self, conv_feat):
        xavier_init = mx.init.Xavier(factor_type="in", rnd_type="uniform", magnitude=3)

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten")
        fc1 = X.fc(flatten, filter=1024, name="bbox_cls_fc1", init=xavier_init)
        fc1 = self.add_norm(fc1)
        fc1 = X.relu(fc1)
        fc2 = X.fc(fc1, filter=1024, name="bbox_cls_fc2", init=xavier_init)
        fc2 = self.add_norm(fc2)
        fc2 = X.relu(fc2)

        return fc2
예제 #4
0
    def _get_bbox_head_logit(self, conv_feat):
        if self._head_feat is not None:
            return self._head_feat

        xavier_init = mx.init.Xavier(factor_type="in", rnd_type="uniform", magnitude=3)

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten")
        fc1 = X.fc(flatten, filter=1024, name="bbox_fc1", init=xavier_init)
        fc1 = X.relu(fc1)
        fc2 = X.fc(fc1, filter=1024, name="bbox_fc2", init=xavier_init)
        fc2 = X.relu(fc2)

        self._head_feat = fc2

        return self._head_feat
예제 #5
0
파일: builder.py 프로젝트: zt706/simpledet
    def _get_bbox_head_logit(self, conv_feat):
        # comment this for re-infer in test stage
        # if self._head_feat is not None:
        #     return self._head_feat

        p = self.p
        stage = self.stage

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten_" + stage)
        reshape = X.reshape(flatten, (0, 0, 1, 1),
                            name="bbox_feat_reshape_" + stage)

        if p.normalizer.__name__ == "fix_bn":
            fc1 = X.convrelu(reshape,
                             filter=1024,
                             weight=self.fc1_weight,
                             bias=self.fc1_bias,
                             no_bias=False,
                             name="bbox_fc1_" + stage)
            fc2 = X.convrelu(fc1,
                             filter=1024,
                             weight=self.fc2_weight,
                             bias=self.fc2_bias,
                             no_bias=False,
                             name="bbox_fc2_" + stage)
        elif p.normalizer.__name__ in ["sync_bn", "gn"]:
            fc1 = X.convnormrelu(p.normalizer,
                                 reshape,
                                 filter=1024,
                                 weight=self.fc1_weight,
                                 bias=self.fc1_bias,
                                 no_bias=False,
                                 name="bbox_fc1_" + stage)
            fc2 = X.convnormrelu(p.normalizer,
                                 fc1,
                                 filter=1024,
                                 weight=self.fc2_weight,
                                 bias=self.fc2_bias,
                                 no_bias=False,
                                 name="bbox_fc2_" + stage)
        else:
            raise NotImplementedError("Unsupported normalizer: {}".format(
                p.normalizer.__name__))

        self._head_feat = fc2

        return self._head_feat
예제 #6
0
    def _get_output(self, mask_pred_logits, conv_feat):
        num_class = self.pBbox.num_class

        msra_init = mx.init.Xavier(rnd_type="gaussian", factor_type="out", magnitude=2)
        normal_init = mx.init.Normal(0.01)
        kaiming_uniform = mx.init.Xavier(rnd_type='uniform', factor_type='in', magnitude=3)

        mask_pred_logits = mx.sym.expand_dims(mask_pred_logits, axis=1)

        iou_head_maxpool_1 = X.pool(
            mask_pred_logits,
            name='iou_head_maxpool_1',
            kernel=2,
            stride=2,
            pad=0,
        )
        iou_head_input = X.concat([conv_feat, iou_head_maxpool_1], axis=1, name='iou_head_input')
        hi = iou_head_input
        for ii in range(3):
            hi = X.conv(
                hi,
                filter=256,
                kernel=3,
                stride=1,
                name='iou_head_conv_%d'%ii,
                no_bias=False,
                init=msra_init,
            )
            hi = X.relu(hi)
        hi = X.conv(
            hi,
            filter=256,
            kernel=3,
            stride=2,
            name='iou_head_conv_3',
            no_bias=False,
            init=msra_init
        )
        hi = X.relu(hi)
        hi = X.flatten(data=hi)
        fc1 = X.relu(X.fc(hi, filter=1024, name='iou_head_FC1', init=kaiming_uniform))
        fc2 = X.relu(X.fc(fc1, filter=1024, name='iou_head_FC2', init=kaiming_uniform))
        iou_pred_logits = X.fc(fc2, filter=num_class, name='iou_head_pred', init=normal_init)
        return iou_pred_logits
예제 #7
0
    def _get_bbox_head_logit(self, conv_feat):
        #if self._head_feat is not None:
        #    return self._head_feat

        stage = self.stage

        flatten = X.flatten(conv_feat, name="bbox_feat_flatten_" + stage)
        reshape = X.reshape(flatten, (0, 0, 1, 1),
                            name="bbox_feat_reshape_" + stage)
        fc1 = X.conv(reshape,
                     filter=1024,
                     weight=self.fc1_weight,
                     name="bbox_fc1_" + stage)
        fc1_relu = X.relu(fc1, name="bbox_fc1_relu_" + stage)
        fc2 = X.conv(fc1_relu,
                     filter=1024,
                     weight=self.fc2_weight,
                     name="bbox_fc2_" + stage)
        fc2_relu = X.relu(fc2, name="bbox_fc2_" + stage)

        self._head_feat = fc2_relu

        return self._head_feat