本文整理汇总了Python中object_detection.utils.np_box_list_ops.sort_by_field方法的典型用法代码示例。如果您正苦于以下问题:Python np_box_list_ops.sort_by_field方法的具体用法?Python np_box_list_ops.sort_by_field怎么用?Python np_box_list_ops.sort_by_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.utils.np_box_list_ops
的用法示例。
在下文中一共展示了np_box_list_ops.sort_by_field方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sort_by_field
# 需要导入模块: from object_detection.utils import np_box_list_ops [as 别名]
# 或者: from object_detection.utils.np_box_list_ops import sort_by_field [as 别名]
def sort_by_field(box_mask_list, field,
order=np_box_list_ops.SortOrder.DESCEND):
"""Sort boxes and associated fields according to a scalar field.
A common use case is reordering the boxes according to descending scores.
Args:
box_mask_list: BoxMaskList holding N boxes.
field: A BoxMaskList field for sorting and reordering the BoxMaskList.
order: (Optional) 'descend' or 'ascend'. Default is descend.
Returns:
sorted_box_mask_list: A sorted BoxMaskList with the field in the specified
order.
"""
return box_list_to_box_mask_list(
np_box_list_ops.sort_by_field(
boxlist=box_mask_list, field=field, order=order))
示例2: test_with_invalid_field
# 需要导入模块: from object_detection.utils import np_box_list_ops [as 别名]
# 或者: from object_detection.utils.np_box_list_ops import sort_by_field [as 别名]
def test_with_invalid_field(self):
with self.assertRaises(ValueError):
np_box_list_ops.sort_by_field(self.boxlist, 'objectness')
with self.assertRaises(ValueError):
np_box_list_ops.sort_by_field(self.boxlist, 'labels')
示例3: test_with_invalid_sorting_order
# 需要导入模块: from object_detection.utils import np_box_list_ops [as 别名]
# 或者: from object_detection.utils.np_box_list_ops import sort_by_field [as 别名]
def test_with_invalid_sorting_order(self):
with self.assertRaises(ValueError):
np_box_list_ops.sort_by_field(self.boxlist, 'scores', 'Descending')
示例4: test_with_descending_sorting
# 需要导入模块: from object_detection.utils import np_box_list_ops [as 别名]
# 或者: from object_detection.utils.np_box_list_ops import sort_by_field [as 别名]
def test_with_descending_sorting(self):
sorted_boxlist = np_box_list_ops.sort_by_field(self.boxlist, 'scores')
expected_boxes = np.array([[14.0, 14.0, 15.0, 15.0], [3.0, 4.0, 6.0, 8.0],
[0.0, 0.0, 20.0, 20.0]],
dtype=float)
self.assertAllClose(expected_boxes, sorted_boxlist.get())
expected_scores = np.array([0.9, 0.5, 0.4], dtype=float)
self.assertAllClose(expected_scores, sorted_boxlist.get_field('scores'))
示例5: test_with_ascending_sorting
# 需要导入模块: from object_detection.utils import np_box_list_ops [as 别名]
# 或者: from object_detection.utils.np_box_list_ops import sort_by_field [as 别名]
def test_with_ascending_sorting(self):
sorted_boxlist = np_box_list_ops.sort_by_field(
self.boxlist, 'scores', np_box_list_ops.SortOrder.ASCEND)
expected_boxes = np.array([[0.0, 0.0, 20.0, 20.0],
[3.0, 4.0, 6.0, 8.0],
[14.0, 14.0, 15.0, 15.0],],
dtype=float)
self.assertAllClose(expected_boxes, sorted_boxlist.get())
expected_scores = np.array([0.4, 0.5, 0.9], dtype=float)
self.assertAllClose(expected_scores, sorted_boxlist.get_field('scores'))