本文整理匯總了Python中object_detection.protos.anchor_generator_pb2.AnchorGenerator方法的典型用法代碼示例。如果您正苦於以下問題:Python anchor_generator_pb2.AnchorGenerator方法的具體用法?Python anchor_generator_pb2.AnchorGenerator怎麽用?Python anchor_generator_pb2.AnchorGenerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類object_detection.protos.anchor_generator_pb2
的用法示例。
在下文中一共展示了anchor_generator_pb2.AnchorGenerator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_build_grid_anchor_generator_with_defaults
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [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])
示例2: test_build_ssd_anchor_generator_with_custom_scales
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_ssd_anchor_generator_with_custom_scales(self):
anchor_generator_text_proto = """
ssd_anchor_generator {
aspect_ratios: [1.0]
scales: [0.1, 0.15, 0.2, 0.4, 0.6, 0.8]
reduce_boxes_in_lowest_layer: false
}
"""
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,
multiple_grid_anchor_generator.
MultipleGridAnchorGenerator))
for actual_scales, expected_scales in zip(
list(anchor_generator_object._scales),
[(0.1, math.sqrt(0.1 * 0.15)),
(0.15, math.sqrt(0.15 * 0.2)),
(0.2, math.sqrt(0.2 * 0.4)),
(0.4, math.sqrt(0.4 * 0.6)),
(0.6, math.sqrt(0.6 * 0.8)),
(0.8, math.sqrt(0.8 * 1.0))]):
self.assert_almost_list_equal(expected_scales, actual_scales, delta=1e-2)
示例3: test_build_ssd_anchor_generator_with_custom_interpolated_scale
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_ssd_anchor_generator_with_custom_interpolated_scale(self):
anchor_generator_text_proto = """
ssd_anchor_generator {
aspect_ratios: [0.5]
interpolated_scale_aspect_ratio: 0.5
reduce_boxes_in_lowest_layer: false
}
"""
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,
multiple_grid_anchor_generator.
MultipleGridAnchorGenerator))
for actual_aspect_ratio, expected_aspect_ratio in zip(
list(anchor_generator_object._aspect_ratios),
6 * [(0.5, 0.5)]):
self.assert_almost_list_equal(expected_aspect_ratio, actual_aspect_ratio)
示例4: test_build_multiscale_anchor_generator_custom_aspect_ratios
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_multiscale_anchor_generator_custom_aspect_ratios(self):
anchor_generator_text_proto = """
multiscale_anchor_generator {
aspect_ratios: [1.0]
}
"""
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,
multiscale_grid_anchor_generator.
MultiscaleGridAnchorGenerator))
for level, anchor_grid_info in zip(
range(3, 8), anchor_generator_object._anchor_grid_info):
self.assertEqual(set(anchor_grid_info.keys()), set(['level', 'info']))
self.assertTrue(level, anchor_grid_info['level'])
self.assertEqual(len(anchor_grid_info['info']), 4)
self.assertAllClose(anchor_grid_info['info'][0], [2**0, 2**0.5])
self.assertTrue(anchor_grid_info['info'][1], 1.0)
self.assertAllClose(anchor_grid_info['info'][2],
[4.0 * 2**level, 4.0 * 2**level])
self.assertAllClose(anchor_grid_info['info'][3], [2**level, 2**level])
self.assertTrue(anchor_generator_object._normalize_coordinates)
示例5: test_build_multiscale_anchor_generator_with_anchors_in_pixel_coordinates
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_multiscale_anchor_generator_with_anchors_in_pixel_coordinates(
self):
anchor_generator_text_proto = """
multiscale_anchor_generator {
aspect_ratios: [1.0]
normalize_coordinates: false
}
"""
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,
multiscale_grid_anchor_generator.
MultiscaleGridAnchorGenerator))
self.assertFalse(anchor_generator_object._normalize_coordinates)
示例6: test_build_multiscale_anchor_generator_custom_aspect_ratios
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_multiscale_anchor_generator_custom_aspect_ratios(self):
anchor_generator_text_proto = """
multiscale_anchor_generator {
aspect_ratios: [1.0]
}
"""
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,
multiscale_grid_anchor_generator.
MultiscaleGridAnchorGenerator))
print anchor_generator_object._anchor_grid_info
for level, anchor_grid_info in zip(
range(3, 8), anchor_generator_object._anchor_grid_info):
self.assertEqual(set(anchor_grid_info.keys()), set(['level', 'info']))
self.assertTrue(level, anchor_grid_info['level'])
self.assertEqual(len(anchor_grid_info['info']), 4)
self.assertAllClose(anchor_grid_info['info'][0], [2**0, 2**0.5])
self.assertTrue(anchor_grid_info['info'][1], 1.0)
self.assertAllClose(anchor_grid_info['info'][2],
[4.0 * 2**level, 4.0 * 2**level])
self.assertAllClose(anchor_grid_info['info'][3], [2**level, 2**level])
開發者ID:ShreyAmbesh,項目名稱:Traffic-Rule-Violation-Detection-System,代碼行數:26,代碼來源:anchor_generator_builder_test.py
示例7: test_build_grid_anchor_generator_with_non_default_parameters
# 需要導入模塊: from object_detection.protos import anchor_generator_pb2 [as 別名]
# 或者: from object_detection.protos.anchor_generator_pb2 import AnchorGenerator [as 別名]
def test_build_grid_anchor_generator_with_non_default_parameters(self):
anchor_generator_text_proto = """
grid_anchor_generator {
height: 128
width: 512
height_stride: 10
width_stride: 20
height_offset: 30
width_offset: 40
scales: [0.4, 2.2]
aspect_ratios: [0.3, 4.5]
}
"""
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.assert_almost_list_equal(anchor_generator_object._scales,
[0.4, 2.2])
self.assert_almost_list_equal(anchor_generator_object._aspect_ratios,
[0.3, 4.5])
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, [30, 40])
self.assertAllEqual(anchor_stride, [10, 20])
self.assertAllEqual(base_anchor_size, [128, 512])