Tensorflow.js是Google開發的開放源代碼庫,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
.image.nonMaxSuppressionAsync() 函數用於執行基於iou的限製框的非最大抑製,即交集。此外,它是 nonMaxSuppression() 方法的異步解釋。
用法:
tf.image.nonMaxSuppressionAsync(boxes, scores, maxOutputSize, iouThreshold?, scoreThreshold?)
Parameters:
- boxes:所述的二維張量,其配置為 [numBoxes, 4]。並且每次訪問都是 [y1, x1, y2, x2],允許 (y1, x1) 和 (y2, x2) 是限製框的邊。它可以是 tf.Tensor2D、TypedArray 或 Array 類型。
- scores:規定的一維張量,前提是框得分是配置 [numBoxes]。它是 tf.Tensor2D、TypedArray 或 Array 類型。
- maxOutputSize:它是要揀選的指定箱子的最大數量。它是類型號。
- iouThreshold:規定的浮點數表示閾值,以決定規定的框是否與 IOU 相交太多。它應該在 [0, 1] 的中間。默認值為 0.5,即 50% 的框相交。它是可選的,類型為 number。
- scoreThreshold:這是規定的閾值,以便根據規定的分數決定在哪些時間刪除框。默認值為 -inf,即允許每個分數。它是可選的,類型為 number。
返回值:它返回 tf.Tensor1D 的 Promise。
範例1:在此示例中,我們將使用 2d 張量、分數和 maxOutputSize 參數。
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling image.nonMaxSuppressionAsync() method
const output = await tf.image.nonMaxSuppressionAsync(
tf.tensor2d([1, 2, 3, 4, 2, 4, 6, 7],
[2, 4]), [1, 1], 4);
// Printing output
output.print();
輸出:
Tensor [0, 1]
範例2:在此示例中,我們將使用浮點數組 iouThreshold 和 scoreThreshold。
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Defining an array of floats
const arr = [[11.1, 2.3, 7.3, 6.4], [3, 6]]
// Calling image.nonMaxSuppressionAsync() method
const res = await tf.image.nonMaxSuppressionAsync(
arr, [2.1, 0], 100, 0.5, 1);
// Printing output
res.print();
輸出:
Tensor [0]
參考: https://js.tensorflow.org/api/latest/#image.nonMaxSuppressionAsync
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP Imagick floodFillPaintImage()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- Tensorflow.js tf.layers.embedding()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.image.nonMaxSuppressionAsync() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。