Exemple #1
0
    def make_anchors(self):
        '''
        :return: [-1,4] ,all level's anchors
        '''
        with tf.variable_scope('make_anchors'):
            anchor_list = []

            with tf.name_scope('make_anchors_all_level'):
                for level, base_anchor_size, stride in zip(
                        self.level, self.base_anchor_size_list, self.stride):

                    feature_map_shape = tf.shape(self.feature_pyramid[level])
                    feature_h, feature_w = feature_map_shape[
                        1], feature_map_shape[2]

                    temp_anchors = make_anchor.make_anchors(
                        base_anchor_size,
                        self.anchor_scales,
                        self.anchor_ratios,
                        feature_h,
                        feature_w,
                        stride,
                        name='make_anchor_{}'.format(level))
                    temp_anchors = tf.reshape(temp_anchors, [-1, 4])
                    anchor_list.append(temp_anchors)

                all_level_anchors = tf.concat(anchor_list, axis=0)
                return all_level_anchors
    def make_anchors(self):
        with tf.variable_scope('make_anchors'):
            anchor_list = []
            level_list = self.level
            with tf.name_scope('make_anchors_all_level'):
                for level, base_anchor_size, stride in zip(level_list, self.base_anchor_size_list, self.stride):
                    '''
                    (level, base_anchor_size) tuple:
                    (P2, 32), (P3, 64), (P4, 128), (P5, 256), (P6, 512)
                    '''
                    featuremap_height, featuremap_width = tf.shape(self.feature_pyramid[level])[1], \
                                                          tf.shape(self.feature_pyramid[level])[2]
                    # stride = base_anchor_size / 8.

                    # tmp_anchors = tf.py_func(
                    #     anchor_utils_pyfunc.make_anchors,
                    #     inp=[base_anchor_size, self.anchor_scales, self.anchor_ratios,
                    #          featuremap_height, featuremap_width, stride],
                    #     Tout=tf.float32
                    # )

                    tmp_anchors = make_anchor.make_anchors(base_anchor_size, self.anchor_scales, self.anchor_ratios,
                                                           featuremap_height,  featuremap_width, stride,
                                                           name='make_anchors_{}'.format(level))
                    tmp_anchors = tf.reshape(tmp_anchors, [-1, 4])
                    anchor_list.append(tmp_anchors)

                all_level_anchors = tf.concat(anchor_list, axis=0)
            return all_level_anchors
Exemple #3
0
    def make_anchors(self):
        with tf.variable_scope('make_anchors'):
            anchor_list = []
            level_list = self.level
            with tf.name_scope('make_anchors_all_level'):
                for level, base_anchor_size, stride in zip(
                        level_list, self.base_anchor_size_list, self.stride):
                    '''
          (level, base_anchor_size) tuple:   
          (P2, 32), (P3, 64), (P4, 128), (P5, 256), (P6, 512)
          base_anchor_size [15, 25, 40, 60, 80],,LEVEL = ['P2', 'P3', 'P4', 'P5', "P6"],,STRIDE = [4, 8, 16, 32, 64]
          in small feature map, anchors one by one,dense; in higher feature map, anchors gap by stride   ---bob
          '''
                    featuremap_height, featuremap_width = tf.shape(self.feature_pyramid[level])[1], \
                                                          tf.shape(self.feature_pyramid[level])[2]
                    # stride = base_anchor_size / 8.

                    # tmp_anchors = tf.py_func(
                    #     anchor_utils_pyfunc.make_anchors,
                    #     inp=[base_anchor_size, self.anchor_scales, self.anchor_ratios,
                    #          featuremap_height, featuremap_width, stride],
                    #     Tout=tf.float32
                    # )

                    tmp_anchors = make_anchor.make_anchors(
                        base_anchor_size,
                        self.anchor_scales,
                        self.anchor_ratios,
                        featuremap_height,
                        featuremap_width,
                        stride,
                        name='make_anchors_{}'.format(level))
                    tmp_anchors = tf.reshape(tmp_anchors, [-1, 4])
                    anchor_list.append(tmp_anchors)

                all_level_anchors = tf.concat(anchor_list, axis=0)
            return all_level_anchors