diff --git a/face-landmarks-detection/package.json b/face-landmarks-detection/package.json index 9e92f01f6c..b2eb5b2d34 100644 --- a/face-landmarks-detection/package.json +++ b/face-landmarks-detection/package.json @@ -1,6 +1,6 @@ { "name": "@tensorflow-models/face-landmarks-detection", - "version": "1.0.1", + "version": "1.0.2", "description": "Pretrained face landmarks detection model", "main": "dist/index.js", "jsnext:main": "dist/face-landmarks-detection.esm.js", diff --git a/face-landmarks-detection/src/tfjs/tfjs_test.ts b/face-landmarks-detection/src/tfjs/tfjs_test.ts index aeb6bf2b71..1df896ec92 100644 --- a/face-landmarks-detection/src/tfjs/tfjs_test.ts +++ b/face-landmarks-detection/src/tfjs/tfjs_test.ts @@ -149,25 +149,28 @@ describeWithFlags('TFJS FaceMesh static image ', BROWSER_ENVS, () => { tfjsResults .map( face => face.keypoints.map( - keypoint => [keypoint.x, keypoint.y, - keypoint.name] as [number, number, string])) + keypoint => [keypoint.x, keypoint.y, keypoint.z, + keypoint.name] as + [number, number, number, string])) .flat(); const mediapipeKeypoints = mediapipeResults .map( face => face.keypoints.map( - keypoint => [keypoint.x, keypoint.y, - keypoint.name] as [number, number, string])) + keypoint => [keypoint.x, keypoint.y, keypoint.z, + keypoint.name] as + [number, number, number, string])) .flat(); expectArraysClose( - tfjsKeypoints.map(keypoint => [keypoint[0], keypoint[1]]), - mediapipeKeypoints.map(keypoint => [keypoint[0], keypoint[1]]), + tfjsKeypoints.map(keypoint => [keypoint[0], keypoint[1], keypoint[2]]), + mediapipeKeypoints.map( + keypoint => [keypoint[0], keypoint[1], keypoint[2]]), EPSILON_IMAGE); expectArraysEqual( - tfjsKeypoints.map(keypoint => keypoint[2]), - mediapipeKeypoints.map(keypoint => keypoint[2])); + tfjsKeypoints.map(keypoint => keypoint[3]), + mediapipeKeypoints.map(keypoint => keypoint[3])); for (let i = 0; i < tfjsResults.length; i++) { for (const key of ['height', 'width', 'xMax', 'xMin', 'yMax', 'yMin'] as diff --git a/face-landmarks-detection/src/version.ts b/face-landmarks-detection/src/version.ts index 6f6a5102cb..74cccc5c1f 100644 --- a/face-landmarks-detection/src/version.ts +++ b/face-landmarks-detection/src/version.ts @@ -1,5 +1,5 @@ /** @license See the LICENSE file. */ // This code is auto-generated, do not modify this file! -const version = '1.0.1'; +const version = '1.0.2'; export {version}; diff --git a/shared/calculators/landmarks_refinement.ts b/shared/calculators/landmarks_refinement.ts index 861ea4ab94..0422ee8716 100644 --- a/shared/calculators/landmarks_refinement.ts +++ b/shared/calculators/landmarks_refinement.ts @@ -58,8 +58,9 @@ function refineXY( refinedLandmarks: Keypoint[]) { for (let i = 0; i < landmarks.length; ++i) { const landmark = landmarks[i]; - const refinedLandmark = {x: landmark.x, y: landmark.y}; - refinedLandmarks[indexesMapping[i]] = refinedLandmark; + const refinedLandmark = refinedLandmarks[indexesMapping[i]]; + refinedLandmark.x = landmark.x; + refinedLandmark.y = landmark.y; } } @@ -81,6 +82,7 @@ function refineZ( for (let i = 0; i < landmarks.length; ++i) { refinedLandmarks[indexesMapping[i]].z = landmarks[i].z; } + break; } case 'none': @@ -114,8 +116,8 @@ export function landmarksRefinement( refinements: LandmarksRefinementConfig[]): Keypoint[] { // Initialize refined landmarks list. const numRefinedLandmarks = getNumberOfRefinedLandmarks(refinements); - const refinedLandmarks: Keypoint[] = new Array(numRefinedLandmarks); - + const refinedLandmarks: Keypoint[] = + new Array(numRefinedLandmarks).fill(null).map(Object); // Apply input landmarks to output refined landmarks in provided order. for (let i = 0; i < allLandmarks.length; ++i) { const landmarks = allLandmarks[i]; @@ -135,7 +137,6 @@ export function landmarksRefinement( refineZ( refinement.indexesMapping, refinement.zRefinement, landmarks, refinedLandmarks); - // Visibility and presence are not currently refined and are left as `0`. }