Add .close() method to ImageSegmenterResult/InteractiveSegmenterResult/PoseLandmarkerResult

PiperOrigin-RevId: 530973944
This commit is contained in:
Sebastian Schmidt
2023-05-10 12:37:48 -07:00
committed by Copybara-Service
parent a7ede9235c
commit 1666f3ed80
9 changed files with 133 additions and 138 deletions
@@ -17,18 +17,26 @@
import {MPMask} from '../../../../tasks/web/vision/core/mask';
/** The output result of InteractiveSegmenter. */
export declare interface InteractiveSegmenterResult {
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
*/
confidenceMasks?: MPMask[];
export class InteractiveSegmenterResult {
constructor(
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
*/
readonly confidenceMasks?: MPMask[],
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
* which the pixel in the original image was predicted to belong to.
*/
readonly categoryMask?: MPMask) {}
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class which
* the pixel in the original image was predicted to belong to.
*/
categoryMask?: MPMask;
/** Frees the resources held by the category and confidence masks. */
close(): void {
this.confidenceMasks?.forEach(m => {
m.close();
});
this.categoryMask?.close();
}
}