Tensorflow.js是Google開發的開放源代碼庫,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
.image.nonMaxSuppressionPadded() 函數用於基於 iou 異步執行限製框的非最大抑製,即聯合的交集以及填充結果的機會。
用法:
tf.image.nonMaxSuppressionPadded(boxes, scores, maxOutputSize, iouThreshold?, scoreThreshold?, padToMaxOutputSize?)
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。
- padToMaxOutputSize:它是布爾類型的可選參數。默認值為 false。如果為真,則結果 selectedIndices 的維度將填充到 maxOutputSize。
返回值:它返回 {[name:string]:tf.Tensor}。
範例1:在此示例中,我們將使用 2d 張量、分數和 maxOutputSize 參數。
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling image.nonMaxSuppressionPadded() method
const output = tf.image.nonMaxSuppressionPadded(
tf.tensor2d([1, 2, 3, 4, 2, 4, 6, 7],
[2, 4]), [1, 1], 4
);
// Printing output
console.log(output);
輸出:
{ "selectedIndices":{ "kept":false, "isDisposedInternal":false, "shape":[ 2 ], "dtype":"int32", "size":2, "strides":[], "dataId":{ "id":22 }, "id":22, "rankType":"1", "scopeId":12 }, "validOutputs":{ "kept":false, "isDisposedInternal":false, "shape":[], "dtype":"int32", "size":1, "strides":[], "dataId":{ "id":23 }, "id":23, "rankType":"0", "scopeId":12 } }
範例2:在此示例中,我們將使用浮點數數組 iouThreshold、scoreThreshold 以及 padToMaxOutputSize。
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.nonMaxSuppressionPadded() method
const res = tf.image.nonMaxSuppressionPadded(
arr, [2.1, 0], 100, 0.5, 1, true);
// Printing output
console.log(res);
輸出:
{ "selectedIndices":{ "kept":false, "isDisposedInternal":false, "shape":[ 2 ], "dtype":"int32", "size":2, "strides":[], "dataId":{ "id":42 }, "id":42, "rankType":"1", "scopeId":22 }, "validOutputs":{ "kept":false, "isDisposedInternal":false, "shape":[], "dtype":"int32", "size":1, "strides":[], "dataId":{ "id":43 }, "id":43, "rankType":"0", "scopeId":22 } }
參考: https://js.tensorflow.org/api/latest/#image.nonMaxSuppressionPadded
相關用法
- 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.nonMaxSuppressionPadded() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。