貪心地按分數的降序選擇邊界框的子集。
用法
tf.image.non_max_suppression_with_scores(
boxes, scores, max_output_size, iou_threshold=0.5,
score_threshold=float('-inf'), soft_nms_sigma=0.0, name=None
)
參數
-
boxes
形狀為[num_boxes, 4]
的二維浮點數Tensor
。 -
scores
形狀為[num_boxes]
的一維浮點數Tensor
,表示對應於每個框(每行框)的單個分數。 -
max_output_size
一個標量整數Tensor
,表示非最大抑製要選擇的最大框數。 -
iou_threshold
一個 0-D 浮點張量,表示用於決定框相對於 IOU 是否重疊過多的閾值。 -
score_threshold
一個 0-D 浮點張量,表示根據分數決定何時移除框的閾值。 -
soft_nms_sigma
一個 0-D 浮點張量,表示 Soft NMS 的 sigma 參數;見 Bodla 等人 (c.f.https://arxiv.org/abs/1704.04503)。什麽時候soft_nms_sigma=0.0
(這是默認設置),我們回退到標準(硬)NMS。 -
name
操作的名稱(可選)。
返回
-
selected_indices
形狀為[M]
的一維整數Tensor
表示從框張量中選擇的索引,其中M <= max_output_size
。 -
selected_scores
形狀為[M]
的一維浮點張量,表示每個選定框的相應分數,其中M <= max_output_size
。使用 Soft NMS 時(即soft_nms_sigma>0
時),分數僅與相應的輸入分數不同
修剪掉與先前選擇的框重疊的 intersection-over-union (IOU) 高的框。邊界框以 [y1, x1, y2, x2]
的形式提供,其中 (y1, x1)
和 (y2, x2)
是任何對角框角對的坐標,並且坐標可以以標準化(即位於區間 [0, 1]
中)或絕對坐標的形式提供。請注意,此算法與原點在坐標係中的位置無關。請注意,該算法對坐標係的正交變換和平移是不變的;因此,坐標係的平移或反射會導致算法選擇相同的框。此操作的輸出是一組整數,索引到表示所選框的邊界框的輸入集合中。然後可以使用tf.gather
操作獲得與所選索引對應的邊界框坐標。例如:
selected_indices, selected_scores = tf.image.non_max_suppression_padded(
boxes, scores, max_output_size, iou_threshold=1.0, score_threshold=0.1,
soft_nms_sigma=0.5)
selected_boxes = tf.gather(boxes, selected_indices)
此函數通過支持Soft-NMS(具有高斯加權)模式(參見 Bodla 等人,https://arxiv.org/abs/1704.04503)來概括 tf.image.non_max_suppression
操作,其中框會降低其他重疊框的分數,而不是直接導致它們被修剪。因此,與 tf.image.non_max_suppression
相比,tf.image.non_max_suppression_padded
在第二個輸出 selected_scores
中返回每個輸入框的新分數。
要啟用此Soft-NMS 模式,請將soft_nms_sigma
參數設置為大於0。當soft_nms_sigma
等於0 時,tf.image.non_max_suppression_padded
的行為與tf.image.non_max_suppression
的行為相同(除了額外的輸出)函數和運行時間。
相關用法
- Python tf.image.non_max_suppression_padded用法及代碼示例
- Python tf.image.non_max_suppression_overlaps用法及代碼示例
- Python tf.image.non_max_suppression用法及代碼示例
- Python tf.image.random_brightness用法及代碼示例
- Python tf.image.pad_to_bounding_box用法及代碼示例
- Python tf.image.adjust_hue用法及代碼示例
- Python tf.image.random_contrast用法及代碼示例
- Python tf.image.rot90用法及代碼示例
- Python tf.image.random_hue用法及代碼示例
- Python tf.image.flip_left_right用法及代碼示例
- Python tf.image.convert_image_dtype用法及代碼示例
- Python tf.image.stateless_random_flip_up_down用法及代碼示例
- Python tf.image.random_saturation用法及代碼示例
- Python tf.image.extract_glimpse用法及代碼示例
- Python tf.image.flip_up_down用法及代碼示例
- Python tf.image.crop_to_bounding_box用法及代碼示例
- Python tf.image.stateless_random_jpeg_quality用法及代碼示例
- Python tf.image.crop_and_resize用法及代碼示例
- Python tf.image.psnr用法及代碼示例
- Python tf.image.stateless_random_hue用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.image.non_max_suppression_with_scores。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。