add config flags

pull/356/head
Vladimir Mandic 2022-09-06 10:28:54 -04:00
parent 398aefcad5
commit 15b50f2181
5 changed files with 58 additions and 46 deletions

View File

@ -88,6 +88,7 @@ Enable via `about:config` -> `gfx.offscreencanvas.enabled`
Run using: `demo/browser.html`
Runs tests for `webgl`, `humangl`, `webgpu` and `wasm`
Runs tests for ESM and IIFE versions of library
- Add `config.flags` settings to allow setting of custom **TFJS** flags during backend configuration
- Increase availability of alternative models
See `models/model.json` for full list
- Update profiling methods in `human.profile()`

View File

@ -76,16 +76,16 @@
"@tensorflow/tfjs-node": "^3.20.0",
"@tensorflow/tfjs-node-gpu": "^3.20.0",
"@tensorflow/tfjs-tflite": "0.0.1-alpha.8",
"@types/node": "^18.7.14",
"@types/node": "^18.7.15",
"@types/offscreencanvas": "^2019.7.0",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"@vladmandic/build": "^0.7.11",
"@vladmandic/pilogger": "^0.4.6",
"@vladmandic/tfjs": "github:vladmandic/tfjs",
"@webgpu/types": "^0.1.21",
"canvas": "^2.9.3",
"esbuild": "^0.15.6",
"canvas": "^2.10.0",
"esbuild": "^0.15.7",
"eslint": "8.23.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-html": "^7.1.0",

View File

@ -286,6 +286,9 @@ export interface Config {
*/
cacheSensitivity: number;
/** Explicit flags passed to initialize TFJS */
flags: Record<string, unknown>,
/** Software Kernels
* Registers software kernel ops running on CPU when accelerated version of kernel is not found in the current backend
*/
@ -333,6 +336,7 @@ const config: Config = {
cacheSensitivity: 0.70,
skipAllowed: false,
deallocate: false,
flags: {},
softwareKernels: false,
filter: {
enabled: true,

View File

@ -164,7 +164,7 @@ export async function check(instance: Human, force = false) {
// if (tf.env().flagRegistry.USE_SETTIMEOUTCUSTOM) tf.env().set('USE_SETTIMEOUTCUSTOM', true); // default=false <https://github.com/tensorflow/tfjs/issues/6687>
// if (tf.env().flagRegistry.CPU_HANDOFF_SIZE_THRESHOLD) tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 1024); // default=1000
// if (tf.env().flagRegistry['WEBGL_FORCE_F16_TEXTURES'] && !instance.config.object.enabled) tf.env().set('WEBGL_FORCE_F16_TEXTURES', true); // safe to use 16bit precision
if (typeof instance.config.deallocate !== 'undefined' && instance.config.deallocate) { // hidden param
if (instance.config.debug && typeof instance.config.deallocate !== 'undefined' && instance.config.deallocate) { // hidden param
log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true);
tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0);
}
@ -184,7 +184,14 @@ export async function check(instance: Human, force = false) {
if (defaultFlags[key] === newFlags[key]) continue;
updatedFlags[key] = newFlags[key];
}
if (Object.keys(updatedFlags).length > 0) log('backend:', tf.getBackend(), 'flags:', updatedFlags);
if (instance.config.debug && Object.keys(updatedFlags).length > 0) log('backend:', tf.getBackend(), 'flags:', updatedFlags);
}
if (instance.config.flags && Object.keys(instance.config.flags).length > 0) {
if (instance.config.debug) log('flags:', instance.config['flags']);
for (const [key, val] of Object.entries(instance.config.flags)) {
tf.env().set(key, val);
}
}
tf.enableProdMode();

View File

@ -1,39 +1,39 @@
2022-09-03 17:17:20 DATA:  Build {"name":"@vladmandic/human","version":"2.10.0"}
2022-09-03 17:17:20 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.0"}
2022-09-03 17:17:20 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2022-09-03 17:17:20 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.6","typescript":"4.8.2","typedoc":"0.23.14","eslint":"8.23.0"}
2022-09-03 17:17:20 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2022-09-03 17:17:20 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608}
2022-09-03 17:17:20 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":656537,"outputBytes":308492}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612}
2022-09-03 17:17:20 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":656541,"outputBytes":308496}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664}
2022-09-03 17:17:20 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":656593,"outputBytes":308546}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583}
2022-09-03 17:17:20 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":656512,"outputBytes":307366}
2022-09-03 17:17:20 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914}
2022-09-03 17:17:20 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3477843,"outputBytes":1687572}
2022-09-03 17:17:21 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3477843,"outputBytes":3108530}
2022-09-03 17:17:25 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30}
2022-09-03 17:17:27 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2022-09-03 17:17:27 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134}
2022-09-03 17:17:27 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15488,"outputBytes":7788}
2022-09-03 17:17:38 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0}
2022-09-03 17:17:38 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2022-09-03 17:17:38 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"}
2022-09-03 17:17:38 INFO:  Done...
2022-09-03 17:17:39 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193}
2022-09-03 17:17:39 STATE: Copy: {"input":"types/human.d.ts"}
2022-09-03 17:17:39 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2022-09-03 17:17:39 STATE: Models {"folder":"./models","models":13}
2022-09-03 17:17:39 STATE: Models {"folder":"../human-models/models","models":42}
2022-09-03 17:17:39 STATE: Models {"folder":"../blazepose/model/","models":4}
2022-09-03 17:17:39 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2022-09-03 17:17:39 STATE: Models {"folder":"../efficientpose/models","models":3}
2022-09-03 17:17:39 STATE: Models {"folder":"../insightface/models","models":5}
2022-09-03 17:17:39 STATE: Models {"folder":"../movenet/models","models":3}
2022-09-03 17:17:39 STATE: Models {"folder":"../nanodet/models","models":4}
2022-09-03 17:17:40 STATE: Models: {"count":57,"totalSize":383017442}
2022-09-03 17:17:40 INFO:  Human Build complete... {"logFile":"test/build.log"}
2022-09-06 10:28:18 DATA:  Build {"name":"@vladmandic/human","version":"2.10.0"}
2022-09-06 10:28:18 INFO:  Application: {"name":"@vladmandic/human","version":"2.10.0"}
2022-09-06 10:28:18 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2022-09-06 10:28:18 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.7","typescript":"4.8.2","typedoc":"0.23.14","eslint":"8.23.0"}
2022-09-06 10:28:18 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2022-09-06 10:28:18 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":159,"outputBytes":608}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":656961,"outputBytes":308696}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":167,"outputBytes":612}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":656965,"outputBytes":308700}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":206,"outputBytes":664}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":657017,"outputBytes":308750}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1125,"outputBytes":358}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1088,"outputBytes":583}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":656936,"outputBytes":307570}
2022-09-06 10:28:18 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":11,"inputBytes":1344,"outputBytes":2821914}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3478267,"outputBytes":1687773}
2022-09-06 10:28:18 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3478267,"outputBytes":3108879}
2022-09-06 10:28:23 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30}
2022-09-06 10:28:25 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2022-09-06 10:28:25 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6714,"outputBytes":3134}
2022-09-06 10:28:25 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":15488,"outputBytes":7788}
2022-09-06 10:28:35 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":110,"errors":0,"warnings":0}
2022-09-06 10:28:36 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2022-09-06 10:28:36 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"}
2022-09-06 10:28:36 INFO:  Done...
2022-09-06 10:28:36 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":193}
2022-09-06 10:28:36 STATE: Copy: {"input":"types/human.d.ts"}
2022-09-06 10:28:36 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2022-09-06 10:28:36 STATE: Models {"folder":"./models","models":13}
2022-09-06 10:28:36 STATE: Models {"folder":"../human-models/models","models":42}
2022-09-06 10:28:36 STATE: Models {"folder":"../blazepose/model/","models":4}
2022-09-06 10:28:36 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2022-09-06 10:28:36 STATE: Models {"folder":"../efficientpose/models","models":3}
2022-09-06 10:28:36 STATE: Models {"folder":"../insightface/models","models":5}
2022-09-06 10:28:36 STATE: Models {"folder":"../movenet/models","models":3}
2022-09-06 10:28:36 STATE: Models {"folder":"../nanodet/models","models":4}
2022-09-06 10:28:37 STATE: Models: {"count":57,"totalSize":383017442}
2022-09-06 10:28:37 INFO:  Human Build complete... {"logFile":"test/build.log"}