def testFPNOutputShape(self, min_level, max_level): backbone_min_level = 2 backbone_max_level = 5 fpn_feat_dims = 256 image_size = 256 inputs = {} for level in range(backbone_min_level, backbone_max_level + 1): inputs[level] = tf.zeros([ 1, image_size // 2**level, image_size // 2**level, fpn_feat_dims ]) with tf.name_scope('min_level_%d_max_level_%d' % (min_level, max_level)): fpn_fn = fpn.Fpn(min_level=min_level, max_level=max_level, fpn_feat_dims=fpn_feat_dims) features = fpn_fn(inputs) for level in range(min_level, max_level): self.assertEqual(features[level].get_shape().as_list(), [ 1, image_size // 2**level, image_size // 2**level, fpn_feat_dims ]) self.assertEqual(sorted(features.keys()), range(min_level, max_level + 1))
def multilevel_features_generator(params): """Generator function for various FPN models.""" if params.architecture.multilevel_features == 'fpn': fpn_params = params.fpn fpn_fn = fpn.Fpn(min_level=fpn_params.min_level, max_level=fpn_params.max_level, fpn_feat_dims=fpn_params.fpn_feat_dims, batch_norm_relu=batch_norm_relu_generator( fpn_params.batch_norm)) else: raise ValueError('The multi-level feature model %s is not supported.' % params.architecture.multilevel_features) return fpn_fn
def multilevel_features_generator(params): """Generator function for various FPN models.""" if params.architecture.multilevel_features == 'fpn': fpn_params = params.fpn fpn_fn = fpn.Fpn(min_level=params.architecture.min_level, max_level=params.architecture.max_level, fpn_feat_dims=fpn_params.fpn_feat_dims, use_separable_conv=fpn_params.use_separable_conv, activation=params.norm_activation.activation, use_batch_norm=fpn_params.use_batch_norm, norm_activation=norm_activation_generator( params.norm_activation)) elif params.architecture.multilevel_features == 'identity': fpn_fn = identity.Identity() else: raise ValueError( 'The multi-level feature model `{}` is not supported.'.format( params.architecture.multilevel_features)) return fpn_fn