mirror of https://github.com/vladmandic/human
updated build platform and typedoc theme
parent
79f95aa39f
commit
cb1ff858e9
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
### **HEAD -> main** 2021/09/17 mandic00@live.com
|
### **HEAD -> main** 2021/09/17 mandic00@live.com
|
||||||
|
|
||||||
|
- webgl exception handling
|
||||||
|
|
||||||
### **2.2.2** 2021/09/17 mandic00@live.com
|
### **2.2.2** 2021/09/17 mandic00@live.com
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --no-warnings demo/nodejs/node.js",
|
"start": "node --no-warnings demo/nodejs/node.js",
|
||||||
"dev": "build --profile development",
|
"dev": "build --profile development",
|
||||||
"build": "build --profile production",
|
"build": "rimraf test/build.log && build --profile production",
|
||||||
"test": "node --no-warnings --unhandled-rejections=strict --trace-uncaught test/test.js",
|
"test": "node --no-warnings --unhandled-rejections=strict --trace-uncaught test/test.js",
|
||||||
"lint": "eslint src demo test",
|
"lint": "eslint src demo test",
|
||||||
"scan": "npx auditjs@latest ossi --dev --quiet"
|
"scan": "npx auditjs@latest ossi --dev --quiet"
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
"@types/node": "^16.9.2",
|
"@types/node": "^16.9.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
||||||
"@typescript-eslint/parser": "^4.31.1",
|
"@typescript-eslint/parser": "^4.31.1",
|
||||||
"@vladmandic/build": "^0.4.1",
|
"@vladmandic/build": "^0.5.1",
|
||||||
"@vladmandic/pilogger": "^0.3.2",
|
"@vladmandic/pilogger": "^0.3.2",
|
||||||
"canvas": "^2.8.0",
|
"canvas": "^2.8.0",
|
||||||
"dayjs": "^1.10.7",
|
"dayjs": "^1.10.7",
|
||||||
|
@ -81,9 +81,10 @@
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"node-fetch": "^3.0.0",
|
"node-fetch": "^3.0.0",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
"seedrandom": "^3.0.5",
|
"seedrandom": "^3.0.5",
|
||||||
"tslib": "^2.3.1",
|
"tslib": "^2.3.1",
|
||||||
"typedoc": "0.22.3",
|
"typedoc": "0.22.4",
|
||||||
"typescript": "4.4.3"
|
"typescript": "4.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,7 @@ export function reset(instance) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load method preloads all instance.configured models on-demand
|
/** Load method preloads all instance.configured models on-demand */
|
||||||
* - Not explicitly required as any required model is load implicitly on it's first run
|
|
||||||
* @param userinstance.config?: {@link instance.config}
|
|
||||||
*/
|
|
||||||
export async function load(instance) {
|
export async function load(instance) {
|
||||||
if (env.initial) reset(instance);
|
if (env.initial) reset(instance);
|
||||||
if (instance.config.async) { // load models concurrently
|
if (instance.config.async) { // load models concurrently
|
||||||
|
|
|
@ -181,7 +181,7 @@ export interface Result {
|
||||||
hand: Array<HandResult>,
|
hand: Array<HandResult>,
|
||||||
/** {@link GestureResult}: detection & analysis results */
|
/** {@link GestureResult}: detection & analysis results */
|
||||||
gesture: Array<GestureResult>,
|
gesture: Array<GestureResult>,
|
||||||
/** {@link ItemResult}: detection & analysis results */
|
/** {@link ObjectResult}: detection & analysis results */
|
||||||
object: Array<ObjectResult>
|
object: Array<ObjectResult>
|
||||||
/** global performance object with timing values for each operation */
|
/** global performance object with timing values for each operation */
|
||||||
performance: Record<string, unknown>,
|
performance: Record<string, unknown>,
|
||||||
|
|
|
@ -144,12 +144,15 @@ async function test(Human, inputConfig) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const t0 = process.hrtime.bigint();
|
const t0 = process.hrtime.bigint();
|
||||||
const human = new Human(config);
|
let human;
|
||||||
|
|
||||||
|
// test event emitter
|
||||||
|
human = new Human(config);
|
||||||
human.events.addEventListener('warmup', () => events('warmup'));
|
human.events.addEventListener('warmup', () => events('warmup'));
|
||||||
human.events.addEventListener('image', () => events('image'));
|
human.events.addEventListener('image', () => events('image'));
|
||||||
human.events.addEventListener('detect', () => events('detect'));
|
human.events.addEventListener('detect', () => events('detect'));
|
||||||
|
|
||||||
// await human.tf.ready();
|
// test warmup sequences
|
||||||
await testInstance(human);
|
await testInstance(human);
|
||||||
config.warmup = 'none';
|
config.warmup = 'none';
|
||||||
await testWarmup(human, 'default');
|
await testWarmup(human, 'default');
|
||||||
|
@ -158,33 +161,63 @@ async function test(Human, inputConfig) {
|
||||||
config.warmup = 'body';
|
config.warmup = 'body';
|
||||||
await testWarmup(human, 'default');
|
await testWarmup(human, 'default');
|
||||||
|
|
||||||
|
// test default config
|
||||||
log('info', 'test default');
|
log('info', 'test default');
|
||||||
|
human = new Human(config);
|
||||||
await testDetect(human, 'samples/ai-body.jpg', 'default');
|
await testDetect(human, 'samples/ai-body.jpg', 'default');
|
||||||
|
|
||||||
|
// test detectors only
|
||||||
|
log('info', 'test detectors');
|
||||||
|
config.face = { mesh: { enabled: false }, iris: { enabled: false }, hand: { landmarks: false } };
|
||||||
|
human = new Human(config);
|
||||||
|
await testDetect(human, 'samples/ai-body.jpg', 'default');
|
||||||
|
|
||||||
|
// test posenet and movenet
|
||||||
log('info', 'test body variants');
|
log('info', 'test body variants');
|
||||||
config.body = { modelPath: 'posenet.json' };
|
config.body = { modelPath: 'posenet.json' };
|
||||||
await testDetect(human, 'samples/ai-body.jpg', 'posenet');
|
await testDetect(human, 'samples/ai-body.jpg', 'posenet');
|
||||||
config.body = { modelPath: 'movenet-lightning.json' };
|
config.body = { modelPath: 'movenet-lightning.json' };
|
||||||
await testDetect(human, 'samples/ai-body.jpg', 'movenet');
|
await testDetect(human, 'samples/ai-body.jpg', 'movenet');
|
||||||
|
|
||||||
|
// test multiple instances
|
||||||
|
const first = new Human(config);
|
||||||
|
const second = new Human(config);
|
||||||
await testDetect(human, null, 'default');
|
await testDetect(human, null, 'default');
|
||||||
log('info', 'test: first instance');
|
log('info', 'test: first instance');
|
||||||
await testDetect(human, 'samples/ai-upper.jpg', 'default');
|
await testDetect(first, 'samples/ai-upper.jpg', 'default');
|
||||||
log('info', 'test: second instance');
|
log('info', 'test: second instance');
|
||||||
const second = new Human(config);
|
|
||||||
await testDetect(second, 'samples/ai-upper.jpg', 'default');
|
await testDetect(second, 'samples/ai-upper.jpg', 'default');
|
||||||
|
|
||||||
|
// test async multiple instances
|
||||||
log('info', 'test: concurrent');
|
log('info', 'test: concurrent');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
testDetect(human, 'samples/ai-face.jpg', 'default'),
|
testDetect(human, 'samples/ai-face.jpg', 'default'),
|
||||||
|
testDetect(first, 'samples/ai-face.jpg', 'default'),
|
||||||
testDetect(second, 'samples/ai-face.jpg', 'default'),
|
testDetect(second, 'samples/ai-face.jpg', 'default'),
|
||||||
testDetect(human, 'samples/ai-body.jpg', 'default'),
|
testDetect(human, 'samples/ai-body.jpg', 'default'),
|
||||||
|
testDetect(first, 'samples/ai-body.jpg', 'default'),
|
||||||
testDetect(second, 'samples/ai-body.jpg', 'default'),
|
testDetect(second, 'samples/ai-body.jpg', 'default'),
|
||||||
testDetect(human, 'samples/ai-upper.jpg', 'default'),
|
testDetect(human, 'samples/ai-upper.jpg', 'default'),
|
||||||
|
testDetect(first, 'samples/ai-upper.jpg', 'default'),
|
||||||
testDetect(second, 'samples/ai-upper.jpg', 'default'),
|
testDetect(second, 'samples/ai-upper.jpg', 'default'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// tests end
|
||||||
const t1 = process.hrtime.bigint();
|
const t1 = process.hrtime.bigint();
|
||||||
|
|
||||||
|
// check tensor leaks
|
||||||
const leak = human.tf.engine().state.numTensors - tensors;
|
const leak = human.tf.engine().state.numTensors - tensors;
|
||||||
if (leak === 0) log('state', 'passeed: no memory leak');
|
if (leak === 0) log('state', 'passeed: no memory leak');
|
||||||
else log('error', 'failed: memory leak', leak);
|
else log('error', 'failed: memory leak', leak);
|
||||||
|
|
||||||
|
// check if all instances reported same
|
||||||
|
const tensors1 = human.tf.engine().state.numTensors;
|
||||||
|
const tensors2 = first.tf.engine().state.numTensors;
|
||||||
|
const tensors3 = second.tf.engine().state.numTensors;
|
||||||
|
if (tensors1 === tensors2 && tensors1 === tensors3 && tensors2 === tensors3) log('state', 'passeed: equal usage');
|
||||||
|
else log('error', 'failed: equal usage', tensors1, tensors2, tensors3);
|
||||||
|
|
||||||
|
// report end
|
||||||
log('info', 'events:', evt);
|
log('info', 'events:', evt);
|
||||||
log('info', 'test complete:', Math.trunc(Number(t1 - t0) / 1000 / 1000), 'ms');
|
log('info', 'test complete:', Math.trunc(Number(t1 - t0) / 1000 / 1000), 'ms');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue