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


Python np_box_list.BoxList方法代码示例

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


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

示例1: test_concatenate

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_concatenate(self):
    boxlist1 = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    boxlist2 = np_box_list.BoxList(
        np.array(
            [[0.5, 0.25, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]], dtype=np.float32))
    boxlists = [boxlist1, boxlist2]
    boxlist_concatenated = np_box_list_ops.concatenate(boxlists)
    boxlist_concatenated_expected = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75],
             [0.5, 0.25, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]],
            dtype=np.float32))
    self.assertAllClose(boxlist_concatenated_expected.get(),
                        boxlist_concatenated.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:np_box_list_ops_test.py

示例2: scale

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def scale(boxlist, y_scale, x_scale):
  """Scale box coordinates in x and y dimensions.

  Args:
    boxlist: BoxList holding N boxes
    y_scale: float
    x_scale: float

  Returns:
    boxlist: BoxList holding N boxes
  """
  y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1)
  y_min = y_scale * y_min
  y_max = y_scale * y_max
  x_min = x_scale * x_min
  x_max = x_scale * x_max
  scaled_boxlist = np_box_list.BoxList(np.hstack([y_min, x_min, y_max, x_max]))

  fields = boxlist.get_extra_fields()
  for field in fields:
    extra_field_data = boxlist.get_field(field)
    scaled_boxlist.add_field(field, extra_field_data)

  return scaled_boxlist 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:np_box_list_ops.py

示例3: _compute_is_aclass_correctly_detected_in_image

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def _compute_is_aclass_correctly_detected_in_image(
      self, detected_boxes, detected_scores, groundtruth_boxes):
    """Compute CorLoc score for a single class.

    Args:
      detected_boxes: A numpy array of shape [N, 4] representing detected box
          coordinates
      detected_scores: A 1-d numpy array of length N representing classification
          score
      groundtruth_boxes: A numpy array of shape [M, 4] representing ground truth
          box coordinates

    Returns:
      is_class_correctly_detected_in_image: An integer 1 or 0 denoting whether a
          class is correctly detected in the image or not
    """
    if detected_boxes.size > 0:
      if groundtruth_boxes.size > 0:
        max_score_id = np.argmax(detected_scores)
        detected_boxlist = np_box_list.BoxList(
            np.expand_dims(detected_boxes[max_score_id, :], axis=0))
        gt_boxlist = np_box_list.BoxList(groundtruth_boxes)
        iou = np_box_list_ops.iou(detected_boxlist, gt_boxlist)
        if np.max(iou) >= self.matching_iou_threshold:
          return 1
    return 0 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:28,代码来源:per_image_evaluation.py

示例4: setUp

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def setUp(self):
    boxes1 = np.array([[4.0, 3.0, 7.0, 5.0], [5.0, 6.0, 10.0, 7.0]],
                      dtype=float)
    boxes2 = np.array([[3.0, 4.0, 6.0, 8.0], [14.0, 14.0, 15.0, 15.0],
                       [0.0, 0.0, 20.0, 20.0]],
                      dtype=float)
    self.boxlist1 = np_box_list.BoxList(boxes1)
    self.boxlist2 = np_box_list.BoxList(boxes2) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:np_box_list_ops_test.py

示例5: test_ioa

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_ioa(self):
    boxlist1 = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    boxlist2 = np_box_list.BoxList(
        np.array(
            [[0.5, 0.25, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]], dtype=np.float32))
    ioa21 = np_box_list_ops.ioa(boxlist2, boxlist1)
    expected_ioa21 = np.array([[0.5, 0.0],
                               [1.0, 1.0]],
                              dtype=np.float32)
    self.assertAllClose(ioa21, expected_ioa21) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:15,代码来源:np_box_list_ops_test.py

示例6: test_scale

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_scale(self):
    boxlist = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    boxlist_scaled = np_box_list_ops.scale(boxlist, 2.0, 3.0)
    expected_boxlist_scaled = np_box_list.BoxList(
        np.array(
            [[0.5, 0.75, 1.5, 2.25], [0.0, 0.0, 1.0, 2.25]], dtype=np.float32))
    self.assertAllClose(expected_boxlist_scaled.get(), boxlist_scaled.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:np_box_list_ops_test.py

示例7: test_prune_outside_window

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_prune_outside_window(self):
    boxlist = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75],
             [-0.2, -0.3, 0.7, 1.5]],
            dtype=np.float32))
    boxlist_pruned, _ = np_box_list_ops.prune_outside_window(
        boxlist, [0.0, 0.0, 1.0, 1.0])
    expected_boxlist_pruned = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    self.assertAllClose(expected_boxlist_pruned.get(), boxlist_pruned.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:15,代码来源:np_box_list_ops_test.py

示例8: test_change_coordinate_frame

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_change_coordinate_frame(self):
    boxlist = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    boxlist_coord = np_box_list_ops.change_coordinate_frame(
        boxlist, np.array([0, 0, 0.5, 0.5], dtype=np.float32))
    expected_boxlist_coord = np_box_list.BoxList(
        np.array([[0.5, 0.5, 1.5, 1.5], [0, 0, 1.0, 1.5]], dtype=np.float32))
    self.assertAllClose(boxlist_coord.get(), expected_boxlist_coord.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:np_box_list_ops_test.py

示例9: test_filter_scores_greater_than

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_filter_scores_greater_than(self):
    boxlist = np_box_list.BoxList(
        np.array(
            [[0.25, 0.25, 0.75, 0.75], [0.0, 0.0, 0.5, 0.75]], dtype=
            np.float32))
    boxlist.add_field('scores', np.array([0.8, 0.2], np.float32))
    boxlist_greater = np_box_list_ops.filter_scores_greater_than(boxlist, 0.5)

    expected_boxlist_greater = np_box_list.BoxList(
        np.array([[0.25, 0.25, 0.75, 0.75]], dtype=np.float32))

    self.assertAllClose(boxlist_greater.get(), expected_boxlist_greater.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:np_box_list_ops_test.py

示例10: test_with_no_scores_field

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_with_no_scores_field(self):
    boxlist = np_box_list.BoxList(self._boxes)
    max_output_size = 3
    iou_threshold = 0.5

    with self.assertRaises(ValueError):
      np_box_list_ops.non_max_suppression(
          boxlist, max_output_size, iou_threshold) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:np_box_list_ops_test.py

示例11: test_nms_disabled_max_output_size_equals_three

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_nms_disabled_max_output_size_equals_three(self):
    boxlist = np_box_list.BoxList(self._boxes)
    boxlist.add_field('scores',
                      np.array([.9, .75, .6, .95, .2, .3], dtype=float))
    max_output_size = 3
    iou_threshold = 1.  # No NMS

    expected_boxes = np.array([[0, 10, 1, 11], [0, 0, 1, 1], [0, 0.1, 1, 1.1]],
                              dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:np_box_list_ops_test.py

示例12: test_select_from_three_clusters

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_select_from_three_clusters(self):
    boxlist = np_box_list.BoxList(self._boxes)
    boxlist.add_field('scores',
                      np.array([.9, .75, .6, .95, .2, .3], dtype=float))
    max_output_size = 3
    iou_threshold = 0.5

    expected_boxes = np.array([[0, 10, 1, 11], [0, 0, 1, 1], [0, 100, 1, 101]],
                              dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:np_box_list_ops_test.py

示例13: test_select_at_most_two_from_three_clusters

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_select_at_most_two_from_three_clusters(self):
    boxlist = np_box_list.BoxList(self._boxes)
    boxlist.add_field('scores',
                      np.array([.9, .75, .6, .95, .5, .3], dtype=float))
    max_output_size = 2
    iou_threshold = 0.5

    expected_boxes = np.array([[0, 10, 1, 11], [0, 0, 1, 1]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:np_box_list_ops_test.py

示例14: test_select_from_ten_indentical_boxes

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_select_from_ten_indentical_boxes(self):
    boxes = np.array(10 * [[0, 0, 1, 1]], dtype=float)
    boxlist = np_box_list.BoxList(boxes)
    boxlist.add_field('scores', np.array(10 * [0.8]))
    iou_threshold = .5
    max_output_size = 3
    expected_boxes = np.array([[0, 0, 1, 1]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:np_box_list_ops_test.py

示例15: test_different_iou_threshold

# 需要导入模块: from object_detection.utils import np_box_list [as 别名]
# 或者: from object_detection.utils.np_box_list import BoxList [as 别名]
def test_different_iou_threshold(self):
    boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80], [200, 200, 210, 300],
                      [200, 200, 210, 250]],
                     dtype=float)
    boxlist = np_box_list.BoxList(boxes)
    boxlist.add_field('scores', np.array([0.9, 0.8, 0.7, 0.6]))
    max_output_size = 4

    iou_threshold = .4
    expected_boxes = np.array([[0, 0, 20, 100],
                               [200, 200, 210, 300],],
                              dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)

    iou_threshold = .5
    expected_boxes = np.array([[0, 0, 20, 100], [200, 200, 210, 300],
                               [200, 200, 210, 250]],
                              dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)

    iou_threshold = .8
    expected_boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80],
                               [200, 200, 210, 300], [200, 200, 210, 250]],
                              dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(
        boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:33,代码来源:np_box_list_ops_test.py


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