當前位置: 首頁>>代碼示例>>Python>>正文


Python grid_anchor_generator.GridAnchorGenerator方法代碼示例

本文整理匯總了Python中object_detection.anchor_generators.grid_anchor_generator.GridAnchorGenerator方法的典型用法代碼示例。如果您正苦於以下問題:Python grid_anchor_generator.GridAnchorGenerator方法的具體用法?Python grid_anchor_generator.GridAnchorGenerator怎麽用?Python grid_anchor_generator.GridAnchorGenerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在object_detection.anchor_generators.grid_anchor_generator的用法示例。


在下文中一共展示了grid_anchor_generator.GridAnchorGenerator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_construct_single_anchor

# 需要導入模塊: from object_detection.anchor_generators import grid_anchor_generator [as 別名]
# 或者: from object_detection.anchor_generators.grid_anchor_generator import GridAnchorGenerator [as 別名]
def test_construct_single_anchor(self):
    """Builds a 1x1 anchor grid to test the size of the output boxes."""
    scales = [0.5, 1.0, 2.0]
    aspect_ratios = [0.25, 1.0, 4.0]
    anchor_offset = [7, -3]
    exp_anchor_corners = [[-121, -35, 135, 29], [-249, -67, 263, 61],
                          [-505, -131, 519, 125], [-57, -67, 71, 61],
                          [-121, -131, 135, 125], [-249, -259, 263, 253],
                          [-25, -131, 39, 125], [-57, -259, 71, 253],
                          [-121, -515, 135, 509]]

    anchor_generator = grid_anchor_generator.GridAnchorGenerator(
        scales, aspect_ratios,
        anchor_offset=anchor_offset)
    anchors = anchor_generator.generate(feature_map_shape_list=[(1, 1)])
    anchor_corners = anchors.get()

    with self.test_session():
      anchor_corners_out = anchor_corners.eval()
      self.assertAllClose(anchor_corners_out, exp_anchor_corners) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:22,代碼來源:grid_anchor_generator_test.py

示例2: test_build_grid_anchor_generator_with_defaults

# 需要導入模塊: from object_detection.anchor_generators import grid_anchor_generator [as 別名]
# 或者: from object_detection.anchor_generators.grid_anchor_generator import GridAnchorGenerator [as 別名]
def test_build_grid_anchor_generator_with_defaults(self):
    anchor_generator_text_proto = """
      grid_anchor_generator {
      }
     """
    anchor_generator_proto = anchor_generator_pb2.AnchorGenerator()
    text_format.Merge(anchor_generator_text_proto, anchor_generator_proto)
    anchor_generator_object = anchor_generator_builder.build(
        anchor_generator_proto)
    self.assertTrue(isinstance(anchor_generator_object,
                               grid_anchor_generator.GridAnchorGenerator))
    self.assertListEqual(anchor_generator_object._scales, [])
    self.assertListEqual(anchor_generator_object._aspect_ratios, [])
    with self.test_session() as sess:
      base_anchor_size, anchor_offset, anchor_stride = sess.run(
          [anchor_generator_object._base_anchor_size,
           anchor_generator_object._anchor_offset,
           anchor_generator_object._anchor_stride])
    self.assertAllEqual(anchor_offset, [0, 0])
    self.assertAllEqual(anchor_stride, [16, 16])
    self.assertAllEqual(base_anchor_size, [256, 256]) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:23,代碼來源:anchor_generator_builder_test.py

示例3: test_construct_single_anchor

# 需要導入模塊: from object_detection.anchor_generators import grid_anchor_generator [as 別名]
# 或者: from object_detection.anchor_generators.grid_anchor_generator import GridAnchorGenerator [as 別名]
def test_construct_single_anchor(self):
    """Builds a 1x1 anchor grid to test the size of the output boxes."""
    def graph_fn():
      scales = [0.5, 1.0, 2.0]
      aspect_ratios = [0.25, 1.0, 4.0]
      anchor_offset = [7, -3]
      anchor_generator = grid_anchor_generator.GridAnchorGenerator(
          scales, aspect_ratios, anchor_offset=anchor_offset)
      anchors_list = anchor_generator.generate(feature_map_shape_list=[(1, 1)])
      anchor_corners = anchors_list[0].get()
      return (anchor_corners,)
    exp_anchor_corners = [[-121, -35, 135, 29], [-249, -67, 263, 61],
                          [-505, -131, 519, 125], [-57, -67, 71, 61],
                          [-121, -131, 135, 125], [-249, -259, 263, 253],
                          [-25, -131, 39, 125], [-57, -259, 71, 253],
                          [-121, -515, 135, 509]]
    anchor_corners_out = self.execute(graph_fn, [])
    self.assertAllClose(anchor_corners_out, exp_anchor_corners) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:20,代碼來源:grid_anchor_generator_test.py

示例4: test_construct_single_anchor

# 需要導入模塊: from object_detection.anchor_generators import grid_anchor_generator [as 別名]
# 或者: from object_detection.anchor_generators.grid_anchor_generator import GridAnchorGenerator [as 別名]
def test_construct_single_anchor(self):
    """Builds a 1x1 anchor grid to test the size of the output boxes."""
    def graph_fn():
      scales = [0.5, 1.0, 2.0]
      aspect_ratios = [0.25, 1.0, 4.0]
      anchor_offset = [7, -3]
      anchor_generator = grid_anchor_generator.GridAnchorGenerator(
          scales, aspect_ratios, anchor_offset=anchor_offset)
      anchors = anchor_generator.generate(feature_map_shape_list=[(1, 1)])
      anchor_corners = anchors.get()
      return (anchor_corners,)
    exp_anchor_corners = [[-121, -35, 135, 29], [-249, -67, 263, 61],
                          [-505, -131, 519, 125], [-57, -67, 71, 61],
                          [-121, -131, 135, 125], [-249, -259, 263, 253],
                          [-25, -131, 39, 125], [-57, -259, 71, 253],
                          [-121, -515, 135, 509]]
    anchor_corners_out = self.execute(graph_fn, [])
    self.assertAllClose(anchor_corners_out, exp_anchor_corners) 
開發者ID:ShreyAmbesh,項目名稱:Traffic-Rule-Violation-Detection-System,代碼行數:20,代碼來源:grid_anchor_generator_test.py


注:本文中的object_detection.anchor_generators.grid_anchor_generator.GridAnchorGenerator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。