UNPKG

2.77 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * =============================================================================
16 */
17/// <amd-module name="@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_with_score" />
18import { Tensor1D, Tensor2D } from '../../tensor';
19import { NamedTensorMap } from '../../tensor_types';
20import { TensorLike } from '../../types';
21/**
22 * Performs non maximum suppression of bounding boxes based on
23 * iou (intersection over union).
24 *
25 * This op also supports a Soft-NMS mode (c.f.
26 * Bodla et al, https://arxiv.org/abs/1704.04503) where boxes reduce the score
27 * of other overlapping boxes, therefore favoring different regions of the image
28 * with high scores. To enable this Soft-NMS mode, set the `softNmsSigma`
29 * parameter to be larger than 0.
30 *
31 * @param boxes a 2d tensor of shape `[numBoxes, 4]`. Each entry is
32 * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the corners of
33 * the bounding box.
34 * @param scores a 1d tensor providing the box scores of shape `[numBoxes]`.
35 * @param maxOutputSize The maximum number of boxes to be selected.
36 * @param iouThreshold A float representing the threshold for deciding whether
37 * boxes overlap too much with respect to IOU. Must be between [0, 1].
38 * Defaults to 0.5 (50% box overlap).
39 * @param scoreThreshold A threshold for deciding when to remove boxes based
40 * on score. Defaults to -inf, which means any score is accepted.
41 * @param softNmsSigma A float representing the sigma parameter for Soft NMS.
42 * When sigma is 0, it falls back to nonMaxSuppression.
43 * @return A map with the following properties:
44 * - selectedIndices: A 1D tensor with the selected box indices.
45 * - selectedScores: A 1D tensor with the corresponding scores for each
46 * selected box.
47 *
48 * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'}
49 */
50declare function nonMaxSuppressionWithScore_(boxes: Tensor2D | TensorLike, scores: Tensor1D | TensorLike, maxOutputSize: number, iouThreshold?: number, scoreThreshold?: number, softNmsSigma?: number): NamedTensorMap;
51export declare const nonMaxSuppressionWithScore: typeof nonMaxSuppressionWithScore_;
52export {};