From accd2d1e65628b3b62c1d0b8f2de4356100f2071 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 18 Sep 2021 19:09:02 -0400 Subject: [PATCH] updated build platform and typedoc theme --- CHANGELOG.md | 1 + package.json | 7 ++++--- src/models.ts | 5 +---- src/result.ts | 2 +- test/test-main.js | 41 +++++++++++++++++++++++++++++++++++++---- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c9f8c6a..dcdc8cd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### **HEAD -> main** 2021/09/17 mandic00@live.com +- webgl exception handling ### **2.2.2** 2021/09/17 mandic00@live.com diff --git a/package.json b/package.json index 7cf1fa41..8cff1116 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "scripts": { "start": "node --no-warnings demo/nodejs/node.js", "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", "lint": "eslint src demo test", "scan": "npx auditjs@latest ossi --dev --quiet" @@ -69,7 +69,7 @@ "@types/node": "^16.9.2", "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", - "@vladmandic/build": "^0.4.1", + "@vladmandic/build": "^0.5.1", "@vladmandic/pilogger": "^0.3.2", "canvas": "^2.8.0", "dayjs": "^1.10.7", @@ -81,9 +81,10 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", "node-fetch": "^3.0.0", + "rimraf": "^3.0.2", "seedrandom": "^3.0.5", "tslib": "^2.3.1", - "typedoc": "0.22.3", + "typedoc": "0.22.4", "typescript": "4.4.3" } } diff --git a/src/models.ts b/src/models.ts index 150f02c9..a3963fb8 100644 --- a/src/models.ts +++ b/src/models.ts @@ -34,10 +34,7 @@ export function reset(instance) { }; } -/** 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} -*/ +/** Load method preloads all instance.configured models on-demand */ export async function load(instance) { if (env.initial) reset(instance); if (instance.config.async) { // load models concurrently diff --git a/src/result.ts b/src/result.ts index 1fc967d9..62383dc0 100644 --- a/src/result.ts +++ b/src/result.ts @@ -181,7 +181,7 @@ export interface Result { hand: Array, /** {@link GestureResult}: detection & analysis results */ gesture: Array, - /** {@link ItemResult}: detection & analysis results */ + /** {@link ObjectResult}: detection & analysis results */ object: Array /** global performance object with timing values for each operation */ performance: Record, diff --git a/test/test-main.js b/test/test-main.js index fbf82d55..8a5b4ee1 100644 --- a/test/test-main.js +++ b/test/test-main.js @@ -144,12 +144,15 @@ async function test(Human, inputConfig) { return; } 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('image', () => events('image')); human.events.addEventListener('detect', () => events('detect')); - // await human.tf.ready(); + // test warmup sequences await testInstance(human); config.warmup = 'none'; await testWarmup(human, 'default'); @@ -158,33 +161,63 @@ async function test(Human, inputConfig) { config.warmup = 'body'; await testWarmup(human, 'default'); + // test default config log('info', 'test default'); + human = new Human(config); 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'); config.body = { modelPath: 'posenet.json' }; await testDetect(human, 'samples/ai-body.jpg', 'posenet'); config.body = { modelPath: 'movenet-lightning.json' }; 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'); 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'); - const second = new Human(config); await testDetect(second, 'samples/ai-upper.jpg', 'default'); + + // test async multiple instances log('info', 'test: concurrent'); await Promise.all([ testDetect(human, 'samples/ai-face.jpg', 'default'), + testDetect(first, 'samples/ai-face.jpg', 'default'), testDetect(second, 'samples/ai-face.jpg', 'default'), testDetect(human, 'samples/ai-body.jpg', 'default'), + testDetect(first, 'samples/ai-body.jpg', 'default'), testDetect(second, 'samples/ai-body.jpg', 'default'), testDetect(human, 'samples/ai-upper.jpg', 'default'), + testDetect(first, 'samples/ai-upper.jpg', 'default'), testDetect(second, 'samples/ai-upper.jpg', 'default'), ]); + + // tests end const t1 = process.hrtime.bigint(); + + // check tensor leaks const leak = human.tf.engine().state.numTensors - tensors; if (leak === 0) log('state', 'passeed: no memory 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', 'test complete:', Math.trunc(Number(t1 - t0) / 1000 / 1000), 'ms'); }