本文整理汇总了Python中object_detection.anchor_generators.grid_anchor_generator.tile_anchors方法的典型用法代码示例。如果您正苦于以下问题:Python grid_anchor_generator.tile_anchors方法的具体用法?Python grid_anchor_generator.tile_anchors怎么用?Python grid_anchor_generator.tile_anchors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.anchor_generators.grid_anchor_generator
的用法示例。
在下文中一共展示了grid_anchor_generator.tile_anchors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate
# 需要导入模块: from object_detection.anchor_generators import grid_anchor_generator [as 别名]
# 或者: from object_detection.anchor_generators.grid_anchor_generator import tile_anchors [as 别名]
def _generate(self, feature_map_shape_list, im_height=1, im_width=1):
"""Generates a collection of bounding boxes to be used as anchors.
Currently we require the input image shape to be statically defined. That
is, im_height and im_width should be integers rather than tensors.
Args:
feature_map_shape_list: list of pairs of convnet layer resolutions in the
format [(height_0, width_0), (height_1, width_1), ...]. For example,
setting feature_map_shape_list=[(8, 8), (7, 7)] asks for anchors that
correspond to an 8x8 layer followed by a 7x7 layer.
im_height: the height of the image to generate the grid for. If both
im_height and im_width are 1, anchors can only be generated in
absolute coordinates.
im_width: the width of the image to generate the grid for. If both
im_height and im_width are 1, anchors can only be generated in
absolute coordinates.
Returns:
boxes_list: a list of BoxLists each holding anchor boxes corresponding to
the input feature map shapes.
Raises:
ValueError: if im_height and im_width are 1, but normalized coordinates
were requested.
"""
anchor_grid_list = []
for (feat_shape, base_sizes, aspect_ratios, anchor_stride, anchor_offset
) in zip(feature_map_shape_list, self._base_sizes, self._aspect_ratios,
self._anchor_strides, self._anchor_offsets):
anchor_grid = grid_anchor_generator.tile_anchors(
feat_shape[0],
feat_shape[1],
tf.cast(tf.convert_to_tensor(base_sizes), dtype=tf.float32),
tf.cast(tf.convert_to_tensor(aspect_ratios), dtype=tf.float32),
tf.constant([1.0, 1.0]),
tf.cast(tf.convert_to_tensor(anchor_stride), dtype=tf.float32),
tf.cast(tf.convert_to_tensor(anchor_offset), dtype=tf.float32))
num_anchors = anchor_grid.num_boxes_static()
if num_anchors is None:
num_anchors = anchor_grid.num_boxes()
anchor_indices = tf.zeros([num_anchors])
anchor_grid.add_field('feature_map_index', anchor_indices)
if self._normalize_coordinates:
if im_height == 1 or im_width == 1:
raise ValueError(
'Normalized coordinates were requested upon construction of the '
'FlexibleGridAnchorGenerator, but a subsequent call to '
'generate did not supply dimension information.')
anchor_grid = box_list_ops.to_normalized_coordinates(
anchor_grid, im_height, im_width, check_range=False)
anchor_grid_list.append(anchor_grid)
return anchor_grid_list
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:55,代码来源:flexible_grid_anchor_generator.py