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


Python box_list.BoxList方法代码示例

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


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

示例1: _batch_decode_refined_boxes

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def _batch_decode_refined_boxes(self, refined_box_encodings, proposal_boxes):
    """Decode tensor of refined box encodings.

    Args:
      refined_box_encodings: a 3-D tensor with shape
        [batch_size, max_num_proposals, num_classes, self._box_coder.code_size]
        representing predicted (final) refined box encodings.
      proposal_boxes: [batch_size, self.max_num_proposals, 4] representing
        decoded proposal bounding boxes.

    Returns:
      refined_box_predictions: a [batch_size, max_num_proposals, num_classes, 4]
        float tensor representing (padded) refined bounding box predictions
        (for each image in batch, proposal and class).
    """
    tiled_proposal_boxes = tf.tile(
        tf.expand_dims(proposal_boxes, 2), [1, 1, self.num_classes, 1])
    tiled_proposals_boxlist = box_list.BoxList(
        tf.reshape(tiled_proposal_boxes, [-1, 4]))
    decoded_boxes = self._box_coder.decode(
        tf.reshape(refined_box_encodings, [-1, self._box_coder.code_size]),
        tiled_proposals_boxlist)
    return tf.reshape(decoded_boxes.get(),
                      [-1, self.max_num_proposals, self.num_classes, 4]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:faster_rcnn_meta_arch.py

示例2: test_get_correct_relative_codes_after_encoding

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_get_correct_relative_codes_after_encoding(self):
    boxes = [[10., 10., 20., 15.],
             [0.2, 0.1, 0.5, 0.4]]
    keypoints = [[[15., 12.], [10., 15.]],
                 [[0.5, 0.3], [0.2, 0.4]]]
    num_keypoints = len(keypoints[0])
    anchors = [[15., 12., 30., 18.],
               [0.1, 0.0, 0.7, 0.9]]
    expected_rel_codes = [
        [-0.5, -0.416666, -0.405465, -0.182321,
         -0.5, -0.5, -0.833333, 0.],
        [-0.083333, -0.222222, -0.693147, -1.098612,
         0.166667, -0.166667, -0.333333, -0.055556]
    ]
    boxes = box_list.BoxList(tf.constant(boxes))
    boxes.add_field(fields.BoxListFields.keypoints, tf.constant(keypoints))
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints)
    rel_codes = coder.encode(boxes, anchors)
    with self.test_session() as sess:
      rel_codes_out, = sess.run([rel_codes])
      self.assertAllClose(rel_codes_out, expected_rel_codes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:keypoint_box_coder_test.py

示例3: test_get_correct_boxes_after_decoding

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_get_correct_boxes_after_decoding(self):
    anchors = [[15., 12., 30., 18.],
               [0.1, 0.0, 0.7, 0.9]]
    rel_codes = [
        [-0.5, -0.416666, -0.405465, -0.182321,
         -0.5, -0.5, -0.833333, 0.],
        [-0.083333, -0.222222, -0.693147, -1.098612,
         0.166667, -0.166667, -0.333333, -0.055556]
    ]
    expected_boxes = [[10., 10., 20., 15.],
                      [0.2, 0.1, 0.5, 0.4]]
    expected_keypoints = [[[15., 12.], [10., 15.]],
                          [[0.5, 0.3], [0.2, 0.4]]]
    num_keypoints = len(expected_keypoints[0])
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = keypoint_box_coder.KeypointBoxCoder(num_keypoints)
    boxes = coder.decode(rel_codes, anchors)
    with self.test_session() as sess:
      boxes_out, keypoints_out = sess.run(
          [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)])
      self.assertAllClose(boxes_out, expected_boxes)
      self.assertAllClose(keypoints_out, expected_keypoints) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:keypoint_box_coder_test.py

示例4: test_get_correct_boxes_after_decoding_with_scaling

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_get_correct_boxes_after_decoding_with_scaling(self):
    anchors = [[15., 12., 30., 18.],
               [0.1, 0.0, 0.7, 0.9]]
    rel_codes = [
        [-1., -1.25, -1.62186, -0.911608,
         -1.0, -1.5, -1.666667, 0.],
        [-0.166667, -0.666667, -2.772588, -5.493062,
         0.333333, -0.5, -0.666667, -0.166667]
    ]
    scale_factors = [2, 3, 4, 5]
    expected_boxes = [[10., 10., 20., 15.],
                      [0.2, 0.1, 0.5, 0.4]]
    expected_keypoints = [[[15., 12.], [10., 15.]],
                          [[0.5, 0.3], [0.2, 0.4]]]
    num_keypoints = len(expected_keypoints[0])
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = keypoint_box_coder.KeypointBoxCoder(
        num_keypoints, scale_factors=scale_factors)
    boxes = coder.decode(rel_codes, anchors)
    with self.test_session() as sess:
      boxes_out, keypoints_out = sess.run(
          [boxes.get(), boxes.get_field(fields.BoxListFields.keypoints)])
      self.assertAllClose(boxes_out, expected_boxes)
      self.assertAllClose(keypoints_out, expected_keypoints) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:keypoint_box_coder_test.py

示例5: _decode

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def _decode(self, rel_codes, anchors):
    """Decode.

    Args:
      rel_codes: a tensor representing N anchor-encoded boxes.
      anchors: BoxList of anchors.  We assume that anchors has an associated
        stddev field.

    Returns:
      boxes: BoxList holding N bounding boxes
    Raises:
      ValueError: if the anchors BoxList does not have a stddev field
    """
    if not anchors.has_field('stddev'):
      raise ValueError('anchors must have a stddev field')
    means = anchors.get()
    stddevs = anchors.get_field('stddev')
    box_corners = rel_codes * stddevs + means
    return box_list.BoxList(box_corners) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:mean_stddev_box_coder.py

示例6: test_batch_decode

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_batch_decode(self):
    mock_anchor_corners = tf.constant(
        [[0, 0.1, 0.2, 0.3], [0.2, 0.4, 0.4, 0.6]], tf.float32)
    mock_anchors = box_list.BoxList(mock_anchor_corners)
    mock_box_coder = MockBoxCoder()

    expected_boxes = [[[0.0, 0.1, 0.5, 0.6], [0.5, 0.6, 0.7, 0.8]],
                      [[0.1, 0.2, 0.3, 0.4], [0.7, 0.8, 0.9, 1.0]]]

    encoded_boxes_list = [mock_box_coder.encode(
        box_list.BoxList(tf.constant(boxes)), mock_anchors)
                          for boxes in expected_boxes]
    encoded_boxes = tf.stack(encoded_boxes_list)
    decoded_boxes = box_coder.batch_decode(
        encoded_boxes, mock_box_coder, mock_anchors)

    with self.test_session() as sess:
      decoded_boxes_result = sess.run(decoded_boxes)
      self.assertAllClose(expected_boxes, decoded_boxes_result) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:box_coder_test.py

示例7: _compute_loss

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def _compute_loss(self, prediction_tensor, target_tensor, weights):
    """Compute loss function.

    Args:
      prediction_tensor: A float tensor of shape [batch_size, num_anchors, 4]
        representing the decoded predicted boxes
      target_tensor: A float tensor of shape [batch_size, num_anchors, 4]
        representing the decoded target boxes
      weights: a float tensor of shape [batch_size, num_anchors]

    Returns:
      loss: a (scalar) tensor representing the value of the loss function
    """
    predicted_boxes = box_list.BoxList(tf.reshape(prediction_tensor, [-1, 4]))
    target_boxes = box_list.BoxList(tf.reshape(target_tensor, [-1, 4]))
    per_anchor_iou_loss = 1.0 - box_list_ops.matched_iou(predicted_boxes,
                                                         target_boxes)
    return tf.reduce_sum(tf.reshape(weights, [-1]) * per_anchor_iou_loss) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:20,代码来源:losses.py

示例8: test_raises_error_on_invalid_groundtruth_labels

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_raises_error_on_invalid_groundtruth_labels(self):
    similarity_calc = region_similarity_calculator.NegSqDistSimilarity()
    matcher = bipartite_matcher.GreedyBipartiteMatcher()
    box_coder = mean_stddev_box_coder.MeanStddevBoxCoder()
    unmatched_cls_target = tf.constant([[0, 0], [0, 0], [0, 0]], tf.float32)
    target_assigner = targetassigner.TargetAssigner(
        similarity_calc, matcher, box_coder,
        unmatched_cls_target=unmatched_cls_target)

    prior_means = tf.constant([[0.0, 0.0, 0.5, 0.5]])
    prior_stddevs = tf.constant([[1.0, 1.0, 1.0, 1.0]])
    priors = box_list.BoxList(prior_means)
    priors.add_field('stddev', prior_stddevs)

    box_corners = [[0.0, 0.0, 0.5, 0.5],
                   [0.5, 0.5, 0.9, 0.9],
                   [.75, 0, .95, .27]]
    boxes = box_list.BoxList(tf.constant(box_corners))

    groundtruth_labels = tf.constant([[[0, 1], [1, 0]]], tf.float32)

    with self.assertRaises(ValueError):
      target_assigner.assign(priors, boxes, groundtruth_labels,
                             num_valid_rows=3) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:target_assigner_test.py

示例9: test_clip_to_window_filter_boxes_which_fall_outside_the_window

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_clip_to_window_filter_boxes_which_fall_outside_the_window(
      self):
    window = tf.constant([0, 0, 9, 14], tf.float32)
    corners = tf.constant([[5.0, 5.0, 6.0, 6.0],
                           [-1.0, -2.0, 4.0, 5.0],
                           [2.0, 3.0, 5.0, 9.0],
                           [0.0, 0.0, 9.0, 14.0],
                           [-100.0, -100.0, 300.0, 600.0],
                           [-10.0, -10.0, -9.0, -9.0]])
    boxes = box_list.BoxList(corners)
    boxes.add_field('extra_data', tf.constant([[1], [2], [3], [4], [5], [6]]))
    exp_output = [[5.0, 5.0, 6.0, 6.0], [0.0, 0.0, 4.0, 5.0],
                  [2.0, 3.0, 5.0, 9.0], [0.0, 0.0, 9.0, 14.0],
                  [0.0, 0.0, 9.0, 14.0]]
    pruned = box_list_ops.clip_to_window(
        boxes, window, filter_nonoverlapping=True)
    with self.test_session() as sess:
      pruned_output = sess.run(pruned.get())
      self.assertAllClose(pruned_output, exp_output)
      extra_data_out = sess.run(pruned.get_field('extra_data'))
      self.assertAllEqual(extra_data_out, [[1], [2], [3], [4], [5]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:box_list_ops_test.py

示例10: test_clip_to_window_without_filtering_boxes_which_fall_outside_the_window

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_clip_to_window_without_filtering_boxes_which_fall_outside_the_window(
      self):
    window = tf.constant([0, 0, 9, 14], tf.float32)
    corners = tf.constant([[5.0, 5.0, 6.0, 6.0],
                           [-1.0, -2.0, 4.0, 5.0],
                           [2.0, 3.0, 5.0, 9.0],
                           [0.0, 0.0, 9.0, 14.0],
                           [-100.0, -100.0, 300.0, 600.0],
                           [-10.0, -10.0, -9.0, -9.0]])
    boxes = box_list.BoxList(corners)
    boxes.add_field('extra_data', tf.constant([[1], [2], [3], [4], [5], [6]]))
    exp_output = [[5.0, 5.0, 6.0, 6.0], [0.0, 0.0, 4.0, 5.0],
                  [2.0, 3.0, 5.0, 9.0], [0.0, 0.0, 9.0, 14.0],
                  [0.0, 0.0, 9.0, 14.0], [0.0, 0.0, 0.0, 0.0]]
    pruned = box_list_ops.clip_to_window(
        boxes, window, filter_nonoverlapping=False)
    with self.test_session() as sess:
      pruned_output = sess.run(pruned.get())
      self.assertAllClose(pruned_output, exp_output)
      extra_data_out = sess.run(pruned.get_field('extra_data'))
      self.assertAllEqual(extra_data_out, [[1], [2], [3], [4], [5], [6]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:box_list_ops_test.py

示例11: test_prune_completely_outside_window

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_prune_completely_outside_window(self):
    window = tf.constant([0, 0, 9, 14], tf.float32)
    corners = tf.constant([[5.0, 5.0, 6.0, 6.0],
                           [-1.0, -2.0, 4.0, 5.0],
                           [2.0, 3.0, 5.0, 9.0],
                           [0.0, 0.0, 9.0, 14.0],
                           [-10.0, -10.0, -9.0, -9.0],
                           [-100.0, -100.0, 300.0, 600.0]])
    boxes = box_list.BoxList(corners)
    boxes.add_field('extra_data', tf.constant([[1], [2], [3], [4], [5], [6]]))
    exp_output = [[5.0, 5.0, 6.0, 6.0],
                  [-1.0, -2.0, 4.0, 5.0],
                  [2.0, 3.0, 5.0, 9.0],
                  [0.0, 0.0, 9.0, 14.0],
                  [-100.0, -100.0, 300.0, 600.0]]
    pruned, keep_indices = box_list_ops.prune_completely_outside_window(boxes,
                                                                        window)
    with self.test_session() as sess:
      pruned_output = sess.run(pruned.get())
      self.assertAllClose(pruned_output, exp_output)
      keep_indices_out = sess.run(keep_indices)
      self.assertAllEqual(keep_indices_out, [0, 1, 2, 3, 5])
      extra_data_out = sess.run(pruned.get_field('extra_data'))
      self.assertAllEqual(extra_data_out, [[1], [2], [3], [4], [6]]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:box_list_ops_test.py

示例12: test_ioa

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_ioa(self):
    corners1 = tf.constant([[4.0, 3.0, 7.0, 5.0], [5.0, 6.0, 10.0, 7.0]])
    corners2 = tf.constant([[3.0, 4.0, 6.0, 8.0], [14.0, 14.0, 15.0, 15.0],
                            [0.0, 0.0, 20.0, 20.0]])
    exp_output_1 = [[2.0 / 12.0, 0, 6.0 / 400.0],
                    [1.0 / 12.0, 0.0, 5.0 / 400.0]]
    exp_output_2 = [[2.0 / 6.0, 1.0 / 5.0],
                    [0, 0],
                    [6.0 / 6.0, 5.0 / 5.0]]
    boxes1 = box_list.BoxList(corners1)
    boxes2 = box_list.BoxList(corners2)
    ioa_1 = box_list_ops.ioa(boxes1, boxes2)
    ioa_2 = box_list_ops.ioa(boxes2, boxes1)
    with self.test_session() as sess:
      ioa_output_1, ioa_output_2 = sess.run([ioa_1, ioa_2])
      self.assertAllClose(ioa_output_1, exp_output_1)
      self.assertAllClose(ioa_output_2, exp_output_2) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:box_list_ops_test.py

示例13: test_prune_non_overlapping_boxes

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_prune_non_overlapping_boxes(self):
    corners1 = tf.constant([[4.0, 3.0, 7.0, 5.0], [5.0, 6.0, 10.0, 7.0]])
    corners2 = tf.constant([[3.0, 4.0, 6.0, 8.0], [14.0, 14.0, 15.0, 15.0],
                            [0.0, 0.0, 20.0, 20.0]])
    boxes1 = box_list.BoxList(corners1)
    boxes2 = box_list.BoxList(corners2)
    minoverlap = 0.5

    exp_output_1 = boxes1
    exp_output_2 = box_list.BoxList(tf.constant(0.0, shape=[0, 4]))
    output_1, keep_indices_1 = box_list_ops.prune_non_overlapping_boxes(
        boxes1, boxes2, min_overlap=minoverlap)
    output_2, keep_indices_2 = box_list_ops.prune_non_overlapping_boxes(
        boxes2, boxes1, min_overlap=minoverlap)
    with self.test_session() as sess:
      (output_1_, keep_indices_1_, output_2_, keep_indices_2_, exp_output_1_,
       exp_output_2_) = sess.run(
           [output_1.get(), keep_indices_1,
            output_2.get(), keep_indices_2,
            exp_output_1.get(), exp_output_2.get()])
      self.assertAllClose(output_1_, exp_output_1_)
      self.assertAllClose(output_2_, exp_output_2_)
      self.assertAllEqual(keep_indices_1_, [0, 1])
      self.assertAllEqual(keep_indices_2_, []) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:26,代码来源:box_list_ops_test.py

示例14: test_boolean_mask_with_field

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_boolean_mask_with_field(self):
    corners = tf.constant(
        [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]])
    indicator = tf.constant([True, False, True, False, True], tf.bool)
    weights = tf.constant([[.1], [.3], [.5], [.7], [.9]], tf.float32)
    expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
    expected_weights = [[.1], [.5], [.9]]

    boxes = box_list.BoxList(corners)
    boxes.add_field('weights', weights)
    subset = box_list_ops.boolean_mask(boxes, indicator, ['weights'])
    with self.test_session() as sess:
      subset_output, weights_output = sess.run(
          [subset.get(), subset.get_field('weights')])
      self.assertAllClose(subset_output, expected_subset)
      self.assertAllClose(weights_output, expected_weights) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:box_list_ops_test.py

示例15: test_gather_with_dynamic_indexing

# 需要导入模块: from object_detection.core import box_list [as 别名]
# 或者: from object_detection.core.box_list import BoxList [as 别名]
def test_gather_with_dynamic_indexing(self):
    corners = tf.constant([4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]
                          ])
    weights = tf.constant([.5, .3, .7, .1, .9], tf.float32)
    indices = tf.reshape(tf.where(tf.greater(weights, 0.4)), [-1])
    expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
    expected_weights = [.5, .7, .9]

    boxes = box_list.BoxList(corners)
    boxes.add_field('weights', weights)
    subset = box_list_ops.gather(boxes, indices, ['weights'])
    with self.test_session() as sess:
      subset_output, weights_output = sess.run([subset.get(), subset.get_field(
          'weights')])
      self.assertAllClose(subset_output, expected_subset)
      self.assertAllClose(weights_output, expected_weights) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:box_list_ops_test.py


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