@mediapipe/tasks-vision 0.1.0-alpha-7 → 0.1.0-alpha-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/package.json +1 -1
- package/vision.d.ts +185 -8
- package/vision_bundle.js +1 -1
- package/wasm/vision_wasm_internal.js +305 -285
- package/wasm/vision_wasm_internal.wasm +0 -0
- package/wasm/vision_wasm_nosimd_internal.js +312 -292
- package/wasm/vision_wasm_nosimd_internal.wasm +0 -0
package/README.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
This package contains the vision tasks for MediaPipe.
|
|
4
4
|
|
|
5
|
+
## Face Detection
|
|
6
|
+
|
|
7
|
+
The MediaPipe Face Detector task lets you detect the presence and location of
|
|
8
|
+
faces within images or videos.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
const vision = await FilesetResolver.forVisionTasks(
|
|
12
|
+
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
|
|
13
|
+
);
|
|
14
|
+
const faceDetector = await FaceDetector.createFromModelPath(vision,
|
|
15
|
+
"https://storage.googleapis.com/mediapipe-tasks/object_detector/efficientdet_lite0_uint8.tflite"
|
|
16
|
+
);
|
|
17
|
+
const image = document.getElementById("image") as HTMLImageElement;
|
|
18
|
+
const detections = faceDetector.detect(image);
|
|
19
|
+
```
|
|
20
|
+
|
|
5
21
|
## Face Landmark Detection
|
|
6
22
|
|
|
7
23
|
The MediaPipe Face Landmarker task lets you detect the landmarks of faces in
|
package/package.json
CHANGED
package/vision.d.ts
CHANGED
|
@@ -29,6 +29,21 @@ declare interface BaseOptions_2 {
|
|
|
29
29
|
delegate?: "CPU" | "GPU" | undefined;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Copyright 2023 The MediaPipe Authors. All Rights Reserved.
|
|
34
|
+
*
|
|
35
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License.
|
|
37
|
+
* You may obtain a copy of the License at
|
|
38
|
+
*
|
|
39
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
+
*
|
|
41
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
+
* See the License for the specific language governing permissions and
|
|
45
|
+
* limitations under the License.
|
|
46
|
+
*/
|
|
32
47
|
/** An integer bounding box, axis aligned. */
|
|
33
48
|
export declare interface BoundingBox {
|
|
34
49
|
/** The X coordinate of the top-left corner, in pixels. */
|
|
@@ -138,13 +153,50 @@ declare interface ClassifierOptions {
|
|
|
138
153
|
categoryDenylist?: string[] | undefined;
|
|
139
154
|
}
|
|
140
155
|
|
|
141
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* CopyRIGHT 2023 The MediaPipe Authors. All RIGHTs Reserved.
|
|
158
|
+
*
|
|
159
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
160
|
+
* you may not use this file except in compliance with the License.
|
|
161
|
+
* You may obtain a copy of the License at
|
|
162
|
+
*
|
|
163
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
164
|
+
*
|
|
165
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
166
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
167
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
168
|
+
* See the License for the specific language governing permissions and
|
|
169
|
+
* limitations under the License.
|
|
170
|
+
*/
|
|
171
|
+
/** A face landmark connection. */
|
|
172
|
+
export declare interface Connection {
|
|
173
|
+
start: number;
|
|
174
|
+
end: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Represents one detection by a detection task. */
|
|
142
178
|
export declare interface Detection {
|
|
143
179
|
/** A list of `Category` objects. */
|
|
144
180
|
categories: Category[];
|
|
145
181
|
/** The bounding box of the detected objects. */
|
|
146
182
|
boundingBox?: BoundingBox;
|
|
183
|
+
/**
|
|
184
|
+
* Optional list of keypoints associated with the detection. Keypoints
|
|
185
|
+
* represent interesting points related to the detection. For example, the
|
|
186
|
+
* keypoints represent the eye, ear and mouth from face detection model. Or
|
|
187
|
+
* in the template matching detection, e.g. KNIFT, they can represent the
|
|
188
|
+
* feature points for template matching.
|
|
189
|
+
*/
|
|
190
|
+
keypoints?: NormalizedKeypoint[];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Detection results of a model. */
|
|
194
|
+
declare interface DetectionResult {
|
|
195
|
+
/** A list of Detections. */
|
|
196
|
+
detections: Detection[];
|
|
147
197
|
}
|
|
198
|
+
export { DetectionResult as FaceDetectorResult }
|
|
199
|
+
export { DetectionResult as ObjectDetectorResult }
|
|
148
200
|
|
|
149
201
|
/**
|
|
150
202
|
* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
|
|
@@ -224,6 +276,84 @@ export declare interface Embedding {
|
|
|
224
276
|
headName: string;
|
|
225
277
|
}
|
|
226
278
|
|
|
279
|
+
/** Performs face detection on images. */
|
|
280
|
+
export declare class FaceDetector extends VisionTaskRunner {
|
|
281
|
+
/**
|
|
282
|
+
* Initializes the Wasm runtime and creates a new face detector from the
|
|
283
|
+
* provided options.
|
|
284
|
+
* @param wasmFileset A configuration object that provides the location of the
|
|
285
|
+
* Wasm binary and its loader.
|
|
286
|
+
* @param faceDetectorOptions The options for the FaceDetector. Note that
|
|
287
|
+
* either a path to the model asset or a model buffer needs to be
|
|
288
|
+
* provided (via `baseOptions`).
|
|
289
|
+
*/
|
|
290
|
+
static createFromOptions(wasmFileset: WasmFileset, faceDetectorOptions: FaceDetectorOptions): Promise<FaceDetector>;
|
|
291
|
+
/**
|
|
292
|
+
* Initializes the Wasm runtime and creates a new face detector based on the
|
|
293
|
+
* provided model asset buffer.
|
|
294
|
+
* @param wasmFileset A configuration object that provides the location of the
|
|
295
|
+
* Wasm binary and its loader.
|
|
296
|
+
* @param modelAssetBuffer A binary representation of the model.
|
|
297
|
+
*/
|
|
298
|
+
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceDetector>;
|
|
299
|
+
/**
|
|
300
|
+
* Initializes the Wasm runtime and creates a new face detector based on the
|
|
301
|
+
* path to the model asset.
|
|
302
|
+
* @param wasmFileset A configuration object that provides the location of the
|
|
303
|
+
* Wasm binary and its loader.
|
|
304
|
+
* @param modelAssetPath The path to the model asset.
|
|
305
|
+
*/
|
|
306
|
+
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceDetector>;
|
|
307
|
+
private constructor();
|
|
308
|
+
/**
|
|
309
|
+
* Sets new options for the FaceDetector.
|
|
310
|
+
*
|
|
311
|
+
* Calling `setOptions()` with a subset of options only affects those options.
|
|
312
|
+
* You can reset an option back to its default value by explicitly setting it
|
|
313
|
+
* to `undefined`.
|
|
314
|
+
*
|
|
315
|
+
* @param options The options for the FaceDetector.
|
|
316
|
+
*/
|
|
317
|
+
setOptions(options: FaceDetectorOptions): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Performs face detection on the provided single image and waits
|
|
320
|
+
* synchronously for the response. Only use this method when the
|
|
321
|
+
* FaceDetector is created with running mode `image`.
|
|
322
|
+
*
|
|
323
|
+
* @param image An image to process.
|
|
324
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
325
|
+
* to process the input image before running inference.
|
|
326
|
+
* @return A result containing the list of detected faces.
|
|
327
|
+
*/
|
|
328
|
+
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
|
|
329
|
+
/**
|
|
330
|
+
* Performs face detection on the provided video frame and waits
|
|
331
|
+
* synchronously for the response. Only use this method when the
|
|
332
|
+
* FaceDetector is created with running mode `video`.
|
|
333
|
+
*
|
|
334
|
+
* @param videoFrame A video frame to process.
|
|
335
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
336
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
337
|
+
* to process the input image before running inference.
|
|
338
|
+
* @return A result containing the list of detected faces.
|
|
339
|
+
*/
|
|
340
|
+
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Options to configure the MediaPipe Face Detector Task */
|
|
344
|
+
export declare interface FaceDetectorOptions extends VisionTaskOptions {
|
|
345
|
+
/**
|
|
346
|
+
* The minimum confidence score for the face detection to be considered
|
|
347
|
+
* successful. Defaults to 0.5.
|
|
348
|
+
*/
|
|
349
|
+
minDetectionConfidence?: number | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* The minimum non-maximum-suppression threshold for face detection to be
|
|
352
|
+
* considered overlapped. Defaults to 0.3.
|
|
353
|
+
*/
|
|
354
|
+
minSuppressionThreshold?: number | undefined;
|
|
355
|
+
}
|
|
356
|
+
|
|
227
357
|
/**
|
|
228
358
|
* Performs face landmarks detection on images.
|
|
229
359
|
*
|
|
@@ -340,6 +470,53 @@ export declare interface FaceLandmarkerResult {
|
|
|
340
470
|
facialTransformationMatrixes?: Matrix[];
|
|
341
471
|
}
|
|
342
472
|
|
|
473
|
+
/**
|
|
474
|
+
* A class containing the Pairs of landmark indices to be rendered with
|
|
475
|
+
* connections.
|
|
476
|
+
*/
|
|
477
|
+
export declare class FaceLandmarksConnections {
|
|
478
|
+
static FACE_LANDMARKS_LIPS: {
|
|
479
|
+
start: number;
|
|
480
|
+
end: number;
|
|
481
|
+
}[];
|
|
482
|
+
static FACE_LANDMARKS_LEFT_EYE: {
|
|
483
|
+
start: number;
|
|
484
|
+
end: number;
|
|
485
|
+
}[];
|
|
486
|
+
static FACE_LANDMARKS_LEFT_EYEBROW: {
|
|
487
|
+
start: number;
|
|
488
|
+
end: number;
|
|
489
|
+
}[];
|
|
490
|
+
static FACE_LANDMARKS_LEFT_IRIS: {
|
|
491
|
+
start: number;
|
|
492
|
+
end: number;
|
|
493
|
+
}[];
|
|
494
|
+
static FACE_LANDMARKS_RIGHT_EYE: {
|
|
495
|
+
start: number;
|
|
496
|
+
end: number;
|
|
497
|
+
}[];
|
|
498
|
+
static FACE_LANDMARKS_RIGHT_EYEBROW: {
|
|
499
|
+
start: number;
|
|
500
|
+
end: number;
|
|
501
|
+
}[];
|
|
502
|
+
static FACE_LANDMARKS_RIGHT_IRIS: {
|
|
503
|
+
start: number;
|
|
504
|
+
end: number;
|
|
505
|
+
}[];
|
|
506
|
+
static FACE_LANDMARKS_FACE_OVAL: {
|
|
507
|
+
start: number;
|
|
508
|
+
end: number;
|
|
509
|
+
}[];
|
|
510
|
+
static FACE_LANDMARKS_CONTOURS: {
|
|
511
|
+
start: number;
|
|
512
|
+
end: number;
|
|
513
|
+
}[];
|
|
514
|
+
static FACE_LANDMARKS_TESSELATION: {
|
|
515
|
+
start: number;
|
|
516
|
+
end: number;
|
|
517
|
+
}[];
|
|
518
|
+
}
|
|
519
|
+
|
|
343
520
|
/** Performs face stylization on images. */
|
|
344
521
|
export declare class FaceStylizer extends VisionTaskRunner {
|
|
345
522
|
/**
|
|
@@ -1254,7 +1431,7 @@ export declare interface Landmark {
|
|
|
1254
1431
|
* See the License for the specific language governing permissions and
|
|
1255
1432
|
* limitations under the License.
|
|
1256
1433
|
*/
|
|
1257
|
-
/** A two-
|
|
1434
|
+
/** A two-dimensional matrix. */
|
|
1258
1435
|
declare interface Matrix {
|
|
1259
1436
|
/** The number of rows. */
|
|
1260
1437
|
rows: number;
|
|
@@ -1372,9 +1549,9 @@ export declare class ObjectDetector extends VisionTaskRunner {
|
|
|
1372
1549
|
* @param image An image to process.
|
|
1373
1550
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1374
1551
|
* to process the input image before running inference.
|
|
1375
|
-
* @return
|
|
1552
|
+
* @return A result containing a list of detected objects.
|
|
1376
1553
|
*/
|
|
1377
|
-
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions):
|
|
1554
|
+
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
|
|
1378
1555
|
/**
|
|
1379
1556
|
* Performs object detection on the provided video frame and waits
|
|
1380
1557
|
* synchronously for the response. Only use this method when the
|
|
@@ -1384,9 +1561,9 @@ export declare class ObjectDetector extends VisionTaskRunner {
|
|
|
1384
1561
|
* @param timestamp The timestamp of the current frame, in ms.
|
|
1385
1562
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1386
1563
|
* to process the input image before running inference.
|
|
1387
|
-
* @return
|
|
1564
|
+
* @return A result containing a list of detected objects.
|
|
1388
1565
|
*/
|
|
1389
|
-
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions):
|
|
1566
|
+
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
|
|
1390
1567
|
}
|
|
1391
1568
|
|
|
1392
1569
|
/** Options to configure the MediaPipe Object Detector Task */
|
|
@@ -1424,7 +1601,7 @@ declare type RunningMode = "IMAGE" | "VIDEO";
|
|
|
1424
1601
|
/**
|
|
1425
1602
|
* The segmentation tasks return the segmentation either as a WebGLTexture (when
|
|
1426
1603
|
* the output is on GPU) or as a typed JavaScript arrays for CPU-based
|
|
1427
|
-
* category or confidence masks. `Uint8ClampedArray`s are used to
|
|
1604
|
+
* category or confidence masks. `Uint8ClampedArray`s are used to represent
|
|
1428
1605
|
* CPU-based category masks and `Float32Array`s are used for CPU-based
|
|
1429
1606
|
* confidence masks.
|
|
1430
1607
|
*/
|
|
@@ -1457,7 +1634,7 @@ declare interface TaskRunnerOptions {
|
|
|
1457
1634
|
declare interface VisionTaskOptions extends TaskRunnerOptions {
|
|
1458
1635
|
/**
|
|
1459
1636
|
* The canvas element to bind textures to. This has to be set for GPU
|
|
1460
|
-
* processing. The task will initialize a WebGL context and throw an
|
|
1637
|
+
* processing. The task will initialize a WebGL context and throw an error if
|
|
1461
1638
|
* this fails (e.g. if you have already initialized a different type of
|
|
1462
1639
|
* context).
|
|
1463
1640
|
*/
|