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


Python square_box_coder.SquareBoxCoder方法代码示例

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


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

示例1: test_correct_relative_codes_with_default_scale

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_correct_relative_codes_with_default_scale(self):
    boxes = [[10.0, 10.0, 20.0, 15.0], [0.2, 0.1, 0.5, 0.4]]
    anchors = [[15.0, 12.0, 30.0, 18.0], [0.1, 0.0, 0.7, 0.9]]
    scale_factors = None
    expected_rel_codes = [[-0.790569, -0.263523, -0.293893],
                          [-0.068041, -0.272166, -0.89588]]

    boxes = box_list.BoxList(tf.constant(boxes))
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = square_box_coder.SquareBoxCoder(scale_factors=scale_factors)
    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,代码行数:16,代码来源:square_box_coder_test.py

示例2: test_correct_relative_codes_with_non_default_scale

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_correct_relative_codes_with_non_default_scale(self):
    boxes = [[10.0, 10.0, 20.0, 15.0], [0.2, 0.1, 0.5, 0.4]]
    anchors = [[15.0, 12.0, 30.0, 18.0], [0.1, 0.0, 0.7, 0.9]]
    scale_factors = [2, 3, 4]
    expected_rel_codes = [[-1.581139, -0.790569, -1.175573],
                          [-0.136083, -0.816497, -3.583519]]
    boxes = box_list.BoxList(tf.constant(boxes))
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = square_box_coder.SquareBoxCoder(scale_factors=scale_factors)
    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,代码行数:15,代码来源:square_box_coder_test.py

示例3: test_correct_relative_codes_with_small_width

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_correct_relative_codes_with_small_width(self):
    boxes = [[10.0, 10.0, 10.0000001, 20.0]]
    anchors = [[15.0, 12.0, 30.0, 18.0]]
    scale_factors = None
    expected_rel_codes = [[-1.317616, 0., -20.670586]]
    boxes = box_list.BoxList(tf.constant(boxes))
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = square_box_coder.SquareBoxCoder(scale_factors=scale_factors)
    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,代码行数:14,代码来源:square_box_coder_test.py

示例4: test_correct_boxes_with_default_scale

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_correct_boxes_with_default_scale(self):
    anchors = [[15.0, 12.0, 30.0, 18.0], [0.1, 0.0, 0.7, 0.9]]
    rel_codes = [[-0.5, -0.416666, -0.405465],
                 [-0.083333, -0.222222, -0.693147]]
    scale_factors = None
    expected_boxes = [[14.594306, 7.884875, 20.918861, 14.209432],
                      [0.155051, 0.102989, 0.522474, 0.470412]]
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = square_box_coder.SquareBoxCoder(scale_factors=scale_factors)
    boxes = coder.decode(rel_codes, anchors)
    with self.test_session() as sess:
      (boxes_out,) = sess.run([boxes.get()])
      self.assertAllClose(boxes_out, expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:15,代码来源:square_box_coder_test.py

示例5: test_correct_boxes_with_non_default_scale

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_correct_boxes_with_non_default_scale(self):
    anchors = [[15.0, 12.0, 30.0, 18.0], [0.1, 0.0, 0.7, 0.9]]
    rel_codes = [[-1., -1.25, -1.62186], [-0.166667, -0.666667, -2.772588]]
    scale_factors = [2, 3, 4]
    expected_boxes = [[14.594306, 7.884875, 20.918861, 14.209432],
                      [0.155051, 0.102989, 0.522474, 0.470412]]
    anchors = box_list.BoxList(tf.constant(anchors))
    coder = square_box_coder.SquareBoxCoder(scale_factors=scale_factors)
    boxes = coder.decode(rel_codes, anchors)
    with self.test_session() as sess:
      (boxes_out,) = sess.run([boxes.get()])
      self.assertAllClose(boxes_out, expected_boxes) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:square_box_coder_test.py

示例6: test_build_square_box_coder_with_non_default_parameters

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def test_build_square_box_coder_with_non_default_parameters(self):
    box_coder_text_proto = """
      square_box_coder {
        y_scale: 6.0
        x_scale: 3.0
        length_scale: 7.0
      }
    """
    box_coder_proto = box_coder_pb2.BoxCoder()
    text_format.Merge(box_coder_text_proto, box_coder_proto)
    box_coder_object = box_coder_builder.build(box_coder_proto)
    self.assertTrue(
        isinstance(box_coder_object, square_box_coder.SquareBoxCoder))
    self.assertEqual(box_coder_object._scale_factors, [6.0, 3.0, 7.0]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:16,代码来源:box_coder_builder_test.py

示例7: build

# 需要导入模块: from object_detection.box_coders import square_box_coder [as 别名]
# 或者: from object_detection.box_coders.square_box_coder import SquareBoxCoder [as 别名]
def build(box_coder_config):
  """Builds a box coder object based on the box coder config.

  Args:
    box_coder_config: A box_coder.proto object containing the config for the
      desired box coder.

  Returns:
    BoxCoder based on the config.

  Raises:
    ValueError: On empty box coder proto.
  """
  if not isinstance(box_coder_config, box_coder_pb2.BoxCoder):
    raise ValueError('box_coder_config not of type box_coder_pb2.BoxCoder.')

  if box_coder_config.WhichOneof('box_coder_oneof') == 'faster_rcnn_box_coder':
    return faster_rcnn_box_coder.FasterRcnnBoxCoder(scale_factors=[
        box_coder_config.faster_rcnn_box_coder.y_scale,
        box_coder_config.faster_rcnn_box_coder.x_scale,
        box_coder_config.faster_rcnn_box_coder.height_scale,
        box_coder_config.faster_rcnn_box_coder.width_scale
    ])
  if (box_coder_config.WhichOneof('box_coder_oneof') ==
      'mean_stddev_box_coder'):
    return mean_stddev_box_coder.MeanStddevBoxCoder()
  if box_coder_config.WhichOneof('box_coder_oneof') == 'square_box_coder':
    return square_box_coder.SquareBoxCoder(scale_factors=[
        box_coder_config.square_box_coder.y_scale,
        box_coder_config.square_box_coder.x_scale,
        box_coder_config.square_box_coder.length_scale
    ])
  raise ValueError('Empty box coder.') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:35,代码来源:box_coder_builder.py


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