當前位置: 首頁>>代碼示例>>Python>>正文


Python box_predictor_builder.build_mask_rcnn_box_predictor方法代碼示例

本文整理匯總了Python中object_detection.builders.box_predictor_builder.build_mask_rcnn_box_predictor方法的典型用法代碼示例。如果您正苦於以下問題:Python box_predictor_builder.build_mask_rcnn_box_predictor方法的具體用法?Python box_predictor_builder.build_mask_rcnn_box_predictor怎麽用?Python box_predictor_builder.build_mask_rcnn_box_predictor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在object_detection.builders.box_predictor_builder的用法示例。


在下文中一共展示了box_predictor_builder.build_mask_rcnn_box_predictor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_boxes_with_five_classes

# 需要導入模塊: from object_detection.builders import box_predictor_builder [as 別名]
# 或者: from object_detection.builders.box_predictor_builder import build_mask_rcnn_box_predictor [as 別名]
def test_get_boxes_with_five_classes(self):
    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])
    image_features = np.random.rand(2, 7, 7, 3).astype(np.float32)
    (box_encodings,
     class_predictions_with_background) = self.execute(graph_fn,
                                                       [image_features])
    self.assertAllEqual(box_encodings.shape, [2, 1, 5, 4])
    self.assertAllEqual(class_predictions_with_background.shape, [2, 1, 6]) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:25,代碼來源:mask_rcnn_box_predictor_test.py

示例2: test_get_boxes_with_five_classes_share_box_across_classes

# 需要導入模塊: from object_detection.builders import box_predictor_builder [as 別名]
# 或者: from object_detection.builders.box_predictor_builder import build_mask_rcnn_box_predictor [as 別名]
def test_get_boxes_with_five_classes_share_box_across_classes(self):
    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,
          share_box_across_classes=True
      )
      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])
    image_features = np.random.rand(2, 7, 7, 3).astype(np.float32)
    (box_encodings,
     class_predictions_with_background) = self.execute(graph_fn,
                                                       [image_features])
    self.assertAllEqual(box_encodings.shape, [2, 1, 1, 4])
    self.assertAllEqual(class_predictions_with_background.shape, [2, 1, 6]) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:26,代碼來源:mask_rcnn_box_predictor_test.py

示例3: test_get_instance_masks

# 需要導入模塊: from object_detection.builders import box_predictor_builder [as 別名]
# 或者: from object_detection.builders.box_predictor_builder import build_mask_rcnn_box_predictor [as 別名]
def test_get_instance_masks(self):
    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],)
    image_features = np.random.rand(2, 7, 7, 3).astype(np.float32)
    mask_predictions = self.execute(graph_fn, [image_features])
    self.assertAllEqual(mask_predictions.shape, [2, 1, 5, 14, 14]) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:23,代碼來源:mask_rcnn_box_predictor_test.py

示例4: test_do_not_return_instance_masks_without_request

# 需要導入模塊: from object_detection.builders import box_predictor_builder [as 別名]
# 或者: from object_detection.builders.box_predictor_builder import build_mask_rcnn_box_predictor [as 別名]
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) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:20,代碼來源:mask_rcnn_box_predictor_test.py

示例5: test_value_error_on_predict_instance_masks_with_no_conv_hyperparms

# 需要導入模塊: from object_detection.builders import box_predictor_builder [as 別名]
# 或者: from object_detection.builders.box_predictor_builder import build_mask_rcnn_box_predictor [as 別名]
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) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:12,代碼來源:mask_rcnn_box_predictor_test.py


注:本文中的object_detection.builders.box_predictor_builder.build_mask_rcnn_box_predictor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。