mirror of https://github.com/vladmandic/human
minor blazepose optimizations
parent
053fa03723
commit
b9915569d3
|
@ -9,7 +9,12 @@
|
|||
|
||||
## Changelog
|
||||
|
||||
### **HEAD -> main** 2021/10/13 mandic00@live.com
|
||||
### **HEAD -> main** 2021/10/15 mandic00@live.com
|
||||
|
||||
- remove handdetect from default package
|
||||
- remove posenet from default package
|
||||
|
||||
### **origin/main** 2021/10/14 mandic00@live.com
|
||||
|
||||
- use transferrable buffer for worker messages
|
||||
- add optional anti-spoofing module
|
||||
|
|
3
TODO.md
3
TODO.md
|
@ -6,9 +6,6 @@
|
|||
|
||||
### Models
|
||||
|
||||
- Optimize BlazePose
|
||||
- Add BlazePose heatmaps
|
||||
|
||||
<br>
|
||||
|
||||
### Backends
|
||||
|
|
|
@ -31,9 +31,9 @@ import jsonView from './helpers/jsonview.js';
|
|||
let human;
|
||||
|
||||
let userConfig = {
|
||||
face: { enabled: false },
|
||||
body: { enabled: true, modelPath: '../../human-models/models/blazepose-lite.json' },
|
||||
hand: { enabled: false },
|
||||
// face: { enabled: false },
|
||||
// body: { enabled: false },
|
||||
// hand: { enabled: false },
|
||||
/*
|
||||
warmup: 'none',
|
||||
backend: 'humangl',
|
||||
|
|
|
@ -4945,22 +4945,26 @@ function rescaleKeypoints(keypoints, outputSize2) {
|
|||
}
|
||||
return keypoints;
|
||||
}
|
||||
var sigmoid2 = (x) => 1 - 1 / (1 + Math.exp(x));
|
||||
async function detectParts(input, config3, outputSize2) {
|
||||
var _a;
|
||||
const t = {};
|
||||
t.input = await prepareImage(input);
|
||||
[t.ld, t.segmentation, t.heatmap, t.world, t.poseflag] = await ((_a = models[1]) == null ? void 0 : _a.execute(t.input, outputNodes));
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8));
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative = [];
|
||||
const depth = 5;
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100;
|
||||
const score = sigmoid2(points[depth * i + 3]);
|
||||
const presence = sigmoid2(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw = [points[depth * i + 0] / inputSize2[1][0], points[depth * i + 1] / inputSize2[1][1], points[depth * i + 2] + 0];
|
||||
const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100;
|
||||
if (avgScore < (config3.body.minConfidence || 0))
|
||||
if (poseScore < (config3.body.minConfidence || 0))
|
||||
return null;
|
||||
const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
|
||||
const boxes = calculateBoxes(keypoints, [outputSize2[0], outputSize2[1]]);
|
||||
|
@ -4976,11 +4980,12 @@ async function detectParts(input, config3, outputSize2) {
|
|||
}
|
||||
annotations2[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
return body4;
|
||||
}
|
||||
async function predict2(input, config3) {
|
||||
const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame) {
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame && cache !== null) {
|
||||
skipped3++;
|
||||
} else {
|
||||
cache = await detectParts(input, config3, outputSize2);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -72434,22 +72434,26 @@ function rescaleKeypoints(keypoints, outputSize2) {
|
|||
}
|
||||
return keypoints;
|
||||
}
|
||||
var sigmoid6 = (x) => 1 - 1 / (1 + Math.exp(x));
|
||||
async function detectParts(input2, config3, outputSize2) {
|
||||
var _a;
|
||||
const t = {};
|
||||
t.input = await prepareImage(input2);
|
||||
[t.ld, t.segmentation, t.heatmap, t.world, t.poseflag] = await ((_a = models[1]) == null ? void 0 : _a.execute(t.input, outputNodes));
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8));
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative = [];
|
||||
const depth = 5;
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100;
|
||||
const score = sigmoid6(points[depth * i + 3]);
|
||||
const presence = sigmoid6(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw = [points[depth * i + 0] / inputSize2[1][0], points[depth * i + 1] / inputSize2[1][1], points[depth * i + 2] + 0];
|
||||
const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100;
|
||||
if (avgScore < (config3.body.minConfidence || 0))
|
||||
if (poseScore < (config3.body.minConfidence || 0))
|
||||
return null;
|
||||
const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
|
||||
const boxes = calculateBoxes(keypoints, [outputSize2[0], outputSize2[1]]);
|
||||
|
@ -72465,11 +72469,12 @@ async function detectParts(input2, config3, outputSize2) {
|
|||
}
|
||||
annotations2[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
return body4;
|
||||
}
|
||||
async function predict2(input2, config3) {
|
||||
const outputSize2 = [input2.shape[2] || 0, input2.shape[1] || 0];
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame) {
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame && cache !== null) {
|
||||
skipped3++;
|
||||
} else {
|
||||
cache = await detectParts(input2, config3, outputSize2);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4977,22 +4977,26 @@ function rescaleKeypoints(keypoints, outputSize2) {
|
|||
}
|
||||
return keypoints;
|
||||
}
|
||||
var sigmoid2 = (x) => 1 - 1 / (1 + Math.exp(x));
|
||||
async function detectParts(input, config3, outputSize2) {
|
||||
var _a;
|
||||
const t = {};
|
||||
t.input = await prepareImage(input);
|
||||
[t.ld, t.segmentation, t.heatmap, t.world, t.poseflag] = await ((_a = models[1]) == null ? void 0 : _a.execute(t.input, outputNodes));
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8));
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative = [];
|
||||
const depth = 5;
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100;
|
||||
const score = sigmoid2(points[depth * i + 3]);
|
||||
const presence = sigmoid2(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw = [points[depth * i + 0] / inputSize2[1][0], points[depth * i + 1] / inputSize2[1][1], points[depth * i + 2] + 0];
|
||||
const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100;
|
||||
if (avgScore < (config3.body.minConfidence || 0))
|
||||
if (poseScore < (config3.body.minConfidence || 0))
|
||||
return null;
|
||||
const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
|
||||
const boxes = calculateBoxes(keypoints, [outputSize2[0], outputSize2[1]]);
|
||||
|
@ -5008,11 +5012,12 @@ async function detectParts(input, config3, outputSize2) {
|
|||
}
|
||||
annotations2[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
return body4;
|
||||
}
|
||||
async function predict2(input, config3) {
|
||||
const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame) {
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame && cache !== null) {
|
||||
skipped3++;
|
||||
} else {
|
||||
cache = await detectParts(input, config3, outputSize2);
|
||||
|
|
|
@ -4978,22 +4978,26 @@ function rescaleKeypoints(keypoints, outputSize2) {
|
|||
}
|
||||
return keypoints;
|
||||
}
|
||||
var sigmoid2 = (x) => 1 - 1 / (1 + Math.exp(x));
|
||||
async function detectParts(input, config3, outputSize2) {
|
||||
var _a;
|
||||
const t = {};
|
||||
t.input = await prepareImage(input);
|
||||
[t.ld, t.segmentation, t.heatmap, t.world, t.poseflag] = await ((_a = models[1]) == null ? void 0 : _a.execute(t.input, outputNodes));
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8));
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative = [];
|
||||
const depth = 5;
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100;
|
||||
const score = sigmoid2(points[depth * i + 3]);
|
||||
const presence = sigmoid2(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw = [points[depth * i + 0] / inputSize2[1][0], points[depth * i + 1] / inputSize2[1][1], points[depth * i + 2] + 0];
|
||||
const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100;
|
||||
if (avgScore < (config3.body.minConfidence || 0))
|
||||
if (poseScore < (config3.body.minConfidence || 0))
|
||||
return null;
|
||||
const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
|
||||
const boxes = calculateBoxes(keypoints, [outputSize2[0], outputSize2[1]]);
|
||||
|
@ -5009,11 +5013,12 @@ async function detectParts(input, config3, outputSize2) {
|
|||
}
|
||||
annotations2[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
return body4;
|
||||
}
|
||||
async function predict2(input, config3) {
|
||||
const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame) {
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame && cache !== null) {
|
||||
skipped3++;
|
||||
} else {
|
||||
cache = await detectParts(input, config3, outputSize2);
|
||||
|
|
|
@ -4977,22 +4977,26 @@ function rescaleKeypoints(keypoints, outputSize2) {
|
|||
}
|
||||
return keypoints;
|
||||
}
|
||||
var sigmoid2 = (x) => 1 - 1 / (1 + Math.exp(x));
|
||||
async function detectParts(input, config3, outputSize2) {
|
||||
var _a;
|
||||
const t = {};
|
||||
t.input = await prepareImage(input);
|
||||
[t.ld, t.segmentation, t.heatmap, t.world, t.poseflag] = await ((_a = models[1]) == null ? void 0 : _a.execute(t.input, outputNodes));
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8));
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative = [];
|
||||
const depth = 5;
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100;
|
||||
const score = sigmoid2(points[depth * i + 3]);
|
||||
const presence = sigmoid2(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw = [points[depth * i + 0] / inputSize2[1][0], points[depth * i + 1] / inputSize2[1][1], points[depth * i + 2] + 0];
|
||||
const position = [Math.trunc(outputSize2[0] * positionRaw[0]), Math.trunc(outputSize2[1] * positionRaw[1]), positionRaw[2]];
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100;
|
||||
if (avgScore < (config3.body.minConfidence || 0))
|
||||
if (poseScore < (config3.body.minConfidence || 0))
|
||||
return null;
|
||||
const keypoints = rescaleKeypoints(keypointsRelative, outputSize2);
|
||||
const boxes = calculateBoxes(keypoints, [outputSize2[0], outputSize2[1]]);
|
||||
|
@ -5008,11 +5012,12 @@ async function detectParts(input, config3, outputSize2) {
|
|||
}
|
||||
annotations2[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
const body4 = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations: annotations2 };
|
||||
return body4;
|
||||
}
|
||||
async function predict2(input, config3) {
|
||||
const outputSize2 = [input.shape[2] || 0, input.shape[1] || 0];
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame) {
|
||||
if (skipped3 < (config3.body.skipFrames || 0) && config3.skipFrame && cache !== null) {
|
||||
skipped3++;
|
||||
} else {
|
||||
cache = await detectParts(input, config3, outputSize2);
|
||||
|
|
|
@ -56,25 +56,6 @@ function calculateBoxes(keypoints: Array<BodyKeypoint>, outputSize: [number, num
|
|||
const y = keypoints.map((a) => a.position[1]);
|
||||
const keypointsBox: Box = [Math.min(...x), Math.min(...y), Math.max(...x) - Math.min(...x), Math.max(...y) - Math.min(...y)];
|
||||
const keypointsBoxRaw: Box = [keypointsBox[0] / outputSize[0], keypointsBox[1] / outputSize[1], keypointsBox[2] / outputSize[0], keypointsBox[3] / outputSize[1]];
|
||||
/*
|
||||
const leftShoulder = keypoints.find((kpt) => kpt.part === 'leftShoulder');
|
||||
const rightShoulder = keypoints.find((kpt) => kpt.part === 'rightShoulder');
|
||||
if (!leftShoulder || !rightShoulder || !config.skipFrame) { // reset cache box coords
|
||||
cache.box = [0, 0, 1, 1];
|
||||
cache.boxRaw = cache.box;
|
||||
} else { // recalculate cache box coords
|
||||
const size = [leftShoulder.position[0] - rightShoulder.position[0], leftShoulder.position[1] - rightShoulder.position[1]];
|
||||
const shoulderWidth = Math.sqrt((size[0] * size[0]) + (size[1] * size[1])); // distance between left and right shoulder
|
||||
const shoulderCenter: Point = [(leftShoulder.position[0] + rightShoulder.position[0]) / 2, (leftShoulder.position[1] + rightShoulder.position[1]) / 2]; // center point between left and right shoulder
|
||||
const bodyCenter: Point = [shoulderCenter[0], shoulderCenter[0] + (shoulderWidth), 0]; // approximate center of the body
|
||||
const bodyCenterRaw: Point = [bodyCenter[0] / outputSize[0], bodyCenter[1] / outputSize[1], 0];
|
||||
const bodyCenterKpt: Keypoint = { part: 'bodyCenter', positionRaw: bodyCenterRaw, position: bodyCenter, score: 1 }; // add virtual keypoint
|
||||
keypoints.push(bodyCenterKpt);
|
||||
const scaleFact = 2.5;
|
||||
cache.box = [Math.trunc(bodyCenter[0] - (scaleFact * shoulderWidth)), Math.trunc(bodyCenter[1] - (scaleFact * shoulderWidth)), Math.trunc(2 * scaleFact * shoulderWidth), Math.trunc(2 * scaleFact * shoulderWidth)];
|
||||
cache.boxRaw = [cache.box[0] / outputSize[0], cache.box[1] / outputSize[1], cache.box[2] / outputSize[0], cache.box[3] / outputSize[1]];
|
||||
}
|
||||
*/
|
||||
return { keypointsBox, keypointsBoxRaw };
|
||||
}
|
||||
|
||||
|
@ -108,23 +89,33 @@ function rescaleKeypoints(keypoints: Array<BodyKeypoint>, outputSize: [number, n
|
|||
return keypoints;
|
||||
}
|
||||
|
||||
const sigmoid = (x) => (1 - (1 / (1 + Math.exp(x))));
|
||||
|
||||
async function detectParts(input: Tensor, config: Config, outputSize: [number, number]): Promise<BodyResult | null> {
|
||||
const t: Record<string, Tensor> = {};
|
||||
t.input = await prepareImage(input);
|
||||
[t.ld/* 1,195 */, t.segmentation/* 1,256,256,1 */, t.heatmap/* 1,64,64,39 */, t.world/* 1,117 */, t.poseflag/* 1,1 */] = await models[1]?.execute(t.input, outputNodes) as Tensor[]; // run model
|
||||
/**
|
||||
* t.ld: 39 keypoints [x,y,z,score,presence] normalized to input size
|
||||
* t.segmentation:
|
||||
* t.heatmap:
|
||||
* t.world: 39 keypoints [x,y,z] normalized to -1..1
|
||||
* t.poseflag: body score
|
||||
*/
|
||||
[t.ld/* 1,195(39*5) */, t.segmentation/* 1,256,256,1 */, t.heatmap/* 1,64,64,39 */, t.world/* 1,117(39*3) */, t.poseflag/* 1,1 */] = await models[1]?.execute(t.input, outputNodes) as Tensor[]; // run model
|
||||
const poseScoreRaw = (await t.poseflag.data())[0];
|
||||
const poseScore = Math.max(0, (poseScoreRaw - 0.8) / (1 - 0.8)); // blow up score variance 5x
|
||||
const points = await t.ld.data();
|
||||
const keypointsRelative: Array<BodyKeypoint> = [];
|
||||
const depth = 5; // each points has x,y,z,visibility,presence
|
||||
for (let i = 0; i < points.length / depth; i++) {
|
||||
const score = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100; // normally this is from tf.sigmoid but no point of running sigmoid on full array which has coords as well
|
||||
// const presence = (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 4])))) / 100; // reverse sigmoid value
|
||||
const score = sigmoid(points[depth * i + 3]);
|
||||
const presence = sigmoid(points[depth * i + 4]);
|
||||
const adjScore = Math.trunc(100 * score * presence * poseScore) / 100;
|
||||
const positionRaw: Point = [points[depth * i + 0] / inputSize[1][0], points[depth * i + 1] / inputSize[1][1], points[depth * i + 2] + 0];
|
||||
const position: Point = [Math.trunc(outputSize[0] * positionRaw[0]), Math.trunc(outputSize[1] * positionRaw[1]), positionRaw[2] as number];
|
||||
// if (positionRaw[0] < 0 || positionRaw[1] < 0 || positionRaw[0] > 1 || positionRaw[1] > 1) score = 0;
|
||||
keypointsRelative.push({ part: coords.kpt[i], positionRaw, position, score });
|
||||
keypointsRelative.push({ part: coords.kpt[i], positionRaw, position, score: adjScore });
|
||||
}
|
||||
const avgScore = Math.round(100 * keypointsRelative.reduce((prev, curr) => prev += curr.score, 0) / keypointsRelative.length) / 100; // average score of keypoints
|
||||
if (avgScore < (config.body.minConfidence || 0)) return null;
|
||||
if (poseScore < (config.body.minConfidence || 0)) return null;
|
||||
const keypoints: Array<BodyKeypoint> = rescaleKeypoints(keypointsRelative, outputSize); // keypoints were relative to input image which is cropped
|
||||
const boxes = calculateBoxes(keypoints, [outputSize[0], outputSize[1]]); // now find boxes based on rescaled keypoints
|
||||
Object.keys(t).forEach((tensor) => tf.dispose(t[tensor]));
|
||||
|
@ -138,17 +129,13 @@ async function detectParts(input: Tensor, config: Config, outputSize: [number, n
|
|||
}
|
||||
annotations[name] = pt;
|
||||
}
|
||||
return { id: 0, score: avgScore, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations };
|
||||
const body = { id: 0, score: Math.trunc(100 * poseScore) / 100, box: boxes.keypointsBox, boxRaw: boxes.keypointsBoxRaw, keypoints, annotations };
|
||||
return body;
|
||||
}
|
||||
|
||||
export async function predict(input: Tensor, config: Config): Promise<BodyResult[]> {
|
||||
/** blazepose caching
|
||||
* not fully implemented
|
||||
* 1. if skipFrame returned cached
|
||||
* 2. run detection based on squared full frame
|
||||
*/
|
||||
const outputSize: [number, number] = [input.shape[2] || 0, input.shape[1] || 0];
|
||||
if ((skipped < (config.body.skipFrames || 0)) && config.skipFrame) {
|
||||
if ((skipped < (config.body.skipFrames || 0)) && config.skipFrame && cache !== null) {
|
||||
skipped++;
|
||||
} else {
|
||||
cache = await detectParts(input, config, outputSize);
|
||||
|
|
|
@ -1,46 +1,24 @@
|
|||
2021-10-14 12:23:28 [36mINFO: [39m @vladmandic/human version 2.3.3
|
||||
2021-10-14 12:23:28 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.10.0
|
||||
2021-10-14 12:23:28 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.3.3"}
|
||||
2021-10-14 12:23:28 [36mINFO: [39m Environment: {"profile":"production","config":"build.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||
2021-10-14 12:23:28 [36mINFO: [39m Toolchain: {"build":"0.6.0","esbuild":"0.13.6","typescript":"4.4.4","typedoc":"0.22.5","eslint":"8.0.1"}
|
||||
2021-10-14 12:23:28 [36mINFO: [39m Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Clean: {"locations":["dist/*","types/*","typedoc/*"]}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":525473,"outputBytes":434511}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":525481,"outputBytes":434515}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":525548,"outputBytes":434587}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3085,"outputBytes":856}
|
||||
2021-10-14 12:23:28 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":525054,"outputBytes":436070}
|
||||
2021-10-14 12:23:29 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3085,"outputBytes":2691961}
|
||||
2021-10-14 12:23:30 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":3216159,"outputBytes":1611238}
|
||||
2021-10-14 12:23:30 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":3216159,"outputBytes":2927935}
|
||||
2021-10-14 12:23:48 [35mSTATE:[39m Typings: {"input":"src/human.ts","output":"types","files":6}
|
||||
2021-10-14 12:23:54 [35mSTATE:[39m TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":36,"generated":true}
|
||||
2021-10-14 12:24:25 [35mSTATE:[39m Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":91,"errors":0,"warnings":0}
|
||||
2021-10-14 12:24:25 [35mSTATE:[39m ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
|
||||
2021-10-14 12:24:25 [36mINFO: [39m Done...
|
||||
2021-10-15 06:46:56 [36mINFO: [39m @vladmandic/human version 2.3.3
|
||||
2021-10-15 06:46:56 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.10.0
|
||||
2021-10-15 06:46:56 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.3.3"}
|
||||
2021-10-15 06:46:56 [36mINFO: [39m Environment: {"profile":"development","config":"build.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||
2021-10-15 06:46:56 [36mINFO: [39m Toolchain: {"build":"0.6.0","esbuild":"0.13.6","typescript":"4.4.4","typedoc":"0.22.5","eslint":"8.0.1"}
|
||||
2021-10-15 06:46:56 [36mINFO: [39m Build: {"profile":"development","steps":["serve","watch","compile"]}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m WebServer: {"ssl":false,"port":10030,"root":"."}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m WebServer: {"ssl":true,"port":10031,"root":".","sslKey":"node_modules/@vladmandic/build/cert/https.key","sslCrt":"node_modules/@vladmandic/build/cert/https.crt"}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Watch: {"locations":["src/**","README.md","src/**/*","tfjs/**/*"]}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":525473,"outputBytes":434511}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":525481,"outputBytes":434515}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":525548,"outputBytes":434587}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3085,"outputBytes":856}
|
||||
2021-10-15 06:46:56 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":525054,"outputBytes":436070}
|
||||
2021-10-15 06:46:57 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3085,"outputBytes":2691961}
|
||||
2021-10-15 06:46:57 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":3216159,"outputBytes":1611238}
|
||||
2021-10-15 06:46:58 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":3216159,"outputBytes":2927935}
|
||||
2021-10-15 06:46:58 [36mINFO: [39m Listening...
|
||||
2021-10-15 09:30:57 [36mINFO: [39m @vladmandic/human version 2.3.3
|
||||
2021-10-15 09:30:57 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.10.0
|
||||
2021-10-15 09:30:57 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.3.3"}
|
||||
2021-10-15 09:30:57 [36mINFO: [39m Environment: {"profile":"production","config":"build.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||
2021-10-15 09:30:57 [36mINFO: [39m Toolchain: {"build":"0.6.0","esbuild":"0.13.6","typescript":"4.4.4","typedoc":"0.22.5","eslint":"8.0.1"}
|
||||
2021-10-15 09:30:57 [36mINFO: [39m Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Clean: {"locations":["dist/*","types/*","typedoc/*"]}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":523789,"outputBytes":434713}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":523797,"outputBytes":434717}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":523864,"outputBytes":434789}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
|
||||
2021-10-15 09:30:57 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3085,"outputBytes":856}
|
||||
2021-10-15 09:30:58 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":523370,"outputBytes":436272}
|
||||
2021-10-15 09:30:58 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3085,"outputBytes":2691961}
|
||||
2021-10-15 09:30:58 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":3214475,"outputBytes":1611302}
|
||||
2021-10-15 09:30:59 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":3214475,"outputBytes":2928137}
|
||||
2021-10-15 09:31:16 [35mSTATE:[39m Typings: {"input":"src/human.ts","output":"types","files":6}
|
||||
2021-10-15 09:31:22 [35mSTATE:[39m TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":36,"generated":true}
|
||||
2021-10-15 09:31:54 [35mSTATE:[39m Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":91,"errors":0,"warnings":0}
|
||||
2021-10-15 09:31:54 [35mSTATE:[39m ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
|
||||
2021-10-15 09:31:54 [36mINFO: [39m Done...
|
||||
|
|
1026
test/test.log
1026
test/test.log
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
{"version":3,"file":"blazepose.d.ts","sourceRoot":"","sources":["../../../src/body/blazepose.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAgB,UAAU,EAAc,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAWxC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAWpE;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAalE;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAI1F;AA4FD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAelF"}
|
||||
{"version":3,"file":"blazepose.d.ts","sourceRoot":"","sources":["../../../src/body/blazepose.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAgB,UAAU,EAAc,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAWxC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAWpE;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAalE;AAED,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAI1F;AAoFD,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAUlF"}
|
Loading…
Reference in New Issue