我是靠谱客的博主 瘦瘦身影,最近开发中收集的这篇文章主要介绍tf.image.non_max_suppression,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

http://mamalm.com/dl_/article-12966-1.html
在说明Yolo算法的预测过程之前,这里先介绍一下非极大值抑制算法(non maximum suppression, NMS),这个算法不单单是针对Yolo算法的,而是所有的检测算法中都会用到。NMS算法主要解决的是一个目标被多次检测的问题,如图11中人脸检测,可以看到人脸被多次检测,但是其实我们希望最后仅仅输出其中一个较好的预测框,比如对于美女,只想要红色那个检测结果。那么可以采用NMS算法来实现这样的效果:首先从所有的检测框中找到置信度较大的那个框,然后挨个计算其与剩余框的IOU,如果其值大于一定阈值(重合度过高),那么就将该框剔除;然后对剩余的检测框重复上述过程,直到处理完所有的检测框。Yolo预测过程也需要用到NMS算法。


tf.image.non_max_suppression(
boxes,
scores,
max_output_size,
iou_threshold=0.5,
name=None
)

Defined in tensorflow/python/ops/image_ops_impl.py.

See the guide: Images > Working with Bounding Boxes

Greedily selects a subset of bounding boxes in descending order of score.

Prunes away boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes are supplied as [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm is agnostic to where the origin is in the coordinate system. Note that this algorithm is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The output of this operation is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the tf.gather operation. For example: selected_indices = tf.image.non_max_suppression( boxes, scores, max_output_size, iou_threshold) selected_boxes = tf.gather(boxes, selected_indices)

Args:

  • boxes: A 2-D float Tensor of shape [num_boxes, 4].
  • scores: A 1-D float Tensor of shape [num_boxes] representing a single score corresponding to each box (each row of boxes).
  • max_output_size: A scalar integer Tensor representing the maximum number of boxes to be selected by non max suppression.
  • iou_threshold: A float representing the threshold for deciding whether boxes overlap too much with respect to IOU.
  • name: A name for the operation (optional).

Returns:

  • selected_indices: A 1-D integer Tensor of shape [M] representing the selected indices from the boxes tensor, where M <= max_output_size.

最后

以上就是瘦瘦身影为你收集整理的tf.image.non_max_suppression的全部内容,希望文章能够帮你解决tf.image.non_max_suppression所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部