示例#1
0
    def test_get_predictions_with_feature_maps_of_dynamic_shape(
            self):
        image_features = tf.placeholder(dtype=tf.float32, shape=[4, None, None, 64])
        conv_box_predictor = (
            box_predictor_builder.build_weight_shared_convolutional_box_predictor(
                is_training=False,
                num_classes=0,
                conv_hyperparams_fn=self._build_arg_scope_with_conv_hyperparams(),
                depth=32,
                num_layers_before_predictor=1,
                box_code_size=4))
        box_predictions = conv_box_predictor.predict(
            [image_features], num_predictions_per_location=[5],
            scope='BoxPredictor')
        box_encodings = tf.concat(box_predictions[box_predictor.BOX_ENCODINGS],
                                  axis=1)
        objectness_predictions = tf.concat(box_predictions[
                                               box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND], axis=1)
        init_op = tf.global_variables_initializer()

        resolution = 32
        expected_num_anchors = resolution * resolution * 5
        with self.test_session() as sess:
            sess.run(init_op)
            (box_encodings_shape,
             objectness_predictions_shape) = sess.run(
                [tf.shape(box_encodings), tf.shape(objectness_predictions)],
                feed_dict={image_features:
                               np.random.rand(4, resolution, resolution, 64)})
            self.assertAllEqual(box_encodings_shape, [4, expected_num_anchors, 4])
            self.assertAllEqual(objectness_predictions_shape,
                                [4, expected_num_anchors, 1])
示例#2
0
 def graph_fn(image_features):
     conv_box_predictor = (
         box_predictor_builder.build_weight_shared_convolutional_box_predictor(
             is_training=True,
             num_classes=2,
             conv_hyperparams_fn=self._build_arg_scope_with_conv_hyperparams(),
             depth=32,
             num_layers_before_predictor=1,
             class_prediction_bias_init=-4.6,
             box_code_size=4))
     box_predictions = conv_box_predictor.predict(
         [image_features], num_predictions_per_location=[5],
         scope='BoxPredictor')
     class_predictions = tf.concat(box_predictions[
                                       box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND], axis=1)
     return (tf.nn.sigmoid(class_predictions),)
示例#3
0
 def graph_fn(image_features):
     conv_box_predictor = (
         box_predictor_builder.build_weight_shared_convolutional_box_predictor(
             is_training=False,
             num_classes=0,
             conv_hyperparams_fn=self._build_arg_scope_with_conv_hyperparams(),
             depth=32,
             num_layers_before_predictor=1,
             box_code_size=4))
     box_predictions = conv_box_predictor.predict(
         [image_features], num_predictions_per_location=[5],
         scope='BoxPredictor')
     box_encodings = tf.concat(
         box_predictions[box_predictor.BOX_ENCODINGS], axis=1)
     objectness_predictions = tf.concat(box_predictions[
                                            box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND], axis=1)
     return (box_encodings, objectness_predictions)
示例#4
0
 def graph_fn(image_features1, image_features2):
     conv_box_predictor = (
         box_predictor_builder.build_weight_shared_convolutional_box_predictor(
             is_training=False,
             num_classes=num_classes_without_background,
             conv_hyperparams_fn=self._build_arg_scope_with_conv_hyperparams(),
             depth=32,
             num_layers_before_predictor=2,
             box_code_size=4,
             share_prediction_tower=True))
     box_predictions = conv_box_predictor.predict(
         [image_features1, image_features2],
         num_predictions_per_location=[5, 5],
         scope='BoxPredictor')
     box_encodings = tf.concat(
         box_predictions[box_predictor.BOX_ENCODINGS], axis=1)
     class_predictions_with_background = tf.concat(
         box_predictions[box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND],
         axis=1)
     return (box_encodings, class_predictions_with_background)