貪心地按分數的降序選擇邊界框的子集。
用法
tf.image.non_max_suppression_padded(
boxes, scores, max_output_size, iou_threshold=0.5,
score_threshold=float('-inf'), pad_to_max_output_size=False,
name=None, sorted_input=False, canonicalized_coordinates=False, tile_size=512
)
參數
-
boxes
秩為 2 或更高的張量,形狀為 [..., num_boxes, 4]。除最後兩個外的維度是批次維度。 -
scores
秩為 1 或更高的張量,形狀為 [..., num_boxes]。 -
max_output_size
一個標量整數Tensor
,表示非最大抑製要選擇的最大框數。請注意,將此值設置為較大的數字可能會導致 OOM 錯誤,具體取決於係統工作負載。 -
iou_threshold
一個浮點數,表示用於決定框是否相對於 IoU(交集超過聯合)重疊過多的閾值。 -
score_threshold
表示框分數閾值的浮點數。得分不大於此閾值的框將被抑製。 -
pad_to_max_output_size
是否將輸出 idx 填充到max_output_size。當輸入是一批圖像時必須設置為 True。 -
name
操作名稱。 -
sorted_input
一個布爾值,指示輸入框和分數是否按分數降序排序。 -
canonicalized_coordinates
如果框坐標為[y_min, x_min, y_max, x_max]
,設置為 True 消除冗餘計算以規範化框坐標。 -
tile_size
一個整數,表示圖塊中的框數,即每張圖像可用於並行抑製其他框的最大框數;更大的tile_size 意味著更大的並行度和可能更多的冗餘工作。
返回
- idx:形狀為 [..., num_boxes] 的張量,表示通過非最大抑製選擇的索引。前導維度是輸入框的批量維度。所有數字都在 [0, num_boxes) 內。對於每個圖像(即 idx[i]),隻有第一個 num_valid[i] 索引(即 idx[i][:num_valid[i]])是有效的。 num_valid:等級為 0 或更高的張量,形狀為 [...],表示 idx 中有效索引的數量。它的維度是輸入框的批量維度。
-
Raises
ValueError:當為批量輸入設置 pad_to_max_output_size 為 False 時。
對 tf.image.non_max_suppression 執行算法等效的操作,並添加一個可選參數 zero-pads 輸出大小為 max_output_size
。此操作的輸出是一個元組,其中包含索引到表示所選框的邊界框輸入集合中的整數集以及索引集中有效索引的數量。然後可以使用tf.slice
和tf.gather
操作獲得與所選索引對應的邊界框坐標。例如:
selected_indices_padded, num_valid = tf.image.non_max_suppression_padded(
boxes, scores, max_output_size, iou_threshold,
score_threshold, pad_to_max_output_size=True)
selected_indices = tf.slice(
selected_indices_padded, tf.constant([0]), num_valid)
selected_boxes = tf.gather(boxes, selected_indices)
相關用法
- Python tf.image.non_max_suppression_overlaps用法及代碼示例
- Python tf.image.non_max_suppression_with_scores用法及代碼示例
- 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_padded。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。