def test_value_error_on_predict_instance_masks_with_no_conv_hyperparms(self): with self.assertRaises(ValueError): box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, predict_instance_masks=True)
def graph_fn(image_features): mask_box_predictor = box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, ) box_predictions = mask_box_predictor.predict( [image_features], num_predictions_per_location=[1], scope='BoxPredictor', prediction_stage=2) return (box_predictions[box_predictor.BOX_ENCODINGS], box_predictions[box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND])
def graph_fn(image_features): mask_box_predictor = box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams_fn=self._build_arg_scope_with_hyperparams( op_type=hyperparams_pb2.Hyperparams.CONV), predict_instance_masks=True) box_predictions = mask_box_predictor.predict( [image_features], num_predictions_per_location=[1], scope='BoxPredictor', prediction_stage=3) return (box_predictions[box_predictor.MASK_PREDICTIONS], )
def graph_fn(image_features): mask_box_predictor = box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams_fn=self._build_arg_scope_with_hyperparams( op_type=hyperparams_pb2.Hyperparams.CONV), predict_instance_masks=True) box_predictions = mask_box_predictor.predict( [image_features], num_predictions_per_location=[1], scope='BoxPredictor', prediction_stage=3) return (box_predictions[box_predictor.MASK_PREDICTIONS],)
def test_do_not_return_instance_masks_without_request(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4) box_predictions = mask_box_predictor.predict( [image_features], num_predictions_per_location=[1], scope='BoxPredictor', prediction_stage=2) self.assertEqual(len(box_predictions), 2) self.assertTrue(box_predictor.BOX_ENCODINGS in box_predictions) self.assertTrue( box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND in box_predictions)
def test_do_not_return_instance_masks_without_request(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor_builder.build_mask_rcnn_box_predictor( is_training=False, num_classes=5, fc_hyperparams_fn=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4) box_predictions = mask_box_predictor.predict( [image_features], num_predictions_per_location=[1], scope='BoxPredictor', prediction_stage=2) self.assertEqual(len(box_predictions), 2) self.assertTrue(box_predictor.BOX_ENCODINGS in box_predictions) self.assertTrue(box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND in box_predictions)