fix movenet-multipose

pull/356/head
Vladimir Mandic 2023-02-28 15:03:46 -05:00
parent 073c6c519d
commit adbab08203
14 changed files with 1168 additions and 1161 deletions

View File

@ -9,8 +9,10 @@
## Changelog
### **HEAD -> main** 2023/02/22 mandic00@live.com
### **HEAD -> main** 2023/02/25 mandic00@live.com
- add electron detection
- fix gender-ssrnet-imdb
- add movenet-multipose workaround
- rebuild and publish
- add face.detector.minsize configurable setting

View File

@ -13,6 +13,7 @@ const Human = require('../../dist/human.node.js'); // use this when using human
const humanConfig = {
// add any custom config here
debug: true,
body: { enabled: false },
};
async function detect(inputFile) {

File diff suppressed because one or more lines are too long

12
dist/human.esm.js vendored
View File

@ -44234,6 +44234,8 @@ async function load17(config3) {
inputSize8 = (model18 == null ? void 0 : model18["executor"]) && ((_a2 = model18 == null ? void 0 : model18.inputs) == null ? void 0 : _a2[0].shape) ? model18.inputs[0].shape[2] : 0;
if (inputSize8 < 64)
inputSize8 = 256;
if (O().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS)
O().set("WEBGL_USE_SHAPES_UNIFORMS", false);
return model18;
}
function parseSinglePose(res, config3, image) {
@ -44276,12 +44278,11 @@ function parseSinglePose(res, config3, image) {
return bodies;
}
function parseMultiPose(res, config3, image) {
config3.body.minConfidence = -1;
const bodies = [];
for (let id2 = 0; id2 < res[0].length; id2++) {
const kpt4 = res[0][id2];
const totalScore = Math.round(100 * kpt4[51 + 4]) / 100;
if (totalScore > config3.body.minConfidence) {
const boxScore = Math.round(100 * kpt4[51 + 4]) / 100;
if (boxScore > config3.body.minConfidence) {
const keypoints = [];
for (let i = 0; i < 17; i++) {
const score = kpt4[3 * i + 2];
@ -44295,7 +44296,8 @@ function parseMultiPose(res, config3, image) {
});
}
}
const newBox = calc(keypoints.map((pt) => pt.position), [image.shape[2], image.shape[1]]);
const boxRaw = [kpt4[51 + 1], kpt4[51 + 0], kpt4[51 + 3] - kpt4[51 + 1], kpt4[51 + 2] - kpt4[51 + 0]];
const boxNorm = [Math.trunc(boxRaw[0] * (image.shape[2] || 0)), Math.trunc(boxRaw[1] * (image.shape[1] || 0)), Math.trunc(boxRaw[2] * (image.shape[2] || 0)), Math.trunc(boxRaw[3] * (image.shape[1] || 0))];
const annotations2 = {};
for (const [name, indexes] of Object.entries(connected3)) {
const pt = [];
@ -44307,7 +44309,7 @@ function parseMultiPose(res, config3, image) {
}
annotations2[name] = pt;
}
const body4 = { id: id2, score: totalScore, box: newBox.box, boxRaw: newBox.boxRaw, keypoints: [...keypoints], annotations: annotations2 };
const body4 = { id: id2, score: boxScore, box: boxNorm, boxRaw, keypoints: [...keypoints], annotations: annotations2 };
bodyParts(body4);
bodies.push(body4);
}

File diff suppressed because one or more lines are too long

86
dist/human.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

24
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

View File

@ -91,16 +91,16 @@
"@tensorflow/tfjs-layers": "^4.2.0",
"@tensorflow/tfjs-node": "^4.2.0",
"@tensorflow/tfjs-node-gpu": "^4.2.0",
"@types/node": "^18.14.1",
"@types/node": "^18.14.2",
"@types/offscreencanvas": "^2019.7.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"@vladmandic/build": "0.8.2",
"@vladmandic/pilogger": "^0.4.7",
"@vladmandic/tfjs": "github:vladmandic/tfjs",
"canvas": "^2.11.0",
"esbuild": "^0.17.10",
"eslint": "8.34.0",
"eslint": "8.35.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.27.5",
@ -110,7 +110,7 @@
"eslint-plugin-promise": "^6.1.1",
"rimraf": "^4.1.2",
"tslib": "^2.5.0",
"typedoc": "0.23.25",
"typedoc": "0.23.26",
"typescript": "4.9.5"
}
}

View File

@ -39,6 +39,8 @@ export async function load(config: Config): Promise<GraphModel> {
} else if (config.debug) log('cached model:', model['modelUrl']);
inputSize = (model?.['executor'] && model?.inputs?.[0].shape) ? model.inputs[0].shape[2] : 0;
if (inputSize < 64) inputSize = 256;
// @ts-ignore private property
if (tf.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS) tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', false); // default=false <https://github.com/tensorflow/tfjs/issues/5205>
return model;
}
@ -81,12 +83,11 @@ function parseSinglePose(res, config, image) {
}
function parseMultiPose(res, config, image) {
config.body.minConfidence = -1; // movenet-multipose return incorrect scores
const bodies: BodyResult[] = [];
for (let id = 0; id < res[0].length; id++) {
const kpt = res[0][id];
const totalScore = Math.round(100 * kpt[51 + 4]) / 100;
if (totalScore > config.body.minConfidence) {
const boxScore = Math.round(100 * kpt[51 + 4]) / 100;
if (boxScore > config.body.minConfidence) {
const keypoints: BodyKeypoint[] = [];
for (let i = 0; i < 17; i++) {
const score = kpt[3 * i + 2];
@ -100,10 +101,10 @@ function parseMultiPose(res, config, image) {
});
}
}
const newBox = box.calc(keypoints.map((pt) => pt.position), [image.shape[2], image.shape[1]]);
// const newBox = box.calc(keypoints.map((pt) => pt.position), [image.shape[2], image.shape[1]]);
// movenet-multipose has built-in box details
// const boxRaw: Box = [kpt[51 + 1], kpt[51 + 0], kpt[51 + 3] - kpt[51 + 1], kpt[51 + 2] - kpt[51 + 0]];
// const box: Box = [Math.trunc(boxRaw[0] * (image.shape[2] || 0)), Math.trunc(boxRaw[1] * (image.shape[1] || 0)), Math.trunc(boxRaw[2] * (image.shape[2] || 0)), Math.trunc(boxRaw[3] * (image.shape[1] || 0))];
const boxRaw: Box = [kpt[51 + 1], kpt[51 + 0], kpt[51 + 3] - kpt[51 + 1], kpt[51 + 2] - kpt[51 + 0]];
const boxNorm: Box = [Math.trunc(boxRaw[0] * (image.shape[2] || 0)), Math.trunc(boxRaw[1] * (image.shape[1] || 0)), Math.trunc(boxRaw[2] * (image.shape[2] || 0)), Math.trunc(boxRaw[3] * (image.shape[1] || 0))];
const annotations: Record<BodyAnnotation, Point[][]> = {} as Record<BodyAnnotation, Point[][]>;
for (const [name, indexes] of Object.entries(coords.connected)) {
const pt: Point[][] = [];
@ -114,7 +115,8 @@ function parseMultiPose(res, config, image) {
}
annotations[name] = pt;
}
const body: BodyResult = { id, score: totalScore, box: newBox.box, boxRaw: newBox.boxRaw, keypoints: [...keypoints], annotations };
// const body: BodyResult = { id, score: totalScore, box: newBox.box, boxRaw: newBox.boxRaw, keypoints: [...keypoints], annotations };
const body: BodyResult = { id, score: boxScore, box: boxNorm, boxRaw, keypoints: [...keypoints], annotations };
fix.bodyParts(body);
bodies.push(body);
}

View File

@ -1,50 +1,50 @@
2023-02-25 09:37:18 DATA:  Build {"name":"@vladmandic/human","version":"3.0.5"}
2023-02-25 09:37:18 INFO:  Application: {"name":"@vladmandic/human","version":"3.0.5"}
2023-02-25 09:37:18 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2023-02-25 09:37:18 INFO:  Toolchain: {"build":"0.8.2","esbuild":"0.17.10","typescript":"4.9.5","typedoc":"0.23.25","eslint":"8.34.0"}
2023-02-25 09:37:18 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2023-02-25 09:37:18 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1289,"outputBytes":361}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":569,"outputBytes":924}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":80,"inputBytes":672881,"outputBytes":319360}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":577,"outputBytes":928}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":80,"inputBytes":672885,"outputBytes":319364}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":665,"outputBytes":1876}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":80,"inputBytes":673833,"outputBytes":319475}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1375,"outputBytes":670}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":80,"inputBytes":672627,"outputBytes":317930}
2023-02-25 09:37:18 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":10,"inputBytes":1375,"outputBytes":1151306}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":80,"inputBytes":1823263,"outputBytes":1465170}
2023-02-25 09:37:18 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":80,"inputBytes":1823263,"outputBytes":1932346}
2023-02-25 09:37:23 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15}
2023-02-25 09:37:26 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":81,"generated":true}
2023-02-25 09:37:26 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6162,"outputBytes":2901}
2023-02-25 09:37:26 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17503,"outputBytes":9403}
2023-02-25 09:37:35 STATE: Lint: {"locations":["**/*.json","src/**/*.ts","test/**/*.js","demo/**/*.js","**/*.md"],"files":170,"errors":0,"warnings":0}
2023-02-25 09:37:36 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2023-02-25 09:37:36 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs-core.d.ts","output":"types/tfjs-core.d.ts"}
2023-02-25 09:37:36 INFO:  Done...
2023-02-25 09:37:36 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs.d.ts","output":"types/tfjs.esm.d.ts"}
2023-02-25 09:37:36 STATE: Copy: {"input":"src/types/tsconfig.json","output":"types/tsconfig.json"}
2023-02-25 09:37:36 STATE: Copy: {"input":"src/types/eslint.json","output":"types/.eslintrc.json"}
2023-02-25 09:37:36 STATE: Copy: {"input":"src/types/tfjs.esm.d.ts","output":"dist/tfjs.esm.d.ts"}
2023-02-25 09:37:36 STATE: Filter: {"input":"types/tfjs-core.d.ts"}
2023-02-25 09:37:37 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":210}
2023-02-25 09:37:37 STATE: Filter: {"input":"types/human.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.esm-nobundle.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.esm.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.node-gpu.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.node.d.ts"}
2023-02-25 09:37:37 STATE: Write: {"output":"dist/human.node-wasm.d.ts"}
2023-02-25 09:37:37 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2023-02-25 09:37:37 STATE: Models {"folder":"./models","models":12}
2023-02-25 09:37:37 STATE: Models {"folder":"../human-models/models","models":44}
2023-02-25 09:37:37 STATE: Models {"folder":"../blazepose/model/","models":4}
2023-02-25 09:37:37 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2023-02-25 09:37:37 STATE: Models {"folder":"../efficientpose/models","models":3}
2023-02-25 09:37:37 STATE: Models {"folder":"../insightface/models","models":5}
2023-02-25 09:37:37 STATE: Models {"folder":"../movenet/models","models":3}
2023-02-25 09:37:37 STATE: Models {"folder":"../nanodet/models","models":4}
2023-02-25 09:37:38 STATE: Models: {"count":58,"totalSize":380063249}
2023-02-25 09:37:38 INFO:  Human Build complete... {"logFile":"test/build.log"}
2023-02-28 14:59:24 DATA:  Build {"name":"@vladmandic/human","version":"3.0.5"}
2023-02-28 14:59:24 INFO:  Application: {"name":"@vladmandic/human","version":"3.0.5"}
2023-02-28 14:59:24 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2023-02-28 14:59:24 INFO:  Toolchain: {"build":"0.8.2","esbuild":"0.17.10","typescript":"4.9.5","typedoc":"0.23.26","eslint":"8.35.0"}
2023-02-28 14:59:24 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2023-02-28 14:59:24 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1289,"outputBytes":361}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":569,"outputBytes":924}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":80,"inputBytes":673124,"outputBytes":319556}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":577,"outputBytes":928}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":80,"inputBytes":673128,"outputBytes":319560}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":665,"outputBytes":1876}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":80,"inputBytes":674076,"outputBytes":319671}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1375,"outputBytes":670}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":80,"inputBytes":672870,"outputBytes":318124}
2023-02-28 14:59:24 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":10,"inputBytes":1375,"outputBytes":1151306}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":80,"inputBytes":1823506,"outputBytes":1465356}
2023-02-28 14:59:24 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":80,"inputBytes":1823506,"outputBytes":1932610}
2023-02-28 14:59:28 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15}
2023-02-28 14:59:31 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":81,"generated":true}
2023-02-28 14:59:31 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6162,"outputBytes":2901}
2023-02-28 14:59:31 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17503,"outputBytes":9403}
2023-02-28 14:59:41 STATE: Lint: {"locations":["**/*.json","src/**/*.ts","test/**/*.js","demo/**/*.js","**/*.md"],"files":170,"errors":0,"warnings":0}
2023-02-28 14:59:42 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2023-02-28 14:59:42 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs-core.d.ts","output":"types/tfjs-core.d.ts"}
2023-02-28 14:59:42 INFO:  Done...
2023-02-28 14:59:42 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs.d.ts","output":"types/tfjs.esm.d.ts"}
2023-02-28 14:59:42 STATE: Copy: {"input":"src/types/tsconfig.json","output":"types/tsconfig.json"}
2023-02-28 14:59:42 STATE: Copy: {"input":"src/types/eslint.json","output":"types/.eslintrc.json"}
2023-02-28 14:59:42 STATE: Copy: {"input":"src/types/tfjs.esm.d.ts","output":"dist/tfjs.esm.d.ts"}
2023-02-28 14:59:42 STATE: Filter: {"input":"types/tfjs-core.d.ts"}
2023-02-28 14:59:43 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":210}
2023-02-28 14:59:43 STATE: Filter: {"input":"types/human.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.esm-nobundle.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.esm.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.node-gpu.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.node.d.ts"}
2023-02-28 14:59:43 STATE: Write: {"output":"dist/human.node-wasm.d.ts"}
2023-02-28 14:59:43 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2023-02-28 14:59:43 STATE: Models {"folder":"./models","models":12}
2023-02-28 14:59:43 STATE: Models {"folder":"../human-models/models","models":44}
2023-02-28 14:59:43 STATE: Models {"folder":"../blazepose/model/","models":4}
2023-02-28 14:59:43 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2023-02-28 14:59:43 STATE: Models {"folder":"../efficientpose/models","models":3}
2023-02-28 14:59:43 STATE: Models {"folder":"../insightface/models","models":5}
2023-02-28 14:59:43 STATE: Models {"folder":"../movenet/models","models":3}
2023-02-28 14:59:43 STATE: Models {"folder":"../nanodet/models","models":4}
2023-02-28 14:59:43 STATE: Models: {"count":58,"totalSize":380063249}
2023-02-28 14:59:43 INFO:  Human Build complete... {"logFile":"test/build.log"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long