add tensorflow library detection

pull/356/head
Vladimir Mandic 2022-08-15 11:40:15 -04:00
parent 6fc26e793c
commit 96bc063a1d
5 changed files with 1031 additions and 1022 deletions

View File

@ -9,7 +9,7 @@
## Changelog
### **HEAD -> main** 2022/08/12 mandic00@live.com
### **HEAD -> main** 2022/08/15 mandic00@live.com
- enumerate additional models
- release refresh

10
TODO.md
View File

@ -57,7 +57,8 @@ Model is supported using `WebGL` backend in browser
Models can be downloaded from <https://github.com/vladmandic/insightface>
- Add `human.check()` which validates all kernel ops for currently loaded models with currently selected backend
Example: `console.error(human.check());`
- Add underlying tensorflow library version detection to `human.env`
- Add underlying **tensorflow** library version detection when running in NodeJS to
`human.env` and check if **GPU** is used for acceleration
Example: `console.log(human.env.tensorflow)`
- Host models in <human-models>
Models can be directly used without downloading to local storage
@ -72,10 +73,11 @@ Model is supported using `WebGL` backend in browser
- Fix `demo/multithread/node-multiprocess.js` demo
- Fix `human.match` when using mixed descriptor lengths
- Fix WASM feature detection issue in TFJS with Edge/Chromium
Example: `console.log(human.env.wasm)`
- Increased test coverage
**NodeJS**: Run using `npm run test`
**Browser**: Run using `demo/browser.html`
**NodeJS**: Run using: `npm run test`
**Browser**: Run using: `demo/browser.html`
- Increase availability of alternative models
See `models/model.json` for full list
- Update profiling methods in `human.profile()`
- Update project dependencies
- Update project dependencies to latest versions

View File

@ -27,10 +27,14 @@ export class Env {
offscreen: undefined | boolean;
/** Are performance counter instant values or additive */
perfadd: boolean = false;
/** If using tfjs-node get version of underlying tensorflow shared library */
/** If using tfjs-node get version of underlying tensorflow shared library and if gpu acceleration is enabled */
tensorflow: {
version: undefined | string,
} = { version: undefined };
gpu: undefined | boolean,
} = {
version: undefined,
gpu: undefined,
};
/** WASM detected capabilities */
wasm: {
supported: undefined | boolean,
@ -119,7 +123,10 @@ export class Env {
async updateBackend() {
// analyze backends
this.backends = Object.keys(tf.engine().registryFactory);
this.tensorflow = { version: (tf.backend()['binding'] ? tf.backend()['binding']['TF_Version'] : undefined) };
this.tensorflow = {
version: (tf.backend()['binding'] ? tf.backend()['binding']['TF_Version'] : undefined),
gpu: (tf.backend()['binding'] ? tf.backend()['binding'].isUsingGpuDevice() : undefined),
};
this.wasm.supported = typeof WebAssembly !== 'undefined';
this.wasm.backend = this.backends.includes('wasm');
if (this.wasm.supported && this.wasm.backend && tf.getBackend() === 'wasm') {

View File

@ -1,39 +1,39 @@
2022-08-15 11:28:08 DATA:  Build {"name":"@vladmandic/human","version":"2.9.3"}
2022-08-15 11:28:08 INFO:  Application: {"name":"@vladmandic/human","version":"2.9.3"}
2022-08-15 11:28:08 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2022-08-15 11:28:08 INFO:  Toolchain: {"build":"0.7.9","esbuild":"0.15.3","typescript":"4.7.4","typedoc":"0.23.10","eslint":"8.22.0"}
2022-08-15 11:28:08 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2022-08-15 11:28:08 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
2022-08-15 11:28:08 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":608}
2022-08-15 11:28:08 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":655247,"outputBytes":307391}
2022-08-15 11:28:08 STATE: 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":612}
2022-08-15 11:28:08 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":655251,"outputBytes":307395}
2022-08-15 11:28:08 STATE: 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":664}
2022-08-15 11:28:08 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":655303,"outputBytes":307445}
2022-08-15 11:28:08 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1069,"outputBytes":358}
2022-08-15 11:28:08 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1032,"outputBytes":583}
2022-08-15 11:28:08 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":655222,"outputBytes":306242}
2022-08-15 11:28:09 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1271,"outputBytes":2787569}
2022-08-15 11:28:09 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3442208,"outputBytes":1669116}
2022-08-15 11:28:09 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3442208,"outputBytes":3072985}
2022-08-15 11:28:14 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30}
2022-08-15 11:28:15 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2022-08-15 11:28:15 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6716,"outputBytes":3141}
2022-08-15 11:28:15 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15629,"outputBytes":7798}
2022-08-15 11:28:24 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":109,"errors":0,"warnings":0}
2022-08-15 11:28:24 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2022-08-15 11:28:24 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"}
2022-08-15 11:28:24 INFO:  Done...
2022-08-15 11:28:24 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":198}
2022-08-15 11:28:24 STATE: Copy: {"input":"types/human.d.ts"}
2022-08-15 11:28:24 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2022-08-15 11:28:24 STATE: Models {"folder":"./models","models":13}
2022-08-15 11:28:24 STATE: Models {"folder":"../human-models/models","models":42}
2022-08-15 11:28:24 STATE: Models {"folder":"../blazepose/model/","models":4}
2022-08-15 11:28:24 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2022-08-15 11:28:24 STATE: Models {"folder":"../efficientpose/models","models":3}
2022-08-15 11:28:24 STATE: Models {"folder":"../insightface/models","models":5}
2022-08-15 11:28:24 STATE: Models {"folder":"../movenet/models","models":3}
2022-08-15 11:28:24 STATE: Models {"folder":"../nanodet/models","models":4}
2022-08-15 11:28:25 STATE: Models: {"count":57,"totalSize":383017442}
2022-08-15 11:28:25 INFO:  Human Build complete... {"logFile":"test/build.log"}
2022-08-15 11:36:04 DATA:  Build {"name":"@vladmandic/human","version":"2.9.3"}
2022-08-15 11:36:04 INFO:  Application: {"name":"@vladmandic/human","version":"2.9.3"}
2022-08-15 11:36:04 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2022-08-15 11:36:04 INFO:  Toolchain: {"build":"0.7.9","esbuild":"0.15.3","typescript":"4.7.4","typedoc":"0.23.10","eslint":"8.22.0"}
2022-08-15 11:36:04 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2022-08-15 11:36:04 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
2022-08-15 11:36:04 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":608}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":655451,"outputBytes":307474}
2022-08-15 11:36:04 STATE: 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":612}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":655455,"outputBytes":307478}
2022-08-15 11:36:04 STATE: 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":664}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":655507,"outputBytes":307528}
2022-08-15 11:36:04 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1069,"outputBytes":358}
2022-08-15 11:36:04 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1032,"outputBytes":583}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":655426,"outputBytes":306323}
2022-08-15 11:36:04 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1271,"outputBytes":2787569}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3442412,"outputBytes":1669183}
2022-08-15 11:36:04 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3442412,"outputBytes":3073108}
2022-08-15 11:36:09 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30}
2022-08-15 11:36:11 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2022-08-15 11:36:11 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6716,"outputBytes":3141}
2022-08-15 11:36:11 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15629,"outputBytes":7798}
2022-08-15 11:36:19 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":109,"errors":0,"warnings":0}
2022-08-15 11:36:19 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2022-08-15 11:36:19 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"}
2022-08-15 11:36:19 INFO:  Done...
2022-08-15 11:36:20 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":198}
2022-08-15 11:36:20 STATE: Copy: {"input":"types/human.d.ts"}
2022-08-15 11:36:20 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2022-08-15 11:36:20 STATE: Models {"folder":"./models","models":13}
2022-08-15 11:36:20 STATE: Models {"folder":"../human-models/models","models":42}
2022-08-15 11:36:20 STATE: Models {"folder":"../blazepose/model/","models":4}
2022-08-15 11:36:20 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2022-08-15 11:36:20 STATE: Models {"folder":"../efficientpose/models","models":3}
2022-08-15 11:36:20 STATE: Models {"folder":"../insightface/models","models":5}
2022-08-15 11:36:20 STATE: Models {"folder":"../movenet/models","models":3}
2022-08-15 11:36:20 STATE: Models {"folder":"../nanodet/models","models":4}
2022-08-15 11:36:20 STATE: Models: {"count":57,"totalSize":383017442}
2022-08-15 11:36:20 INFO:  Human Build complete... {"logFile":"test/build.log"}

File diff suppressed because it is too large Load Diff