added skipInitial flag

pull/91/head
Vladimir Mandic 2021-03-01 17:20:02 -05:00
parent af4cb56a12
commit 92cc067b6f
22 changed files with 218 additions and 213 deletions

View File

@ -76,6 +76,8 @@ export default {
// e.g., if model is running st 25 FPS, we can re-use existing bounding
// box for updated face analysis as the head probably hasn't moved much
// in short time (10 * 1/25 = 0.25 sec)
skipInitial: false, // if previous detection resulted in no faces detected,
// should skipFrames be reset immediately
minConfidence: 0.2, // threshold for discarding a prediction
iouThreshold: 0.2, // threshold for deciding whether boxes overlap too much in
// non-maximum suppression (0.1 means drop if overlap 10%)
@ -154,6 +156,8 @@ export default {
// e.g., if model is running st 25 FPS, we can re-use existing bounding
// box for updated hand skeleton analysis as the hand probably
// hasn't moved much in short time (10 * 1/25 = 0.25 sec)
skipInitial: false, // if previous detection resulted in no faces detected,
// should skipFrames be reset immediately
minConfidence: 0.1, // threshold for discarding a prediction
iouThreshold: 0.1, // threshold for deciding whether boxes overlap too much
// in non-maximum suppression

View File

@ -8,8 +8,9 @@ import draw from './draw.js';
import Menu from './menu.js';
import GLBench from './gl-bench.js';
// const userConfig = {}; // add any user configuration overrides
const userConfig = {}; // add any user configuration overrides
/*
const userConfig = {
backend: 'wasm',
async: false,
@ -18,6 +19,7 @@ const userConfig = {
body: { enabled: false },
hand: { enabled: false },
};
*/
const human = new Human(userConfig);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"inputs": {
"dist/human.esm.js": {
"bytes": 1339028,
"bytes": 1339128,
"imports": []
},
"demo/draw.js": {
@ -17,7 +17,7 @@
"imports": []
},
"demo/browser.js": {
"bytes": 26835,
"bytes": 26838,
"imports": [
{
"path": "dist/human.esm.js",
@ -43,7 +43,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 2038301
"bytes": 2038382
},
"dist/demo-browser-index.js": {
"imports": [],
@ -51,7 +51,7 @@
"entryPoint": "demo/browser.js",
"inputs": {
"dist/human.esm.js": {
"bytesInOutput": 1331550
"bytesInOutput": 1331652
},
"demo/draw.js": {
"bytesInOutput": 6241
@ -63,10 +63,10 @@
"bytesInOutput": 6759
},
"demo/browser.js": {
"bytesInOutput": 17635
"bytesInOutput": 17423
}
},
"bytes": 1380266
"bytes": 1380156
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/human.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

16
dist/human.esm.json vendored
View File

@ -52,7 +52,7 @@
"imports": []
},
"src/blazeface/facepipeline.ts": {
"bytes": 14175,
"bytes": 14151,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -338,7 +338,7 @@
"imports": []
},
"src/handpose/handpipeline.ts": {
"bytes": 7206,
"bytes": 7120,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -409,7 +409,7 @@
]
},
"config.js": {
"bytes": 9774,
"bytes": 10086,
"imports": []
},
"src/sample.ts": {
@ -499,7 +499,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 1939981
"bytes": 1940277
},
"dist/human.esm.js": {
"imports": [],
@ -536,7 +536,7 @@
"bytesInOutput": 28983
},
"src/blazeface/facepipeline.ts": {
"bytesInOutput": 5042
"bytesInOutput": 5051
},
"src/human.ts": {
"bytesInOutput": 10347
@ -599,7 +599,7 @@
"bytesInOutput": 816
},
"src/handpose/handpipeline.ts": {
"bytesInOutput": 2449
"bytesInOutput": 2510
},
"src/handpose/anchors.ts": {
"bytesInOutput": 126985
@ -614,7 +614,7 @@
"bytesInOutput": 2355
},
"config.js": {
"bytesInOutput": 1414
"bytesInOutput": 1444
},
"src/sample.ts": {
"bytesInOutput": 55295
@ -623,7 +623,7 @@
"bytesInOutput": 2572
}
},
"bytes": 1339028
"bytes": 1339128
}
}
}

16
dist/human.iife.json vendored
View File

@ -52,7 +52,7 @@
"imports": []
},
"src/blazeface/facepipeline.ts": {
"bytes": 14175,
"bytes": 14151,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -338,7 +338,7 @@
"imports": []
},
"src/handpose/handpipeline.ts": {
"bytes": 7206,
"bytes": 7120,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -409,7 +409,7 @@
]
},
"config.js": {
"bytes": 9774,
"bytes": 10086,
"imports": []
},
"src/sample.ts": {
@ -499,7 +499,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 1939992
"bytes": 1940288
},
"dist/human.ts": {
"imports": [],
@ -537,7 +537,7 @@
"bytesInOutput": 28983
},
"src/blazeface/facepipeline.ts": {
"bytesInOutput": 5042
"bytesInOutput": 5051
},
"src/faceboxes/faceboxes.ts": {
"bytesInOutput": 1549
@ -597,7 +597,7 @@
"bytesInOutput": 816
},
"src/handpose/handpipeline.ts": {
"bytesInOutput": 2449
"bytesInOutput": 2510
},
"src/handpose/anchors.ts": {
"bytesInOutput": 126985
@ -612,7 +612,7 @@
"bytesInOutput": 2355
},
"config.js": {
"bytesInOutput": 1414
"bytesInOutput": 1444
},
"src/sample.ts": {
"bytesInOutput": 55295
@ -621,7 +621,7 @@
"bytesInOutput": 2572
}
},
"bytes": 1339070
"bytes": 1339170
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

16
dist/human.node.json vendored
View File

@ -52,7 +52,7 @@
"imports": []
},
"src/blazeface/facepipeline.ts": {
"bytes": 14175,
"bytes": 14151,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -338,7 +338,7 @@
"imports": []
},
"src/handpose/handpipeline.ts": {
"bytes": 7206,
"bytes": 7120,
"imports": [
{
"path": "dist/tfjs.esm.js",
@ -409,7 +409,7 @@
]
},
"config.js": {
"bytes": 9774,
"bytes": 10086,
"imports": []
},
"src/sample.ts": {
@ -499,7 +499,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 706736
"bytes": 707032
},
"dist/human.node-gpu.js": {
"imports": [],
@ -528,7 +528,7 @@
"bytesInOutput": 2329
},
"src/blazeface/facepipeline.ts": {
"bytesInOutput": 5089
"bytesInOutput": 5098
},
"src/blazeface/box.ts": {
"bytesInOutput": 854
@ -594,7 +594,7 @@
"bytesInOutput": 958
},
"src/handpose/handpipeline.ts": {
"bytesInOutput": 2470
"bytesInOutput": 2531
},
"src/handpose/util.ts": {
"bytesInOutput": 806
@ -612,7 +612,7 @@
"bytesInOutput": 10973
},
"config.js": {
"bytesInOutput": 1414
"bytesInOutput": 1444
},
"src/sample.ts": {
"bytesInOutput": 55295
@ -621,7 +621,7 @@
"bytesInOutput": 2569
}
},
"bytes": 276557
"bytes": 276657
}
}
}

4
dist/human.ts vendored

File diff suppressed because one or more lines are too long

4
dist/human.ts.map vendored

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,6 @@ function replaceRawCoordinates(rawCoords, newCoords, prefix, keys = null) {
// The Pipeline coordinates between the bounding box and skeleton models.
export class Pipeline {
storedBoxes: any;
runsWithoutFaceDetector: number;
boundingBoxDetector: any;
meshDetector: any;
irisModel: any;
@ -53,7 +52,6 @@ export class Pipeline {
constructor(boundingBoxDetector, meshDetector, irisModel, config) {
// An array of facial bounding boxes.
this.storedBoxes = [];
this.runsWithoutFaceDetector = 0;
this.boundingBoxDetector = boundingBoxDetector;
this.meshDetector = meshDetector;
this.irisModel = irisModel;
@ -156,6 +154,8 @@ export class Pipeline {
if (this.storedBoxes.length > 0) useFreshBox = true;
}
if (config.face.detector.skipInitial && this.detectedFaces === 0) this.skipped = 0;
if (useFreshBox) {
if (!detector || !detector.boxes || (detector.boxes.length === 0)) {
this.storedBoxes = [];
@ -170,7 +170,6 @@ export class Pipeline {
const confidence = this.storedBoxes[i].confidence;
this.storedBoxes[i] = { ...squarifiedBox, confidence, landmarks };
}
this.runsWithoutFaceDetector = 0;
}
if (detector && detector.boxes) {
detector.boxes.forEach((prediction) => {

View File

@ -90,7 +90,8 @@ export class HandPipeline {
if (this.storedBoxes.length > 0) useFreshBox = true;
}
const hands: Array<{}> = [];
// log('hand', `skipped: ${this.skipped} max: ${config.hand.maxHands} detected: ${this.detectedHands} stored: ${this.storedBoxes.length} new: ${boxes?.length}`);
if (config.hand.skipInitial && this.detectedHands === 0) this.skipped = 0;
// go through working set of boxes
for (let i = 0; i < this.storedBoxes.length; i++) {

View File

@ -1,6 +1,5 @@
export declare class Pipeline {
storedBoxes: any;
runsWithoutFaceDetector: number;
boundingBoxDetector: any;
meshDetector: any;
irisModel: any;

2
wiki

@ -1 +1 @@
Subproject commit 35cb9ec10d7036a8a2ec425c00798050dd9eafea
Subproject commit c283c4a21d26dc0ba03e576dae8e6fbd3af12ac8