Python object_detection.protos.box_predictor_pb2.BoxPredictor() Examples
The following are 30
code examples of object_detection.protos.box_predictor_pb2.BoxPredictor().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
object_detection.protos.box_predictor_pb2
, or try the search function
.
Example #1
Source File: box_predictor_builder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #2
Source File: faster_rcnn_meta_arch_test_lib.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def _get_second_stage_box_predictor(self, num_classes, is_training, predict_masks, masks_are_class_agnostic): box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(self._get_second_stage_box_predictor_text_proto(), box_predictor_proto) if predict_masks: text_format.Merge( self._add_mask_to_second_stage_box_predictor_text_proto( masks_are_class_agnostic), box_predictor_proto) return box_predictor_builder.build( hyperparams_builder.build, box_predictor_proto, num_classes=num_classes, is_training=is_training)
Example #3
Source File: box_predictor_builder.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def build_score_converter(score_converter_config, is_training): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid] score converters based on the config and whether the BoxPredictor is for training or inference. Args: score_converter_config: box_predictor_pb2.WeightSharedConvolutionalBoxPredictor.score_converter. is_training: Indicates whether the BoxPredictor is in training mode. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == ( box_predictor_pb2.WeightSharedConvolutionalBoxPredictor.IDENTITY): return tf.identity if score_converter_config == ( box_predictor_pb2.WeightSharedConvolutionalBoxPredictor.SIGMOID): return tf.identity if is_training else tf.sigmoid raise ValueError('Unknown score converter.')
Example #4
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_construct_default_conv_box_predictor(self): box_predictor_text_proto = """ weight_shared_convolutional_box_predictor { conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor._depth, 0) self.assertEqual(box_predictor._num_layers_before_predictor, 0) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training)
Example #5
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #6
Source File: box_predictor_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #7
Source File: faster_rcnn_meta_arch_test_lib.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def _get_second_stage_box_predictor(self, num_classes, is_training, predict_masks, masks_are_class_agnostic): box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(self._get_second_stage_box_predictor_text_proto(), box_predictor_proto) if predict_masks: text_format.Merge( self._add_mask_to_second_stage_box_predictor_text_proto( masks_are_class_agnostic), box_predictor_proto) return box_predictor_builder.build( hyperparams_builder.build, box_predictor_proto, num_classes=num_classes, is_training=is_training)
Example #8
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_construct_default_conv_box_predictor(self): box_predictor_text_proto = """ weight_shared_convolutional_box_predictor { conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor._depth, 0) self.assertEqual(box_predictor._num_layers_before_predictor, 0) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training)
Example #9
Source File: box_predictor_builder_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #10
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #11
Source File: box_predictor_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) box_head = box_predictor._box_prediction_head class_head = box_predictor._class_prediction_head self.assertFalse(box_head._use_dropout) self.assertFalse(class_head._use_dropout) self.assertAlmostEqual(box_head._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_head._box_code_size, 4) self.assertEqual(len(box_predictor._third_stage_heads.keys()), 0)
Example #12
Source File: box_predictor_builder_test.py From HereIsWally with MIT License | 6 votes |
def test_build_default_mask_rcnn_box_predictor(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor = box_predictor_builder.build( argscope_fn=mock.Mock(return_value='arg_scope'), box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertFalse(box_predictor._predict_instance_masks) self.assertFalse(box_predictor._predict_keypoints)
Example #13
Source File: box_predictor_builder_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_construct_weight_shared_predictor_with_custom_mask_head(self): box_predictor_text_proto = """ weight_shared_convolutional_box_predictor { mask_head { mask_height: 7 mask_width: 7 masks_are_class_agnostic: false } conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertTrue(convolutional_box_predictor.MASK_PREDICTIONS in box_predictor._other_heads) weight_shared_convolutional_mask_head = ( box_predictor._other_heads[convolutional_box_predictor.MASK_PREDICTIONS] ) self.assertIsInstance(weight_shared_convolutional_mask_head, mask_head.WeightSharedConvolutionalMaskHead) self.assertEqual(weight_shared_convolutional_mask_head._mask_height, 7) self.assertEqual(weight_shared_convolutional_mask_head._mask_width, 7) self.assertFalse( weight_shared_convolutional_mask_head._masks_are_class_agnostic)
Example #14
Source File: box_predictor_builder_test.py From garbage-object-detection-tensorflow with MIT License | 5 votes |
def test_box_predictor_builder_calls_fc_argscope_fn(self): fc_hyperparams_text_proto = """ regularizer { l1_regularizer { weight: 0.0003 } } initializer { truncated_normal_initializer { mean: 0.0 stddev: 0.3 } } activation: RELU_6 op: FC """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(fc_hyperparams_text_proto, hyperparams_proto) box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.CopyFrom( hyperparams_proto) mock_argscope_fn = mock.Mock(return_value='arg_scope') box_predictor = box_predictor_builder.build( argscope_fn=mock_argscope_fn, box_predictor_config=box_predictor_proto, is_training=False, num_classes=10) mock_argscope_fn.assert_called_with(hyperparams_proto, False) self.assertEqual(box_predictor._fc_hyperparams, 'arg_scope')
Example #15
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def test_non_default_mask_rcnn_box_predictor(self): fc_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 op: FC """ box_predictor_text_proto = """ mask_rcnn_box_predictor { use_dropout: true dropout_keep_probability: 0.8 box_code_size: 3 } """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(fc_hyperparams_text_proto, hyperparams_proto) def mock_fc_argscope_builder(fc_hyperparams_arg, is_training): return (fc_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_fc_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertTrue(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.8) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 3)
Example #16
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def test_non_default_rfcn_box_predictor(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 """ box_predictor_text_proto = """ rfcn_box_predictor { num_spatial_bins_height: 4 num_spatial_bins_width: 4 depth: 4 box_code_size: 3 crop_height: 16 crop_width: 16 } """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, hyperparams_proto) def mock_conv_argscope_builder(conv_hyperparams_arg, is_training): return (conv_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor_proto.rfcn_box_predictor.conv_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_conv_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 3) self.assertEqual(box_predictor._num_spatial_bins, [4, 4]) self.assertEqual(box_predictor._crop_size, [16, 16])
Example #17
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_default_rfcn_box_predictor(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, hyperparams_proto) def mock_conv_argscope_builder(conv_hyperparams_arg, is_training): return (conv_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.rfcn_box_predictor.conv_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_conv_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertEqual(box_predictor._num_spatial_bins, [3, 3]) self.assertEqual(box_predictor._crop_size, [12, 12])
Example #18
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_box_predictor_builder_calls_fc_argscope_fn(self): fc_hyperparams_text_proto = """ regularizer { l1_regularizer { weight: 0.0003 } } initializer { truncated_normal_initializer { mean: 0.0 stddev: 0.3 } } activation: RELU_6 op: FC """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(fc_hyperparams_text_proto, hyperparams_proto) box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.CopyFrom( hyperparams_proto) mock_argscope_fn = mock.Mock(return_value='arg_scope') box_predictor = box_predictor_builder.build( argscope_fn=mock_argscope_fn, box_predictor_config=box_predictor_proto, is_training=False, num_classes=10) mock_argscope_fn.assert_called_with(hyperparams_proto, False) self.assertEqual(box_predictor._fc_hyperparams_fn, 'arg_scope')
Example #19
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_non_default_mask_rcnn_box_predictor(self): fc_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 op: FC """ box_predictor_text_proto = """ mask_rcnn_box_predictor { use_dropout: true dropout_keep_probability: 0.8 box_code_size: 3 share_box_across_classes: true } """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(fc_hyperparams_text_proto, hyperparams_proto) def mock_fc_argscope_builder(fc_hyperparams_arg, is_training): return (fc_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_fc_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertTrue(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.8) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 3) self.assertEqual(box_predictor._share_box_across_classes, True)
Example #20
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_build_box_predictor_with_mask_branch(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams.op = ( hyperparams_pb2.Hyperparams.CONV) box_predictor_proto.mask_rcnn_box_predictor.predict_instance_masks = True box_predictor_proto.mask_rcnn_box_predictor.mask_prediction_conv_depth = 512 box_predictor_proto.mask_rcnn_box_predictor.mask_height = 16 box_predictor_proto.mask_rcnn_box_predictor.mask_width = 16 mock_argscope_fn = mock.Mock(return_value='arg_scope') box_predictor = box_predictor_builder.build( argscope_fn=mock_argscope_fn, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) mock_argscope_fn.assert_has_calls( [mock.call(box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams, True), mock.call(box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams, True)], any_order=True) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertTrue(box_predictor._predict_instance_masks) self.assertEqual(box_predictor._mask_prediction_conv_depth, 512) self.assertFalse(box_predictor._predict_keypoints)
Example #21
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_non_default_rfcn_box_predictor(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 """ box_predictor_text_proto = """ rfcn_box_predictor { num_spatial_bins_height: 4 num_spatial_bins_width: 4 depth: 4 box_code_size: 3 crop_height: 16 crop_width: 16 } """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, hyperparams_proto) def mock_conv_argscope_builder(conv_hyperparams_arg, is_training): return (conv_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor_proto.rfcn_box_predictor.conv_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_conv_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 3) self.assertEqual(box_predictor._num_spatial_bins, [4, 4]) self.assertEqual(box_predictor._crop_size, [16, 16])
Example #22
Source File: box_predictor_builder_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def test_construct_default_conv_box_predictor(self): box_predictor_text_proto = """ convolutional_box_predictor { conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor._min_depth, 0) self.assertEqual(box_predictor._max_depth, 0) self.assertEqual(box_predictor._num_layers_before_predictor, 0) self.assertTrue(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.8) self.assertFalse(box_predictor._apply_sigmoid_to_scores) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertFalse(box_predictor._use_depthwise)
Example #23
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def test_build_box_predictor_with_mask_branch(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams.op = ( hyperparams_pb2.Hyperparams.CONV) box_predictor_proto.mask_rcnn_box_predictor.predict_instance_masks = True box_predictor_proto.mask_rcnn_box_predictor.mask_prediction_conv_depth = 512 box_predictor_proto.mask_rcnn_box_predictor.mask_height = 16 box_predictor_proto.mask_rcnn_box_predictor.mask_width = 16 mock_argscope_fn = mock.Mock(return_value='arg_scope') box_predictor = box_predictor_builder.build( argscope_fn=mock_argscope_fn, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) mock_argscope_fn.assert_has_calls( [mock.call(box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams, True), mock.call(box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams, True)], any_order=True) self.assertFalse(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertTrue(box_predictor._predict_instance_masks) self.assertEqual(box_predictor._mask_prediction_conv_depth, 512) self.assertFalse(box_predictor._predict_keypoints)
Example #24
Source File: box_predictor_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def test_construct_default_conv_box_predictor(self): box_predictor_text_proto = """ convolutional_box_predictor { conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor._min_depth, 0) self.assertEqual(box_predictor._max_depth, 0) self.assertEqual(box_predictor._num_layers_before_predictor, 0) self.assertTrue(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.8) self.assertFalse(box_predictor._apply_sigmoid_to_scores) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertFalse(box_predictor._use_depthwise)
Example #25
Source File: box_predictor_builder_test.py From garbage-object-detection-tensorflow with MIT License | 5 votes |
def test_construct_default_conv_box_predictor(self): box_predictor_text_proto = """ convolutional_box_predictor { conv_hyperparams { regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } } }""" box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor = box_predictor_builder.build( argscope_fn=hyperparams_builder.build, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor._min_depth, 0) self.assertEqual(box_predictor._max_depth, 0) self.assertEqual(box_predictor._num_layers_before_predictor, 0) self.assertTrue(box_predictor._use_dropout) self.assertAlmostEqual(box_predictor._dropout_keep_prob, 0.8) self.assertFalse(box_predictor._apply_sigmoid_to_scores) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training)
Example #26
Source File: faster_rcnn_meta_arch_test_lib.py From DOTA_models with Apache License 2.0 | 5 votes |
def _get_second_stage_box_predictor(self, num_classes, is_training): box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(self._get_second_stage_box_predictor_text_proto(), box_predictor_proto) return box_predictor_builder.build( hyperparams_builder.build, box_predictor_proto, num_classes=num_classes, is_training=is_training)
Example #27
Source File: box_predictor_builder_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_build_box_predictor_with_convlve_then_upsample_masks(self): box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams.op = ( hyperparams_pb2.Hyperparams.FC) box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams.op = ( hyperparams_pb2.Hyperparams.CONV) box_predictor_proto.mask_rcnn_box_predictor.predict_instance_masks = True box_predictor_proto.mask_rcnn_box_predictor.mask_prediction_conv_depth = 512 box_predictor_proto.mask_rcnn_box_predictor.mask_height = 24 box_predictor_proto.mask_rcnn_box_predictor.mask_width = 24 box_predictor_proto.mask_rcnn_box_predictor.convolve_then_upsample_masks = ( True) mock_argscope_fn = mock.Mock(return_value='arg_scope') box_predictor = box_predictor_builder.build( argscope_fn=mock_argscope_fn, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) mock_argscope_fn.assert_has_calls( [mock.call(box_predictor_proto.mask_rcnn_box_predictor.fc_hyperparams, True), mock.call(box_predictor_proto.mask_rcnn_box_predictor.conv_hyperparams, True)], any_order=True) box_head = box_predictor._box_prediction_head class_head = box_predictor._class_prediction_head third_stage_heads = box_predictor._third_stage_heads self.assertFalse(box_head._use_dropout) self.assertFalse(class_head._use_dropout) self.assertAlmostEqual(box_head._dropout_keep_prob, 0.5) self.assertAlmostEqual(class_head._dropout_keep_prob, 0.5) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_head._box_code_size, 4) self.assertTrue( mask_rcnn_box_predictor.MASK_PREDICTIONS in third_stage_heads) self.assertEqual( third_stage_heads[mask_rcnn_box_predictor.MASK_PREDICTIONS] ._mask_prediction_conv_depth, 512) self.assertTrue(third_stage_heads[mask_rcnn_box_predictor.MASK_PREDICTIONS] ._convolve_then_upsample)
Example #28
Source File: faster_rcnn_meta_arch_test_lib.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def _get_second_stage_box_predictor(self, num_classes, is_training, predict_masks): box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(self._get_second_stage_box_predictor_text_proto(), box_predictor_proto) if predict_masks: text_format.Merge( self._add_mask_to_second_stage_box_predictor_text_proto(), box_predictor_proto) return box_predictor_builder.build( hyperparams_builder.build, box_predictor_proto, num_classes=num_classes, is_training=is_training)
Example #29
Source File: box_predictor_builder_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_default_rfcn_box_predictor(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, hyperparams_proto) def mock_conv_argscope_builder(conv_hyperparams_arg, is_training): return (conv_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() box_predictor_proto.rfcn_box_predictor.conv_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_conv_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 4) self.assertEqual(box_predictor._num_spatial_bins, [3, 3]) self.assertEqual(box_predictor._crop_size, [12, 12])
Example #30
Source File: box_predictor_builder_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_non_default_rfcn_box_predictor(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } activation: RELU_6 """ box_predictor_text_proto = """ rfcn_box_predictor { num_spatial_bins_height: 4 num_spatial_bins_width: 4 depth: 4 box_code_size: 3 crop_height: 16 crop_width: 16 } """ hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, hyperparams_proto) def mock_conv_argscope_builder(conv_hyperparams_arg, is_training): return (conv_hyperparams_arg, is_training) box_predictor_proto = box_predictor_pb2.BoxPredictor() text_format.Merge(box_predictor_text_proto, box_predictor_proto) box_predictor_proto.rfcn_box_predictor.conv_hyperparams.CopyFrom( hyperparams_proto) box_predictor = box_predictor_builder.build( argscope_fn=mock_conv_argscope_builder, box_predictor_config=box_predictor_proto, is_training=True, num_classes=90) self.assertEqual(box_predictor.num_classes, 90) self.assertTrue(box_predictor._is_training) self.assertEqual(box_predictor._box_code_size, 3) self.assertEqual(box_predictor._num_spatial_bins, [4, 4]) self.assertEqual(box_predictor._crop_size, [16, 16])