当前位置: 首页>>代码示例>>Python>>正文


Python argmax_matcher.ArgMaxMatcher方法代码示例

本文整理汇总了Python中object_detection.matchers.argmax_matcher.ArgMaxMatcher方法的典型用法代码示例。如果您正苦于以下问题:Python argmax_matcher.ArgMaxMatcher方法的具体用法?Python argmax_matcher.ArgMaxMatcher怎么用?Python argmax_matcher.ArgMaxMatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object_detection.matchers.argmax_matcher的用法示例。


在下文中一共展示了argmax_matcher.ArgMaxMatcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_return_correct_matches_with_default_thresholds

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_default_thresholds(self):
    similarity = np.array([[1., 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]])

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=None)
    expected_matched_rows = np.array([2, 0, 1, 0, 1])

    sim = tf.constant(similarity)
    match = matcher.match(sim)
    matched_cols = match.matched_column_indices()
    matched_rows = match.matched_row_indices()
    unmatched_cols = match.unmatched_column_indices()

    with self.test_session() as sess:
      res_matched_cols = sess.run(matched_cols)
      res_matched_rows = sess.run(matched_rows)
      res_unmatched_cols = sess.run(unmatched_cols)

    self.assertAllEqual(res_matched_rows, expected_matched_rows)
    self.assertAllEqual(res_matched_cols, np.arange(similarity.shape[1]))
    self.assertEmpty(res_unmatched_cols) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:argmax_matcher_test.py

示例2: test_return_correct_matches_with_matched_and_unmatched_threshold

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_matched_and_unmatched_threshold(self):
    similarity = np.array([[1, 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.int32)

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3,
                                           unmatched_threshold=2)
    expected_matched_cols = np.array([0, 3, 4])
    expected_matched_rows = np.array([2, 0, 1])
    expected_unmatched_cols = np.array([1])  # col 2 has too high maximum val

    sim = tf.constant(similarity)
    match = matcher.match(sim)
    matched_cols = match.matched_column_indices()
    matched_rows = match.matched_row_indices()
    unmatched_cols = match.unmatched_column_indices()

    with self.test_session() as sess:
      res_matched_cols = sess.run(matched_cols)
      res_matched_rows = sess.run(matched_rows)
      res_unmatched_cols = sess.run(unmatched_cols)

    self.assertAllEqual(res_matched_rows, expected_matched_rows)
    self.assertAllEqual(res_matched_cols, expected_matched_cols)
    self.assertAllEqual(res_unmatched_cols, expected_unmatched_cols) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:27,代码来源:argmax_matcher_test.py

示例3: test_build_arg_max_matcher_with_non_default_parameters

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_build_arg_max_matcher_with_non_default_parameters(self):
    matcher_text_proto = """
      argmax_matcher {
        matched_threshold: 0.7
        unmatched_threshold: 0.3
        negatives_lower_than_unmatched: false
        force_match_for_each_row: true
      }
    """
    matcher_proto = matcher_pb2.Matcher()
    text_format.Merge(matcher_text_proto, matcher_proto)
    matcher_object = matcher_builder.build(matcher_proto)
    self.assertTrue(isinstance(matcher_object, argmax_matcher.ArgMaxMatcher))
    self.assertAlmostEqual(matcher_object._matched_threshold, 0.7)
    self.assertAlmostEqual(matcher_object._unmatched_threshold, 0.3)
    self.assertFalse(matcher_object._negatives_lower_than_unmatched)
    self.assertTrue(matcher_object._force_match_for_each_row) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:matcher_builder_test.py

示例4: test_return_correct_matches_with_default_thresholds

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_default_thresholds(self):

    def graph_fn(similarity_matrix):
      matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=None)
      match = matcher.match(similarity_matrix)
      matched_cols = match.matched_column_indicator()
      unmatched_cols = match.unmatched_column_indicator()
      match_results = match.match_results
      return (matched_cols, unmatched_cols, match_results)

    similarity = np.array([[1., 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.float32)
    expected_matched_rows = np.array([2, 0, 1, 0, 1])
    (res_matched_cols, res_unmatched_cols,
     res_match_results) = self.execute(graph_fn, [similarity])

    self.assertAllEqual(res_match_results[res_matched_cols],
                        expected_matched_rows)
    self.assertAllEqual(np.nonzero(res_matched_cols)[0], [0, 1, 2, 3, 4])
    self.assertFalse(np.all(res_unmatched_cols)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:argmax_matcher_test.py

示例5: test_return_correct_matches_with_matched_threshold

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_matched_threshold(self):

    def graph_fn(similarity):
      matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3.)
      match = matcher.match(similarity)
      matched_cols = match.matched_column_indicator()
      unmatched_cols = match.unmatched_column_indicator()
      match_results = match.match_results
      return (matched_cols, unmatched_cols, match_results)

    similarity = np.array([[1, 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.float32)
    expected_matched_cols = np.array([0, 3, 4])
    expected_matched_rows = np.array([2, 0, 1])
    expected_unmatched_cols = np.array([1, 2])

    (res_matched_cols, res_unmatched_cols,
     match_results) = self.execute(graph_fn, [similarity])
    self.assertAllEqual(match_results[res_matched_cols], expected_matched_rows)
    self.assertAllEqual(np.nonzero(res_matched_cols)[0], expected_matched_cols)
    self.assertAllEqual(np.nonzero(res_unmatched_cols)[0],
                        expected_unmatched_cols) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:25,代码来源:argmax_matcher_test.py

示例6: test_return_correct_matches_with_matched_and_unmatched_threshold

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_matched_and_unmatched_threshold(self):

    def graph_fn(similarity):
      matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3.,
                                             unmatched_threshold=2.)
      match = matcher.match(similarity)
      matched_cols = match.matched_column_indicator()
      unmatched_cols = match.unmatched_column_indicator()
      match_results = match.match_results
      return (matched_cols, unmatched_cols, match_results)

    similarity = np.array([[1, 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.float32)
    expected_matched_cols = np.array([0, 3, 4])
    expected_matched_rows = np.array([2, 0, 1])
    expected_unmatched_cols = np.array([1])  # col 2 has too high maximum val

    (res_matched_cols, res_unmatched_cols,
     match_results) = self.execute(graph_fn, [similarity])
    self.assertAllEqual(match_results[res_matched_cols], expected_matched_rows)
    self.assertAllEqual(np.nonzero(res_matched_cols)[0], expected_matched_cols)
    self.assertAllEqual(np.nonzero(res_unmatched_cols)[0],
                        expected_unmatched_cols) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:26,代码来源:argmax_matcher_test.py

示例7: test_return_correct_matches_unmatched_row_while_using_force_match

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_unmatched_row_while_using_force_match(self):
    def graph_fn(similarity):
      matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3.,
                                             unmatched_threshold=2.,
                                             force_match_for_each_row=True)
      match = matcher.match(similarity)
      matched_cols = match.matched_column_indicator()
      unmatched_cols = match.unmatched_column_indicator()
      match_results = match.match_results
      return (matched_cols, unmatched_cols, match_results)

    similarity = np.array([[1, 1, 1, 3, 1],
                           [-1, 0, -2, -2, -1],
                           [3, 0, -1, 2, 0]], dtype=np.float32)
    expected_matched_cols = np.array([0, 1, 3])
    expected_matched_rows = np.array([2, 1, 0])
    expected_unmatched_cols = np.array([2, 4])  # col 2 has too high max val

    (res_matched_cols, res_unmatched_cols,
     match_results) = self.execute(graph_fn, [similarity])
    self.assertAllEqual(match_results[res_matched_cols], expected_matched_rows)
    self.assertAllEqual(np.nonzero(res_matched_cols)[0], expected_matched_cols)
    self.assertAllEqual(np.nonzero(res_unmatched_cols)[0],
                        expected_unmatched_cols) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:26,代码来源:argmax_matcher_test.py

示例8: test_build_arg_max_matcher_with_non_default_parameters

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_build_arg_max_matcher_with_non_default_parameters(self):
    matcher_text_proto = """
      argmax_matcher {
        matched_threshold: 0.7
        unmatched_threshold: 0.3
        negatives_lower_than_unmatched: false
        force_match_for_each_row: true
        use_matmul_gather: true
      }
    """
    matcher_proto = matcher_pb2.Matcher()
    text_format.Merge(matcher_text_proto, matcher_proto)
    matcher_object = matcher_builder.build(matcher_proto)
    self.assertTrue(isinstance(matcher_object, argmax_matcher.ArgMaxMatcher))
    self.assertAlmostEqual(matcher_object._matched_threshold, 0.7)
    self.assertAlmostEqual(matcher_object._unmatched_threshold, 0.3)
    self.assertFalse(matcher_object._negatives_lower_than_unmatched)
    self.assertTrue(matcher_object._force_match_for_each_row)
    self.assertTrue(matcher_object._use_matmul_gather) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:21,代码来源:matcher_builder_test.py

示例9: __init__

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def __init__(self):
    similarity_calc = region_similarity_calculator.IouSimilarity()
    matcher = argmax_matcher.ArgMaxMatcher(
        matched_threshold=ssd_constants.MATCH_THRESHOLD,
        unmatched_threshold=ssd_constants.MATCH_THRESHOLD,
        negatives_lower_than_unmatched=True,
        force_match_for_each_row=True)

    box_coder = faster_rcnn_box_coder.FasterRcnnBoxCoder(
        scale_factors=ssd_constants.BOX_CODER_SCALES)

    self.default_boxes = DefaultBoxes()('ltrb')
    self.default_boxes = box_list.BoxList(
        tf.convert_to_tensor(self.default_boxes))
    self.assigner = target_assigner.TargetAssigner(
        similarity_calc, matcher, box_coder) 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:18,代码来源:ssd_dataloader.py

示例10: test_return_correct_matches_with_empty_rows

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_empty_rows(self):

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=None)
    sim = 0.2*tf.ones([0, 5])
    match = matcher.match(sim)
    unmatched_cols = match.unmatched_column_indices()

    with self.test_session() as sess:
      res_unmatched_cols = sess.run(unmatched_cols)
      self.assertAllEqual(res_unmatched_cols, np.arange(5)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:argmax_matcher_test.py

示例11: test_return_correct_matches_with_matched_threshold

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_with_matched_threshold(self):
    similarity = np.array([[1, 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.int32)

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3)
    expected_matched_cols = np.array([0, 3, 4])
    expected_matched_rows = np.array([2, 0, 1])
    expected_unmatched_cols = np.array([1, 2])

    sim = tf.constant(similarity)
    match = matcher.match(sim)
    matched_cols = match.matched_column_indices()
    matched_rows = match.matched_row_indices()
    unmatched_cols = match.unmatched_column_indices()

    init_op = tf.global_variables_initializer()

    with self.test_session() as sess:
      sess.run(init_op)
      res_matched_cols = sess.run(matched_cols)
      res_matched_rows = sess.run(matched_rows)
      res_unmatched_cols = sess.run(unmatched_cols)

    self.assertAllEqual(res_matched_rows, expected_matched_rows)
    self.assertAllEqual(res_matched_cols, expected_matched_cols)
    self.assertAllEqual(res_unmatched_cols, expected_unmatched_cols) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:29,代码来源:argmax_matcher_test.py

示例12: test_return_correct_matches_negatives_lower_than_unmatched_false

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_negatives_lower_than_unmatched_false(self):
    similarity = np.array([[1, 1, 1, 3, 1],
                           [2, -1, 2, 0, 4],
                           [3, 0, -1, 0, 0]], dtype=np.int32)

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3,
                                           unmatched_threshold=2,
                                           negatives_lower_than_unmatched=False)
    expected_matched_cols = np.array([0, 3, 4])
    expected_matched_rows = np.array([2, 0, 1])
    expected_unmatched_cols = np.array([2])  # col 1 has too low maximum val

    sim = tf.constant(similarity)
    match = matcher.match(sim)
    matched_cols = match.matched_column_indices()
    matched_rows = match.matched_row_indices()
    unmatched_cols = match.unmatched_column_indices()

    with self.test_session() as sess:
      res_matched_cols = sess.run(matched_cols)
      res_matched_rows = sess.run(matched_rows)
      res_unmatched_cols = sess.run(unmatched_cols)

    self.assertAllEqual(res_matched_rows, expected_matched_rows)
    self.assertAllEqual(res_matched_cols, expected_matched_cols)
    self.assertAllEqual(res_unmatched_cols, expected_unmatched_cols) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:28,代码来源:argmax_matcher_test.py

示例13: test_return_correct_matches_unmatched_row_while_using_force_match

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_return_correct_matches_unmatched_row_while_using_force_match(self):
    similarity = np.array([[1, 1, 1, 3, 1],
                           [-1, 0, -2, -2, -1],
                           [3, 0, -1, 2, 0]], dtype=np.int32)

    matcher = argmax_matcher.ArgMaxMatcher(matched_threshold=3,
                                           unmatched_threshold=2,
                                           force_match_for_each_row=True)
    expected_matched_cols = np.array([0, 1, 3])
    expected_matched_rows = np.array([2, 1, 0])
    expected_unmatched_cols = np.array([2, 4])  # col 2 has too high max val

    sim = tf.constant(similarity)
    match = matcher.match(sim)
    matched_cols = match.matched_column_indices()
    matched_rows = match.matched_row_indices()
    unmatched_cols = match.unmatched_column_indices()

    with self.test_session() as sess:
      res_matched_cols = sess.run(matched_cols)
      res_matched_rows = sess.run(matched_rows)
      res_unmatched_cols = sess.run(unmatched_cols)

    self.assertAllEqual(res_matched_rows, expected_matched_rows)
    self.assertAllEqual(res_matched_cols, expected_matched_cols)
    self.assertAllEqual(res_unmatched_cols, expected_unmatched_cols) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:28,代码来源:argmax_matcher_test.py

示例14: test_valid_arguments_corner_case

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_valid_arguments_corner_case(self):
    argmax_matcher.ArgMaxMatcher(matched_threshold=1,
                                 unmatched_threshold=1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:5,代码来源:argmax_matcher_test.py

示例15: test_invalid_arguments_corner_case_negatives_lower_than_thres_false

# 需要导入模块: from object_detection.matchers import argmax_matcher [as 别名]
# 或者: from object_detection.matchers.argmax_matcher import ArgMaxMatcher [as 别名]
def test_invalid_arguments_corner_case_negatives_lower_than_thres_false(self):
    with self.assertRaises(ValueError):
      argmax_matcher.ArgMaxMatcher(matched_threshold=1,
                                   unmatched_threshold=1,
                                   negatives_lower_than_unmatched=False) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:7,代码来源:argmax_matcher_test.py


注:本文中的object_detection.matchers.argmax_matcher.ArgMaxMatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。