本文整理汇总了Python中object_detection.core.box_predictor.MASK_PREDICTIONS属性的典型用法代码示例。如果您正苦于以下问题:Python box_predictor.MASK_PREDICTIONS属性的具体用法?Python box_predictor.MASK_PREDICTIONS怎么用?Python box_predictor.MASK_PREDICTIONS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类object_detection.core.box_predictor
的用法示例。
在下文中一共展示了box_predictor.MASK_PREDICTIONS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_instance_masks
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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())
示例2: _predict_head
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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)
示例3: test_get_instance_masks
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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())
示例4: test_get_instance_masks
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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())
示例5: test_get_instance_masks
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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())
示例6: _predict
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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
示例7: predict_edgemask
# 需要导入模块: from object_detection.core import box_predictor [as 别名]
# 或者: from object_detection.core.box_predictor import MASK_PREDICTIONS [as 别名]
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