Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
dòng chảy căng:: ôi:: NonMaxSuppressionV5
#include <image_ops.h>
Tham lam chọn một tập hợp con các hộp giới hạn theo thứ tự điểm giảm dần.
Bản tóm tắt
cắt bỏ các hộp có sự chồng chéo cao (IOU) với các hộp đã chọn trước đó. Các hộp giới hạn có số điểm nhỏ hơn score_threshold
sẽ bị xóa. Các hộp giới hạn được cung cấp dưới dạng [y1, x1, y2, x2], trong đó (y1, x1) và (y2, x2) là tọa độ của bất kỳ cặp góc chéo nào của hộp và tọa độ có thể được cung cấp dưới dạng chuẩn hóa (nghĩa là nằm trong khoảng [0, 1]) hoặc tuyệt đối. Lưu ý rằng thuật toán này không xác định được gốc tọa độ ở đâu và nói chung là bất biến đối với các phép biến đổi trực giao và tịnh tiến của hệ tọa độ; do đó việc dịch hoặc phản ánh của hệ tọa độ dẫn đến các hộp giống nhau được thuật toán chọn. Đầu ra của thao tác này là một tập hợp các số nguyên được lập chỉ mục vào tập hợp đầu vào của các hộp giới hạn đại diện cho các hộp đã chọn. Sau đó, tọa độ hộp giới hạn tương ứng với các chỉ số đã chọn có thể được lấy bằng cách sử dụng tf.gather operation
. Ví dụ: selected_indices = tf.image.non_max_suppression_v2( hộp, điểm, max_output_size, iou_threshold, Score_threshold) selected_boxes = tf.gather(boxes, selected_indices) Op này cũng hỗ trợ chế độ Soft-NMS (với trọng số Gaussian) (cf Bodla et al , https://arxiv.org/abs/1704.04503 ) trong đó các hộp làm giảm điểm của các hộp chồng chéo khác thay vì trực tiếp khiến chúng bị cắt bớt. Để bật chế độ Soft-NMS này, hãy đặt tham số soft_nms_sigma
lớn hơn 0.
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- hộp: Một tensor nổi 2-D có hình dạng
[num_boxes, 4]
. - điểm số: Một tenxơ float 1-D có hình dạng
[num_boxes]
biểu thị một điểm duy nhất tương ứng với mỗi hộp (mỗi hàng hộp). - max_output_size: Một tenxơ số nguyên vô hướng biểu thị số lượng hộp tối đa được chọn bằng cách triệt tiêu không tối đa.
- iou_threshold: Một tenxơ float 0-D biểu thị ngưỡng để quyết định xem các hộp có chồng chéo quá nhiều so với IOU hay không.
- Score_threshold: Một tensor float 0-D biểu thị ngưỡng để quyết định thời điểm loại bỏ các hộp dựa trên điểm số.
- soft_nms_sigma: Một tenxơ float 0-D biểu thị tham số sigma cho Soft NMS; xem Bodla và cộng sự (xem https://arxiv.org/abs/1704.04503 ). Khi
soft_nms_sigma=0.0
(là mặc định), chúng tôi quay lại NMS tiêu chuẩn (cứng).
Thuộc tính tùy chọn (xem Attrs
):
- pad_to_max_output_size: Nếu đúng, đầu ra
selected_indices
sẽ được đệm để có độ dài max_output_size
. Mặc định là sai.
Trả về:
-
Output
selected_indices: Một tenxơ số nguyên 1-D có hình dạng [M]
biểu thị các chỉ số đã chọn từ tenxơ hộp, trong đó M <= max_output_size
. -
Output
đã chọn_scores: Một tenxơ float 1-D có hình dạng [M]
biểu thị điểm tương ứng cho mỗi hộp được chọn, trong đó M <= max_output_size
. Điểm chỉ khác với điểm đầu vào tương ứng khi sử dụng Soft NMS (tức là khi soft_nms_sigma>0
) -
Output
valid_outputs: Một tenxơ số nguyên 0-D biểu thị số phần tử hợp lệ trong selected_indices
, với các phần tử hợp lệ xuất hiện đầu tiên.
Hàm tạo và hàm hủy |
---|
NonMaxSuppressionV5 (const :: tensorflow::Scope & scope, :: tensorflow::Input boxes, :: tensorflow::Input scores, :: tensorflow::Input max_output_size, :: tensorflow::Input iou_threshold, :: tensorflow::Input score_threshold, :: tensorflow::Input soft_nms_sigma)
|
NonMaxSuppressionV5 (const :: tensorflow::Scope & scope, :: tensorflow::Input boxes, :: tensorflow::Input scores, :: tensorflow::Input max_output_size, :: tensorflow::Input iou_threshold, :: tensorflow::Input score_threshold, :: tensorflow::Input soft_nms_sigma, const NonMaxSuppressionV5::Attrs & attrs) |
Thuộc tính công khai
Chức năng công cộng
Các hàm tĩnh công khai
PadToMaxKích thước đầu ra
Attrs PadToMaxOutputSize(
bool x
)
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# tensorflow::ops::NonMaxSuppressionV5 Class Reference\n\ntensorflow::ops::NonMaxSuppressionV5\n====================================\n\n`#include \u003cimage_ops.h\u003e`\n\nGreedily selects a subset of bounding boxes in descending order of score,.\n\nSummary\n-------\n\npruning away boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes with score less than `score_threshold` are removed. 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 and more generally 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_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices) This op also supports a Soft-NMS (with Gaussian weighting) mode (c.f. Bodla et al, \u003chttps://arxiv.org/abs/1704.04503\u003e) where boxes reduce the score of other overlapping boxes instead of directly causing them to be pruned. To enable this Soft-NMS mode, set the `soft_nms_sigma` parameter to be larger than 0.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- boxes: A 2-D float tensor of shape `[num_boxes, 4]`.\n- scores: A 1-D float tensor of shape `[num_boxes]` representing a single score corresponding to each box (each row of boxes).\n- max_output_size: A scalar integer tensor representing the maximum number of boxes to be selected by non max suppression.\n- iou_threshold: A 0-D float tensor representing the threshold for deciding whether boxes overlap too much with respect to IOU.\n- score_threshold: A 0-D float tensor representing the threshold for deciding when to remove boxes based on score.\n- soft_nms_sigma: A 0-D float tensor representing the sigma parameter for Soft NMS; see Bodla et al (c.f. \u003chttps://arxiv.org/abs/1704.04503\u003e). When `soft_nms_sigma=0.0` (which is default), we fall back to standard (hard) NMS.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/non-max-suppression-v5/attrs#structtensorflow_1_1ops_1_1_non_max_suppression_v5_1_1_attrs)):\n\n- pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length `max_output_size`. Defaults to false.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) selected_indices: A 1-D integer tensor of shape `[M]` representing the selected indices from the boxes tensor, where `M \u003c= max_output_size`.\n- [Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) selected_scores: A 1-D float tensor of shape `[M]` representing the corresponding scores for each selected box, where `M \u003c= max_output_size`. Scores only differ from corresponding input scores when using Soft NMS (i.e. when `soft_nms_sigma\u003e0`)\n- [Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) valid_outputs: A 0-D integer tensor representing the number of valid elements in `selected_indices`, with the valid elements appearing first.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [NonMaxSuppressionV5](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1a58f80a7976cd835a7edb22cdfbe9d52e)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` boxes, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` scores, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` max_output_size, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` iou_threshold, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` score_threshold, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` soft_nms_sigma)` ||\n| [NonMaxSuppressionV5](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1a01252b578e820021a7bd241b40164251)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` boxes, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` scores, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` max_output_size, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` iou_threshold, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` score_threshold, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` soft_nms_sigma, const `[NonMaxSuppressionV5::Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/non-max-suppression-v5/attrs#structtensorflow_1_1ops_1_1_non_max_suppression_v5_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1aa96dc249a5c111b383bada5507ebf994) | [Operation](/versions/r2.0/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [selected_indices](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1a7c287739ff4978fb784b56224b054b21) | `::`[tensorflow::Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [selected_scores](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1ab66338bc87549958c2b63ba5fd795530) | `::`[tensorflow::Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [valid_outputs](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1a4099ccdeda03b3fc9290a7391e811ace) | `::`[tensorflow::Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| [PadToMaxOutputSize](#classtensorflow_1_1ops_1_1_non_max_suppression_v5_1a6f6209fd08cfd3bd97ba74954009db05)`(bool x)` | [Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/non-max-suppression-v5/attrs#structtensorflow_1_1ops_1_1_non_max_suppression_v5_1_1_attrs) |\n\n| ### Structs ||\n|------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::NonMaxSuppressionV5::Attrs](/versions/r2.0/api_docs/cc/struct/tensorflow/ops/non-max-suppression-v5/attrs) | Optional attribute setters for [NonMaxSuppressionV5](/versions/r2.0/api_docs/cc/class/tensorflow/ops/non-max-suppression-v5#classtensorflow_1_1ops_1_1_non_max_suppression_v5). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### selected_indices\n\n```scdoc\n::tensorflow::Output selected_indices\n``` \n\n### selected_scores\n\n```scdoc\n::tensorflow::Output selected_scores\n``` \n\n### valid_outputs\n\n```scdoc\n::tensorflow::Output valid_outputs\n``` \n\nPublic functions\n----------------\n\n### NonMaxSuppressionV5\n\n```gdscript\n NonMaxSuppressionV5(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input boxes,\n ::tensorflow::Input scores,\n ::tensorflow::Input max_output_size,\n ::tensorflow::Input iou_threshold,\n ::tensorflow::Input score_threshold,\n ::tensorflow::Input soft_nms_sigma\n)\n``` \n\n### NonMaxSuppressionV5\n\n```gdscript\n NonMaxSuppressionV5(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input boxes,\n ::tensorflow::Input scores,\n ::tensorflow::Input max_output_size,\n ::tensorflow::Input iou_threshold,\n ::tensorflow::Input score_threshold,\n ::tensorflow::Input soft_nms_sigma,\n const NonMaxSuppressionV5::Attrs & attrs\n)\n``` \n\nPublic static functions\n-----------------------\n\n### PadToMaxOutputSize\n\n```text\nAttrs PadToMaxOutputSize(\n bool x\n)\n```"]]