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


Python np_box_mask_list.BoxMaskList方法代码示例

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


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

示例1: box_list_to_box_mask_list

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def box_list_to_box_mask_list(boxlist):
  """Converts a BoxList containing 'masks' into a BoxMaskList.

  Args:
    boxlist: An np_box_list.BoxList object.

  Returns:
    An np_box_mask_list.BoxMaskList object.

  Raises:
    ValueError: If boxlist does not contain `masks` as a field.
  """
  if not boxlist.has_field('masks'):
    raise ValueError('boxlist does not contain mask field.')
  box_mask_list = np_box_mask_list.BoxMaskList(
      box_data=boxlist.get(),
      mask_data=boxlist.get_field('masks'))
  extra_fields = boxlist.get_extra_fields()
  for key in extra_fields:
    if key != 'masks':
      box_mask_list.data[key] = boxlist.get_field(key)
  return box_mask_list 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:24,代码来源:np_box_mask_list_ops.py

示例2: sort_by_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [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)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:np_box_mask_list_ops.py

示例3: prune_non_overlapping_masks

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def prune_non_overlapping_masks(box_mask_list1, box_mask_list2, minoverlap=0.0):
  """Prunes the boxes in list1 that overlap less than thresh with list2.

  For each mask in box_mask_list1, we want its IOA to be more than minoverlap
  with at least one of the masks in box_mask_list2. If it does not, we remove
  it. If the masks are not full size image, we do the pruning based on boxes.

  Args:
    box_mask_list1: np_box_mask_list.BoxMaskList holding N boxes and masks.
    box_mask_list2: np_box_mask_list.BoxMaskList holding M boxes and masks.
    minoverlap: Minimum required overlap between boxes, to count them as
                overlapping.

  Returns:
    A pruned box_mask_list with size [N', 4].
  """
  intersection_over_area = ioa(box_mask_list2, box_mask_list1)  # [M, N] tensor
  intersection_over_area = np.amax(intersection_over_area, axis=0)  # [N] tensor
  keep_bool = np.greater_equal(intersection_over_area, np.array(minoverlap))
  keep_inds = np.nonzero(keep_bool)[0]
  new_box_mask_list1 = gather(box_mask_list1, keep_inds)
  return new_box_mask_list1 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:24,代码来源:np_box_mask_list_ops.py

示例4: test_invalid_box_mask_data

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_invalid_box_mask_data(self):
    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=[0, 0, 1, 1],
          mask_data=np.zeros([1, 3, 3], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 0, 1, 1]], dtype=int),
          mask_data=np.zeros([1, 3, 3], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([0, 1, 1, 3, 4], dtype=float),
          mask_data=np.zeros([1, 3, 3], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 1, 1, 3], [3, 1, 1, 5]], dtype=float),
          mask_data=np.zeros([2, 3, 3], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 1, 1, 3], [1, 1, 1, 5]], dtype=float),
          mask_data=np.zeros([3, 5, 5], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 1, 1, 3], [1, 1, 1, 5]], dtype=float),
          mask_data=np.zeros([2, 5], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 1, 1, 3], [1, 1, 1, 5]], dtype=float),
          mask_data=np.zeros([2, 5, 5, 5], dtype=np.uint8))

    with self.assertRaises(ValueError):
      np_box_mask_list.BoxMaskList(
          box_data=np.array([[0, 1, 1, 3], [1, 1, 1, 5]], dtype=float),
          mask_data=np.zeros([2, 5, 5], dtype=np.int32)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:42,代码来源:np_box_mask_list_test.py

示例5: test_has_field_with_existed_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_has_field_with_existed_field(self):
    boxes = 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)
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=boxes, mask_data=np.zeros([3, 5, 5], dtype=np.uint8))
    self.assertTrue(box_mask_list.has_field('boxes'))
    self.assertTrue(box_mask_list.has_field('masks')) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:10,代码来源:np_box_mask_list_test.py

示例6: test_has_field_with_nonexisted_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_has_field_with_nonexisted_field(self):
    boxes = 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)
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=boxes, mask_data=np.zeros([3, 3, 3], dtype=np.uint8))
    self.assertFalse(box_mask_list.has_field('scores')) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:9,代码来源:np_box_mask_list_test.py

示例7: test_get_field_with_existed_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_get_field_with_existed_field(self):
    boxes = 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)
    masks = np.zeros([3, 3, 3], dtype=np.uint8)
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=boxes, mask_data=masks)
    self.assertTrue(np.allclose(box_mask_list.get_field('boxes'), boxes))
    self.assertTrue(np.allclose(box_mask_list.get_field('masks'), masks)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:11,代码来源:np_box_mask_list_test.py

示例8: test_get_field_with_nonexited_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_get_field_with_nonexited_field(self):
    boxes = 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)
    masks = np.zeros([3, 3, 3], dtype=np.uint8)
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=boxes, mask_data=masks)
    with self.assertRaises(ValueError):
      box_mask_list.get_field('scores') 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:11,代码来源:np_box_mask_list_test.py

示例9: test_num_boxes

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_num_boxes(self):
    boxes = np.array([[0., 0., 100., 100.], [10., 30., 50., 70.]], dtype=float)
    masks = np.zeros([2, 5, 5], dtype=np.uint8)
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=boxes, mask_data=masks)
    expected_num_boxes = 2
    self.assertEquals(box_mask_list.num_boxes(), expected_num_boxes) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:9,代码来源:np_box_mask_list_test.py

示例10: test_with_no_scores_field

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_with_no_scores_field(self):
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=self.boxes1, mask_data=self.masks1)
    max_output_size = 3
    iou_threshold = 0.5

    with self.assertRaises(ValueError):
      np_box_mask_list_ops.non_max_suppression(
          box_mask_list, max_output_size, iou_threshold) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:11,代码来源:np_box_mask_list_ops_test.py

示例11: test_nms_disabled_max_output_size_equals_one

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def test_nms_disabled_max_output_size_equals_one(self):
    box_mask_list = np_box_mask_list.BoxMaskList(
        box_data=self.boxes2, mask_data=self.masks2)
    box_mask_list.add_field('scores',
                            np.array([.9, .75, .6], dtype=float))
    max_output_size = 1
    iou_threshold = 1.  # No NMS
    expected_boxes = np.array([[3.0, 4.0, 6.0, 8.0]], dtype=float)
    expected_masks = np.array(
        [[[0, 1, 0], [1, 1, 1], [0, 0, 0]]], dtype=np.uint8)
    nms_box_mask_list = np_box_mask_list_ops.non_max_suppression(
        box_mask_list, max_output_size, iou_threshold)
    self.assertAllClose(nms_box_mask_list.get(), expected_boxes)
    self.assertAllClose(nms_box_mask_list.get_masks(), expected_masks) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:16,代码来源:np_box_mask_list_ops_test.py

示例12: area

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def area(box_mask_list):
  """Computes area of masks.

  Args:
    box_mask_list: np_box_mask_list.BoxMaskList holding N boxes and masks

  Returns:
    a numpy array with shape [N*1] representing mask areas
  """
  return np_mask_ops.area(box_mask_list.get_masks()) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:12,代码来源:np_box_mask_list_ops.py

示例13: intersection

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def intersection(box_mask_list1, box_mask_list2):
  """Compute pairwise intersection areas between masks.

  Args:
    box_mask_list1: BoxMaskList holding N boxes and masks
    box_mask_list2: BoxMaskList holding M boxes and masks

  Returns:
    a numpy array with shape [N*M] representing pairwise intersection area
  """
  return np_mask_ops.intersection(box_mask_list1.get_masks(),
                                  box_mask_list2.get_masks()) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:14,代码来源:np_box_mask_list_ops.py

示例14: iou

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def iou(box_mask_list1, box_mask_list2):
  """Computes pairwise intersection-over-union between box and mask collections.

  Args:
    box_mask_list1: BoxMaskList holding N boxes and masks
    box_mask_list2: BoxMaskList holding M boxes and masks

  Returns:
    a numpy array with shape [N, M] representing pairwise iou scores.
  """
  return np_mask_ops.iou(box_mask_list1.get_masks(),
                         box_mask_list2.get_masks()) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:14,代码来源:np_box_mask_list_ops.py

示例15: gather

# 需要导入模块: from object_detection.utils import np_box_mask_list [as 别名]
# 或者: from object_detection.utils.np_box_mask_list import BoxMaskList [as 别名]
def gather(box_mask_list, indices, fields=None):
  """Gather boxes from np_box_mask_list.BoxMaskList according to indices.

  By default, gather returns boxes corresponding to the input index list, as
  well as all additional fields stored in the box_mask_list (indexing into the
  first dimension).  However one can optionally only gather from a
  subset of fields.

  Args:
    box_mask_list: np_box_mask_list.BoxMaskList holding N boxes
    indices: a 1-d numpy array of type int_
    fields: (optional) list of fields to also gather from.  If None (default),
        all fields are gathered from.  Pass an empty fields list to only gather
        the box coordinates.

  Returns:
    subbox_mask_list: a np_box_mask_list.BoxMaskList corresponding to the subset
        of the input box_mask_list specified by indices

  Raises:
    ValueError: if specified field is not contained in box_mask_list or if the
        indices are not of type int_
  """
  if fields is not None:
    if 'masks' not in fields:
      fields.append('masks')
  return box_list_to_box_mask_list(
      np_box_list_ops.gather(
          boxlist=box_mask_list, indices=indices, fields=fields)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:31,代码来源:np_box_mask_list_ops.py


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