本文整理汇总了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])
示例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)
示例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)
示例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])
示例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)
示例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)
示例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])