Exemplo n.º 1
0
    def _network(self):
        # There shouldn't be any gt_boxes if in evaluation mode
        if self.eval_mode is True:
            assert self.gt_boxes is None, \
                'Evaluation mode should not have ground truth boxes (or else what are you detecting for?)'

        _num_anchors = len(self.anchor_scales)*3

        rpn_layers = Layers(self.featureMaps)

        with tf.variable_scope('rpn'):
            # Spatial windowing
            for i in range(len(cfg.RPN_OUTPUT_CHANNELS)):
                rpn_layers.conv2d(filter_size=cfg.RPN_FILTER_SIZES[i], output_channels=cfg.RPN_OUTPUT_CHANNELS[i])
                
            features = rpn_layers.get_output()

            with tf.variable_scope('cls'):
                # Box-classification layer (objectness)
                self.rpn_bbox_cls_layers = Layers(features)
                self.rpn_bbox_cls_layers.conv2d(filter_size=1, output_channels=_num_anchors*2, activation_fn=None)

            with tf.variable_scope('target'):
                # Only calculate targets in train mode. No ground truth boxes in evaluation mode
                if self.eval_mode is False:
                    # Anchor Target Layer (anchors and deltas)
                    rpn_cls_score = self.rpn_bbox_cls_layers.get_output()
                    self.rpn_labels, self.rpn_bbox_targets, self.rpn_bbox_inside_weights, self.rpn_bbox_outside_weights = \
                        anchor_target_layer(rpn_cls_score=rpn_cls_score, gt_boxes=self.gt_boxes, im_dims=self.im_dims,
                                            _feat_stride=self._feat_stride, anchor_scales=self.anchor_scales)

            with tf.variable_scope('bbox'):
                # Bounding-Box regression layer (bounding box predictions)
                self.rpn_bbox_pred_layers = Layers(features)
                self.rpn_bbox_pred_layers.conv2d(filter_size=1, output_channels=_num_anchors*4, activation_fn=None)
Exemplo n.º 2
0
    def _network(self):
        # There shouldn't be any gt_boxes if in evaluation mode
        if self.eval_mode is True:
            assert self.gt_boxes is None, \
                'Evaluation mode should not have ground truth boxes (or else what are you detecting for?)'

        _num_anchors = len(self.anchor_scales) * 3

        features = self.featureMaps
        with tf.variable_scope('rpn'):
            # Spatial windowing
            for i in range(len(cfg.RPN_OUTPUT_CHANNELS)):
                # 2D Conv -> Batch Normalization -> ReLU
                features = tcl.conv2d(
                    inputs=features,
                    num_outputs=cfg.RPN_OUTPUT_CHANNELS[i],
                    kernel_size=cfg.RPN_FILTER_SIZES[i],
                    activation_fn=tf.nn.relu,
                    normalizer_fn=tcl.batch_norm,
                    normalizer_params={'is_training': not self.eval_mode})

            # Box-classification layer (objectness)
            with tf.variable_scope('cls'):
                # Only 2D Conv
                self.rpn_cls_score = tcl.conv2d(inputs=features,
                                                num_outputs=_num_anchors * 2,
                                                kernel_size=1,
                                                activation_fn=None)

            # Anchor Target Layer (anchors and deltas)
            with tf.variable_scope('target'):
                # Only calculate targets in train mode. No ground truth boxes in evaluation mode
                if self.eval_mode is False:
                    self.rpn_labels, self.rpn_bbox_targets, self.rpn_bbox_inside_weights, self.rpn_bbox_outside_weights = \
                        anchor_target_layer(rpn_cls_score=self.rpn_cls_score, gt_boxes=self.gt_boxes, im_dims=self.im_dims,
                                            _feat_stride=self._feat_stride, anchor_scales=self.anchor_scales)

            # Bounding-Box regression layer (bounding box predictions)
            with tf.variable_scope('bbox'):
                # Only 2D Conv
                self.rpn_bbox_pred = tcl.conv2d(inputs=features,
                                                num_outputs=_num_anchors * 4,
                                                kernel_size=1,
                                                activation_fn=None)
Exemplo n.º 3
0
    def _network(self):
        # There shouldn't be any gt_boxes if in evaluation mode
        if self.eval_mode is True:
            assert self.gt_boxes is None, \
                'Evaluation mode should not have ground truth boxes (or else what are you detecting for?)'

        _num_anchors = len(self.anchor_scales) * 1

        rpn_layers = Layers(self.featureMaps)

        with tf.variable_scope('rpn'):
            # Spatial windowing
            for i in range(len(cfg.RPN_OUTPUT_CHANNELS)):
                rpn_layers.conv2d(filter_size=cfg.RPN_FILTER_SIZES[i],
                                  output_channels=cfg.RPN_OUTPUT_CHANNELS[i])

            features = rpn_layers.get_output()

            with tf.variable_scope('cls'):
                # Box-classification layer (objectness)
                self.rpn_bbox_cls_layers = Layers(features)
                self.rpn_bbox_cls_layers.conv2d(filter_size=1,
                                                output_channels=_num_anchors *
                                                2,
                                                activation_fn=None)

            with tf.variable_scope('target'):
                # Only calculate targets in train mode. No ground truth boxes in evaluation mode
                if self.eval_mode is False:
                    print(anchor_target_layer)
                    # Anchor Target Layer (anchors and deltas)
                    rpn_cls_score = self.rpn_bbox_cls_layers.get_output()
                    self.rpn_labels, self.rpn_bbox_targets, self.rpn_bbox_inside_weights, self.rpn_bbox_outside_weights = \
                        anchor_target_layer(rpn_cls_score=rpn_cls_score, gt_boxes=self.gt_boxes, im_dims=self.im_dims,
                                            _feat_stride=self._feat_stride, anchor_scales=self.anchor_scales)

            with tf.variable_scope('bbox'):
                # Bounding-Box regression layer (bounding box predictions)
                self.rpn_bbox_pred_layers = Layers(features)
                self.rpn_bbox_pred_layers.conv2d(filter_size=1,
                                                 output_channels=_num_anchors *
                                                 4,
                                                 activation_fn=None)
 def _network(self):
     _num_anchors = len(self.flags['anchor_scales'])*3    
     
     rpn_layers = Layers(self.featureMaps)
     
     with tf.variable_scope('rpn'):
         # Spatial windowing
         rpn_layers.conv2d(filter_size=3,output_channels=512)
         features = rpn_layers.get_output()
         
         with tf.variable_scope('bbox'):
         # Box-classification layer (objectness)
             self.rpn_bbox_cls_layers = Layers(features)
             self.rpn_bbox_cls_layers.conv2d(filter_size=1,output_channels=_num_anchors*2,activation_fn=None)        
         
             # Anchor Target Layer (anchors and deltas)
             rpn_cls_score = self.rpn_bbox_cls_layers.get_output()
             self.rpn_labels,self.rpn_bbox_targets,self.rpn_bbox_inside_weights,self.rpn_bbox_outside_weights = \
                 anchor_target_layer(rpn_cls_score=rpn_cls_score,gt_boxes=self.gt_boxes,im_dims=self.im_dims,_feat_stride=self._feat_stride,anchor_scales=self.flags['anchor_scales'])       
         
         with tf.variable_scope('cls'):
         # Bounding-Box regression layer (bounding box predictions)
             self.rpn_bbox_pred_layers = Layers(features)
             self.rpn_bbox_pred_layers.conv2d(filter_size=1,output_channels=_num_anchors*4,activation_fn=None)