Python object_detection.core.box_predictor.MASK_PREDICTIONS Examples
The following are 30
code examples of object_detection.core.box_predictor.MASK_PREDICTIONS().
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.core.box_predictor
, or try the search function
.
Example #1
Source File: convolutional_box_predictor.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 6 votes |
def _predict_head(self, head_name, head_obj, image_feature, box_tower_feature, feature_index, has_different_feature_channels, target_channel, inserted_layer_counter, num_predictions_per_location): if head_name == CLASS_PREDICTIONS_WITH_BACKGROUND: tower_name_scope = 'ClassPredictionTower' elif head_name == MASK_PREDICTIONS: tower_name_scope = 'MaskPredictionTower' else: raise ValueError('Unknown head') if self._share_prediction_tower: head_tower_feature = box_tower_feature else: head_tower_feature = self._compute_base_tower( tower_name_scope=tower_name_scope, image_feature=image_feature, feature_index=feature_index, has_different_feature_channels=has_different_feature_channels, target_channel=target_channel, inserted_layer_counter=inserted_layer_counter) return head_obj.predict( features=head_tower_feature, num_predictions_per_location=num_predictions_per_location)
Example #2
Source File: convolutional_box_predictor.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def _predict_head(self, head_name, head_obj, image_feature, box_tower_feature, feature_index, has_different_feature_channels, target_channel, inserted_layer_counter, num_predictions_per_location): if head_name == CLASS_PREDICTIONS_WITH_BACKGROUND: tower_name_scope = 'ClassPredictionTower' elif head_name == MASK_PREDICTIONS: tower_name_scope = 'MaskPredictionTower' else: raise ValueError('Unknown head') if self._share_prediction_tower: head_tower_feature = box_tower_feature else: head_tower_feature = self._compute_base_tower( tower_name_scope=tower_name_scope, image_feature=image_feature, feature_index=feature_index, has_different_feature_channels=has_different_feature_channels, target_channel=target_channel, inserted_layer_counter=inserted_layer_counter) return head_obj.predict( features=head_tower_feature, num_predictions_per_location=num_predictions_per_location)
Example #3
Source File: box_predictor_test.py From mtl-ssl with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #4
Source File: box_predictor_test.py From motion-rcnn with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=self._build_arg_scope_with_hyperparams( op_type=hyperparams_pb2.Hyperparams.CONV), predict_instance_masks=True, num_layers_before_mask_prediction=2) box_predictions = mask_box_predictor.predict( image_features, num_predictions_per_location=1, scope='BoxPredictor') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #5
Source File: box_predictor_test.py From AniSeg with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #6
Source File: box_predictor_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #7
Source File: box_predictor_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #8
Source File: box_predictor_test.py From Elphas with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #9
Source File: box_predictor_test.py From MBMD with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #10
Source File: box_predictor_test.py From object_detection_kitti with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #11
Source File: box_predictor_test.py From hands-detection with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #12
Source File: box_predictor_test.py From moveo_ros with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #13
Source File: box_predictor_test.py From ros_tensorflow with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( 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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #14
Source File: box_predictor_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( 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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #15
Source File: box_predictor_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #16
Source File: box_predictor_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #17
Source File: box_predictor_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( 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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #18
Source File: box_predictor_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #19
Source File: box_predictor_test.py From object_detector_app with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #20
Source File: convolutional_box_predictor.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def _predict_head(self, head_name, head_obj, image_feature, box_tower_feature, feature_index, has_different_feature_channels, target_channel, inserted_layer_counter, num_predictions_per_location): if head_name == CLASS_PREDICTIONS_WITH_BACKGROUND: tower_name_scope = 'ClassPredictionTower' elif head_name == MASK_PREDICTIONS: tower_name_scope = 'MaskPredictionTower' else: raise ValueError('Unknown head') if self._share_prediction_tower: head_tower_feature = box_tower_feature else: head_tower_feature = self._compute_base_tower( tower_name_scope=tower_name_scope, image_feature=image_feature, feature_index=feature_index, has_different_feature_channels=has_different_feature_channels, target_channel=target_channel, inserted_layer_counter=inserted_layer_counter) return head_obj.predict( features=head_tower_feature, num_predictions_per_location=num_predictions_per_location)
Example #21
Source File: box_predictor_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #22
Source File: box_predictor_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #23
Source File: box_predictor_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #24
Source File: box_predictor_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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', predict_boxes_and_classes=True, predict_auxiliary_outputs=True) mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #25
Source File: box_predictor_test.py From HereIsWally with MIT License | 6 votes |
def test_get_instance_masks(self): image_features = tf.random_uniform([2, 7, 7, 3], dtype=tf.float32) mask_box_predictor = box_predictor.MaskRCNNBoxPredictor( is_training=False, num_classes=5, fc_hyperparams=self._build_arg_scope_with_hyperparams(), use_dropout=False, dropout_keep_prob=0.5, box_code_size=4, conv_hyperparams=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') mask_predictions = box_predictions[box_predictor.MASK_PREDICTIONS] self.assertListEqual([2, 1, 5, 14, 14], mask_predictions.get_shape().as_list())
Example #26
Source File: test_utils.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def _predict(self, image_features, **kwargs): image_feature = image_features[0] combined_feature_shape = shape_utils.combined_static_and_dynamic_shape( image_feature) batch_size = combined_feature_shape[0] num_anchors = (combined_feature_shape[1] * combined_feature_shape[2]) code_size = 4 zero = tf.reduce_sum(0 * image_feature) num_class_slots = self.num_classes if self._add_background_class: num_class_slots = num_class_slots + 1 box_encodings = zero + tf.zeros( (batch_size, num_anchors, 1, code_size), dtype=tf.float32) class_predictions_with_background = zero + tf.zeros( (batch_size, num_anchors, num_class_slots), dtype=tf.float32) masks = zero + tf.zeros( (batch_size, num_anchors, self.num_classes, DEFAULT_MASK_SIZE, DEFAULT_MASK_SIZE), dtype=tf.float32) predictions_dict = { box_predictor.BOX_ENCODINGS: box_encodings, box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background } if self._predict_mask: predictions_dict[box_predictor.MASK_PREDICTIONS] = masks return predictions_dict
Example #27
Source File: test_utils.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def _predict(self, image_features, num_predictions_per_location): image_feature = image_features[0] combined_feature_shape = shape_utils.combined_static_and_dynamic_shape( image_feature) batch_size = combined_feature_shape[0] num_anchors = (combined_feature_shape[1] * combined_feature_shape[2]) code_size = 4 zero = tf.reduce_sum(0 * image_feature) num_class_slots = self.num_classes if self._add_background_class: num_class_slots = num_class_slots + 1 box_encodings = zero + tf.zeros( (batch_size, num_anchors, 1, code_size), dtype=tf.float32) class_predictions_with_background = zero + tf.zeros( (batch_size, num_anchors, num_class_slots), dtype=tf.float32) masks = zero + tf.zeros( (batch_size, num_anchors, self.num_classes, DEFAULT_MASK_SIZE, DEFAULT_MASK_SIZE), dtype=tf.float32) predictions_dict = { box_predictor.BOX_ENCODINGS: box_encodings, box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background } if self._predict_mask: predictions_dict[box_predictor.MASK_PREDICTIONS] = masks return predictions_dict
Example #28
Source File: faster_rcnn_meta_arch.py From mtl-ssl with Apache License 2.0 | 5 votes |
def predict_edgemask(self, prediction_dict): input_feature = prediction_dict['rpn_features_to_crop'] edgemask_predictions = self._edgemask_predictor.predict( input_feature, scope=self.edgemask_predictor_scope) prediction_dict['edgemask_predictions'] = edgemask_predictions[mask_predictor.MASK_PREDICTIONS] return prediction_dict
Example #29
Source File: test_utils.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def _predict(self, image_features, num_predictions_per_location): image_feature = image_features[0] combined_feature_shape = shape_utils.combined_static_and_dynamic_shape( image_feature) batch_size = combined_feature_shape[0] num_anchors = (combined_feature_shape[1] * combined_feature_shape[2]) code_size = 4 zero = tf.reduce_sum(0 * image_feature) num_class_slots = self.num_classes if self._add_background_class: num_class_slots = num_class_slots + 1 box_encodings = zero + tf.zeros( (batch_size, num_anchors, 1, code_size), dtype=tf.float32) class_predictions_with_background = zero + tf.zeros( (batch_size, num_anchors, num_class_slots), dtype=tf.float32) masks = zero + tf.zeros( (batch_size, num_anchors, self.num_classes, DEFAULT_MASK_SIZE, DEFAULT_MASK_SIZE), dtype=tf.float32) predictions_dict = { box_predictor.BOX_ENCODINGS: box_encodings, box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background } if self._predict_mask: predictions_dict[box_predictor.MASK_PREDICTIONS] = masks return predictions_dict
Example #30
Source File: test_utils.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def _predict(self, image_features, **kwargs): image_feature = image_features[0] combined_feature_shape = shape_utils.combined_static_and_dynamic_shape( image_feature) batch_size = combined_feature_shape[0] num_anchors = (combined_feature_shape[1] * combined_feature_shape[2]) code_size = 4 zero = tf.reduce_sum(0 * image_feature) num_class_slots = self.num_classes if self._add_background_class: num_class_slots = num_class_slots + 1 box_encodings = zero + tf.zeros( (batch_size, num_anchors, 1, code_size), dtype=tf.float32) class_predictions_with_background = zero + tf.zeros( (batch_size, num_anchors, num_class_slots), dtype=tf.float32) masks = zero + tf.zeros( (batch_size, num_anchors, self.num_classes, DEFAULT_MASK_SIZE, DEFAULT_MASK_SIZE), dtype=tf.float32) predictions_dict = { box_predictor.BOX_ENCODINGS: box_encodings, box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background } if self._predict_mask: predictions_dict[box_predictor.MASK_PREDICTIONS] = masks return predictions_dict