本文整理匯總了Python中object_detection.meta_architectures.faster_rcnn_meta_arch.FasterRCNNMetaArch方法的典型用法代碼示例。如果您正苦於以下問題:Python faster_rcnn_meta_arch.FasterRCNNMetaArch方法的具體用法?Python faster_rcnn_meta_arch.FasterRCNNMetaArch怎麽用?Python faster_rcnn_meta_arch.FasterRCNNMetaArch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類object_detection.meta_architectures.faster_rcnn_meta_arch
的用法示例。
在下文中一共展示了faster_rcnn_meta_arch.FasterRCNNMetaArch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_create_faster_rcnn_models_from_config
# 需要導入模塊: from object_detection.meta_architectures import faster_rcnn_meta_arch [as 別名]
# 或者: from object_detection.meta_architectures.faster_rcnn_meta_arch import FasterRCNNMetaArch [as 別名]
def test_create_faster_rcnn_models_from_config(
self, use_matmul_crop_and_resize, enable_mask_prediction):
model_proto = self.create_default_faster_rcnn_model_proto()
faster_rcnn_config = model_proto.faster_rcnn
faster_rcnn_config.use_matmul_crop_and_resize = use_matmul_crop_and_resize
if enable_mask_prediction:
faster_rcnn_config.second_stage_mask_prediction_loss_weight = 3.0
mask_predictor_config = (
faster_rcnn_config.second_stage_box_predictor.mask_rcnn_box_predictor)
mask_predictor_config.predict_instance_masks = True
for extractor_type, extractor_class in (
model_builder.FASTER_RCNN_FEATURE_EXTRACTOR_CLASS_MAP.items()):
faster_rcnn_config.feature_extractor.type = extractor_type
model = model_builder.build(model_proto, is_training=True)
self.assertIsInstance(model, faster_rcnn_meta_arch.FasterRCNNMetaArch)
self.assertIsInstance(model._feature_extractor, extractor_class)
if enable_mask_prediction:
self.assertAlmostEqual(model._second_stage_mask_loss_weight, 3.0)
開發者ID:ShivangShekhar,項目名稱:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代碼行數:21,代碼來源:model_builder_test.py
示例2: test_create_faster_rcnn_models_from_config
# 需要導入模塊: from object_detection.meta_architectures import faster_rcnn_meta_arch [as 別名]
# 或者: from object_detection.meta_architectures.faster_rcnn_meta_arch import FasterRCNNMetaArch [as 別名]
def test_create_faster_rcnn_models_from_config(self,
use_matmul_crop_and_resize,
enable_mask_prediction):
model_proto = self.create_default_faster_rcnn_model_proto()
faster_rcnn_config = model_proto.faster_rcnn
faster_rcnn_config.use_matmul_crop_and_resize = use_matmul_crop_and_resize
if enable_mask_prediction:
faster_rcnn_config.second_stage_mask_prediction_loss_weight = 3.0
mask_predictor_config = (
faster_rcnn_config.second_stage_box_predictor.mask_rcnn_box_predictor)
mask_predictor_config.predict_instance_masks = True
for extractor_type, extractor_class in (
self.faster_rcnn_feature_extractors().items()):
faster_rcnn_config.feature_extractor.type = extractor_type
model = model_builder.build(model_proto, is_training=True)
self.assertIsInstance(model, faster_rcnn_meta_arch.FasterRCNNMetaArch)
self.assertIsInstance(model._feature_extractor, extractor_class)
if enable_mask_prediction:
self.assertAlmostEqual(model._second_stage_mask_loss_weight, 3.0)
示例3: _get_model
# 需要導入模塊: from object_detection.meta_architectures import faster_rcnn_meta_arch [as 別名]
# 或者: from object_detection.meta_architectures.faster_rcnn_meta_arch import FasterRCNNMetaArch [as 別名]
def _get_model(self, box_predictor, **common_kwargs):
return faster_rcnn_meta_arch.FasterRCNNMetaArch(
initial_crop_size=3,
maxpool_kernel_size=1,
maxpool_stride=1,
second_stage_mask_rcnn_box_predictor=box_predictor,
**common_kwargs)
示例4: _compute_second_stage_input_feature_maps
# 需要導入模塊: from object_detection.meta_architectures import faster_rcnn_meta_arch [as 別名]
# 或者: from object_detection.meta_architectures.faster_rcnn_meta_arch import FasterRCNNMetaArch [as 別名]
def _compute_second_stage_input_feature_maps(self, features_to_crop,
proposal_boxes_normalized,
context_features,
valid_context_size):
"""Crops to a set of proposals from the feature map for a batch of images.
This function overrides the one in the FasterRCNNMetaArch. Aside from
cropping and resizing the feature maps, which is done in the parent class,
it adds context attention features to the box features.
Args:
features_to_crop: A float32 Tensor with shape [batch_size, height, width,
depth]
proposal_boxes_normalized: A float32 Tensor with shape [batch_size,
num_proposals, box_code_size] containing proposal boxes in normalized
coordinates.
context_features: A float Tensor of shape [batch_size, context_size,
num_context_features].
valid_context_size: A int32 Tensor of shape [batch_size].
Returns:
A float32 Tensor with shape [K, new_height, new_width, depth].
"""
box_features = self._crop_and_resize_fn(
features_to_crop, proposal_boxes_normalized,
[self._initial_crop_size, self._initial_crop_size])
attention_features = self._context_feature_extract_fn(
box_features=box_features,
context_features=context_features,
valid_context_size=valid_context_size)
# Adds box features with attention features.
box_features += attention_features
flattened_feature_maps = self._flatten_first_two_dimensions(box_features)
return self._maxpool_layer(flattened_feature_maps)
示例5: _get_model
# 需要導入模塊: from object_detection.meta_architectures import faster_rcnn_meta_arch [as 別名]
# 或者: from object_detection.meta_architectures.faster_rcnn_meta_arch import FasterRCNNMetaArch [as 別名]
def _get_model(self, box_predictor, keras_model=False, **common_kwargs):
return faster_rcnn_meta_arch.FasterRCNNMetaArch(
initial_crop_size=3,
maxpool_kernel_size=1,
maxpool_stride=1,
second_stage_mask_rcnn_box_predictor=box_predictor,
**common_kwargs)