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


Python ops.merge_boxes_with_multiple_labels方法代码示例

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


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

示例1: testMergeBoxesWithEmptyInputs

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithEmptyInputs(self):
    boxes = tf.zeros([0, 4], dtype=tf.float32)
    class_indices = tf.constant([], dtype=tf.int32)
    class_confidences = tf.constant([], dtype=tf.float32)
    num_classes = 5
    merged_boxes, merged_classes, merged_confidences, merged_box_indices = (
        ops.merge_boxes_with_multiple_labels(
            boxes, class_indices, class_confidences, num_classes))
    with self.test_session() as sess:
      (np_merged_boxes, np_merged_classes, np_merged_confidences,
       np_merged_box_indices) = sess.run(
           [merged_boxes, merged_classes, merged_confidences,
            merged_box_indices])
      self.assertAllEqual(np_merged_boxes.shape, [0, 4])
      self.assertAllEqual(np_merged_classes.shape, [0, 5])
      self.assertAllEqual(np_merged_confidences.shape, [0, 5])
      self.assertAllEqual(np_merged_box_indices.shape, [0]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:19,代码来源:ops_test.py

示例2: testMergeBoxesWithMultipleLabels

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithMultipleLabels(self):
    boxes = tf.constant(
        [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75],
         [0.25, 0.25, 0.75, 0.75]],
        dtype=tf.float32)
    class_indices = tf.constant([0, 4, 2], dtype=tf.int32)
    num_classes = 5
    merged_boxes, merged_classes, merged_box_indices = (
        ops.merge_boxes_with_multiple_labels(boxes, class_indices, num_classes))
    expected_merged_boxes = np.array(
        [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=np.float32)
    expected_merged_classes = np.array(
        [[1, 0, 1, 0, 0], [0, 0, 0, 0, 1]], dtype=np.int32)
    expected_merged_box_indices = np.array([0, 1], dtype=np.int32)
    with self.test_session() as sess:
      np_merged_boxes, np_merged_classes, np_merged_box_indices = sess.run(
          [merged_boxes, merged_classes, merged_box_indices])
      if np_merged_classes[0, 0] != 1:
        expected_merged_boxes = expected_merged_boxes[::-1, :]
        expected_merged_classes = expected_merged_classes[::-1, :]
        expected_merged_box_indices = expected_merged_box_indices[::-1, :]
      self.assertAllClose(np_merged_boxes, expected_merged_boxes)
      self.assertAllClose(np_merged_classes, expected_merged_classes)
      self.assertAllClose(np_merged_box_indices, expected_merged_box_indices) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:26,代码来源:ops_test.py

示例3: testMergeBoxesWithMultipleLabels

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithMultipleLabels(self):
        boxes = tf.constant(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75],
             [0.25, 0.25, 0.75, 0.75]],
            dtype=tf.float32)
        class_indices = tf.constant([0, 4, 2], dtype=tf.int32)
        num_classes = 5
        merged_boxes, merged_classes, merged_box_indices = (
            ops.merge_boxes_with_multiple_labels(boxes, class_indices, num_classes))
        expected_merged_boxes = np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=np.float32)
        expected_merged_classes = np.array(
            [[1, 0, 1, 0, 0], [0, 0, 0, 0, 1]], dtype=np.int32)
        expected_merged_box_indices = np.array([0, 1], dtype=np.int32)
        with self.test_session() as sess:
            np_merged_boxes, np_merged_classes, np_merged_box_indices = sess.run(
                [merged_boxes, merged_classes, merged_box_indices])
            if np_merged_classes[0, 0] != 1:
                expected_merged_boxes = expected_merged_boxes[::-1, :]
                expected_merged_classes = expected_merged_classes[::-1, :]
                expected_merged_box_indices = expected_merged_box_indices[::-1, :]
            self.assertAllClose(np_merged_boxes, expected_merged_boxes)
            self.assertAllClose(np_merged_classes, expected_merged_classes)
            self.assertAllClose(np_merged_box_indices, expected_merged_box_indices) 
开发者ID:kujason,项目名称:monopsr,代码行数:26,代码来源:ops_test.py

示例4: testMergeBoxesWithEmptyInputs

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithEmptyInputs(self):

    def graph_fn():
      boxes = tf.zeros([0, 4], dtype=tf.float32)
      class_indices = tf.constant([], dtype=tf.int32)
      class_confidences = tf.constant([], dtype=tf.float32)
      num_classes = 5
      merged_boxes, merged_classes, merged_confidences, merged_box_indices = (
          ops.merge_boxes_with_multiple_labels(
              boxes, class_indices, class_confidences, num_classes))
      return (merged_boxes, merged_classes, merged_confidences,
              merged_box_indices)

    # Running on CPU only as tf.unique is not supported on TPU.
    (np_merged_boxes, np_merged_classes, np_merged_confidences,
     np_merged_box_indices) = self.execute_cpu(graph_fn, [])
    self.assertAllEqual(np_merged_boxes.shape, [0, 4])
    self.assertAllEqual(np_merged_classes.shape, [0, 5])
    self.assertAllEqual(np_merged_confidences.shape, [0, 5])
    self.assertAllEqual(np_merged_box_indices.shape, [0]) 
开发者ID:tensorflow,项目名称:models,代码行数:22,代码来源:ops_test.py

示例5: testMergeBoxesWithMultipleLabels

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithMultipleLabels(self):
    boxes = tf.constant(
        [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75],
         [0.25, 0.25, 0.75, 0.75]],
        dtype=tf.float32)
    class_indices = tf.constant([0, 4, 2], dtype=tf.int32)
    class_confidences = tf.constant([0.8, 0.2, 0.1], dtype=tf.float32)
    num_classes = 5
    merged_boxes, merged_classes, merged_confidences, merged_box_indices = (
        ops.merge_boxes_with_multiple_labels(
            boxes, class_indices, class_confidences, num_classes))
    expected_merged_boxes = np.array(
        [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=np.float32)
    expected_merged_classes = np.array(
        [[1, 0, 1, 0, 0], [0, 0, 0, 0, 1]], dtype=np.int32)
    expected_merged_confidences = np.array(
        [[0.8, 0, 0.1, 0, 0], [0, 0, 0, 0, 0.2]], dtype=np.float32)
    expected_merged_box_indices = np.array([0, 1], dtype=np.int32)
    with self.test_session() as sess:
      (np_merged_boxes, np_merged_classes, np_merged_confidences,
       np_merged_box_indices) = sess.run(
           [merged_boxes, merged_classes, merged_confidences,
            merged_box_indices])
      self.assertAllClose(np_merged_boxes, expected_merged_boxes)
      self.assertAllClose(np_merged_classes, expected_merged_classes)
      self.assertAllClose(np_merged_confidences, expected_merged_confidences)
      self.assertAllClose(np_merged_box_indices, expected_merged_box_indices) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:29,代码来源:ops_test.py

示例6: testMergeBoxesWithMultipleLabelsCornerCase

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithMultipleLabelsCornerCase(self):
    boxes = tf.constant(
        [[0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1],
         [1, 1, 1, 1], [1, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
        dtype=tf.float32)
    class_indices = tf.constant([0, 1, 2, 3, 2, 1, 0, 3], dtype=tf.int32)
    class_confidences = tf.constant([0.1, 0.9, 0.2, 0.8, 0.3, 0.7, 0.4, 0.6],
                                    dtype=tf.float32)
    num_classes = 4
    merged_boxes, merged_classes, merged_confidences, merged_box_indices = (
        ops.merge_boxes_with_multiple_labels(
            boxes, class_indices, class_confidences, num_classes))
    expected_merged_boxes = np.array(
        [[0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]],
        dtype=np.float32)
    expected_merged_classes = np.array(
        [[1, 0, 0, 1], [1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1]],
        dtype=np.int32)
    expected_merged_confidences = np.array(
        [[0.1, 0, 0, 0.6], [0.4, 0.9, 0, 0],
         [0, 0.7, 0.2, 0], [0, 0, 0.3, 0.8]], dtype=np.float32)
    expected_merged_box_indices = np.array([0, 1, 2, 3], dtype=np.int32)
    with self.test_session() as sess:
      (np_merged_boxes, np_merged_classes, np_merged_confidences,
       np_merged_box_indices) = sess.run(
           [merged_boxes, merged_classes, merged_confidences,
            merged_box_indices])
      self.assertAllClose(np_merged_boxes, expected_merged_boxes)
      self.assertAllClose(np_merged_classes, expected_merged_classes)
      self.assertAllClose(np_merged_confidences, expected_merged_confidences)
      self.assertAllClose(np_merged_box_indices, expected_merged_box_indices) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:33,代码来源:ops_test.py

示例7: testMergeBoxesWithEmptyInputs

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import merge_boxes_with_multiple_labels [as 别名]
def testMergeBoxesWithEmptyInputs(self):
    boxes = tf.constant([[]])
    class_indices = tf.constant([])
    num_classes = 5
    merged_boxes, merged_classes, merged_box_indices = (
        ops.merge_boxes_with_multiple_labels(boxes, class_indices, num_classes))
    with self.test_session() as sess:
      np_merged_boxes, np_merged_classes, np_merged_box_indices = sess.run(
          [merged_boxes, merged_classes, merged_box_indices])
      self.assertAllEqual(np_merged_boxes.shape, [0, 4])
      self.assertAllEqual(np_merged_classes.shape, [0, 5])
      self.assertAllEqual(np_merged_box_indices.shape, [0]) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:14,代码来源:ops_test.py


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