當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。