From 43f44cd114c06e570b4a3c293b5badee4e0c077e Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 2 Sep 2022 10:22:24 -0400 Subject: [PATCH] update backend --- CHANGELOG.md | 2 +- src/tfjs/backend.ts | 17 +++++----- src/tfjs/humangl.ts | 4 +-- test/build.log | 78 ++++++++++++++++++++++----------------------- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3969b83..5a49af60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ## Changelog -### **HEAD -> main** 2022/09/01 mandic00@live.com +### **HEAD -> main** 2022/09/02 mandic00@live.com - add browser iife tests - minor bug fixes and increased test coverage diff --git a/src/tfjs/backend.ts b/src/tfjs/backend.ts index 0eb7c3c9..2ff787bf 100644 --- a/src/tfjs/backend.ts +++ b/src/tfjs/backend.ts @@ -122,6 +122,7 @@ export async function check(instance: Human, force = false) { // customize wasm if (instance.config.backend === 'wasm') { + if (instance.config.debug) log('backend wasm: set custom params'); if (tf.env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY) tf.env().set('CANVAS2D_WILL_READ_FREQUENTLY', true); if (instance.config.debug) log('wasm path:', instance.config.wasmPath); if (typeof tf.setWasmPaths !== 'undefined') tf.setWasmPaths(instance.config.wasmPath, instance.config.wasmPlatformFetch); @@ -150,14 +151,13 @@ export async function check(instance: Human, force = false) { // customize humangl if (tf.getBackend() === 'humangl') { - if (tf.env().flagRegistry.CHECK_COMPUTATION_FOR_ERRORS) tf.env().set('CHECK_COMPUTATION_FOR_ERRORS', false); - if (tf.env().flagRegistry.WEBGL_CPU_FORWARD) tf.env().set('WEBGL_CPU_FORWARD', true); - if (tf.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS) tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); - if (tf.env().flagRegistry.CPU_HANDOFF_SIZE_THRESHOLD) tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); - if (tf.env().flagRegistry.WEBGL_EXP_CONV) tf.env().set('WEBGL_EXP_CONV', true); // - if (tf.env().flagRegistry.USE_SETTIMEOUTCUSTOM) tf.env().set('USE_SETTIMEOUTCUSTOM', true); // - // if (tf.env().flagRegistry['WEBGL_PACK_DEPTHWISECONV']) tf.env().set('WEBGL_PACK_DEPTHWISECONV', false); - // if (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 (instance.config.debug) log('backend humangl: set custom params'); + if (tf.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS) tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); // default=false + if (tf.env().flagRegistry.WEBGL_EXP_CONV) tf.env().set('WEBGL_EXP_CONV', true); // default=false + // if (tf.env().flagRegistry['WEBGL_PACK_DEPTHWISECONV']) tf.env().set('WEBGL_PACK_DEPTHWISECONV', false); // default=true + // if (tf.env().flagRegistry.USE_SETTIMEOUTCUSTOM) tf.env().set('USE_SETTIMEOUTCUSTOM', true); // default=false + // 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 log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true); tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0); @@ -170,6 +170,7 @@ export async function check(instance: Human, force = false) { // customize webgpu if (tf.getBackend() === 'webgpu') { + if (instance.config.debug) log('backend webgpu: set custom params'); // if (tf.env().flagRegistry['WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD']) tf.env().set('WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD', 512); // if (tf.env().flagRegistry['WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE']) tf.env().set('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', 0); // if (tf.env().flagRegistry['WEBGPU_CPU_FORWARD']) tf.env().set('WEBGPU_CPU_FORWARD', true); diff --git a/src/tfjs/humangl.ts b/src/tfjs/humangl.ts index 3ca951da..0ec56622 100644 --- a/src/tfjs/humangl.ts +++ b/src/tfjs/humangl.ts @@ -21,8 +21,8 @@ export const config = { preserveDrawingBuffer: false, depth: false, stencil: false, - failIfMajorPerformanceCaveat: false, - desynchronized: true, + failIfMajorPerformanceCaveat: false, // default=true + desynchronized: true, // default=undefined }, }; diff --git a/test/build.log b/test/build.log index f0d72fc7..9e008997 100644 --- a/test/build.log +++ b/test/build.log @@ -1,39 +1,39 @@ -2022-09-02 08:07:35 DATA:  Build {"name":"@vladmandic/human","version":"2.9.4"} -2022-09-02 08:07:35 INFO:  Application: {"name":"@vladmandic/human","version":"2.9.4"} -2022-09-02 08:07:35 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} -2022-09-02 08:07:35 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.6","typescript":"4.8.2","typedoc":"0.23.13","eslint":"8.23.0"} -2022-09-02 08:07:35 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} -2022-09-02 08:07:35 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} -2022-09-02 08:07:35 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-02 08:07:35 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":655767,"outputBytes":308629} -2022-09-02 08:07:35 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-02 08:07:35 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":655771,"outputBytes":308633} -2022-09-02 08:07:35 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-02 08:07:35 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":655823,"outputBytes":308683} -2022-09-02 08:07:35 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-02 08:07:35 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-02 08:07:35 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":655742,"outputBytes":307503} -2022-09-02 08:07:35 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-02 08:07:35 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3477073,"outputBytes":1687675} -2022-09-02 08:07:35 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3477073,"outputBytes":3108312} -2022-09-02 08:07:40 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30} -2022-09-02 08:07:42 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} -2022-09-02 08:07:42 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-02 08:07:42 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-02 08:07:53 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":113,"errors":0,"warnings":0} -2022-09-02 08:07:53 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} -2022-09-02 08:07:53 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} -2022-09-02 08:07:53 INFO:  Done... -2022-09-02 08:07:54 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":198} -2022-09-02 08:07:54 STATE: Copy: {"input":"types/human.d.ts"} -2022-09-02 08:07:54 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} -2022-09-02 08:07:54 STATE: Models {"folder":"./models","models":13} -2022-09-02 08:07:54 STATE: Models {"folder":"../human-models/models","models":42} -2022-09-02 08:07:54 STATE: Models {"folder":"../blazepose/model/","models":4} -2022-09-02 08:07:54 STATE: Models {"folder":"../anti-spoofing/model","models":1} -2022-09-02 08:07:54 STATE: Models {"folder":"../efficientpose/models","models":3} -2022-09-02 08:07:54 STATE: Models {"folder":"../insightface/models","models":5} -2022-09-02 08:07:54 STATE: Models {"folder":"../movenet/models","models":3} -2022-09-02 08:07:54 STATE: Models {"folder":"../nanodet/models","models":4} -2022-09-02 08:07:55 STATE: Models: {"count":57,"totalSize":383017442} -2022-09-02 08:07:55 INFO:  Human Build complete... {"logFile":"test/build.log"} +2022-09-02 10:21:42 DATA:  Build {"name":"@vladmandic/human","version":"2.9.4"} +2022-09-02 10:21:42 INFO:  Application: {"name":"@vladmandic/human","version":"2.9.4"} +2022-09-02 10:21:42 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} +2022-09-02 10:21:42 INFO:  Toolchain: {"build":"0.7.11","esbuild":"0.15.6","typescript":"4.8.2","typedoc":"0.23.13","eslint":"8.23.0"} +2022-09-02 10:21:42 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} +2022-09-02 10:21:42 STATE: Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]} +2022-09-02 10:21:42 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-02 10:21:42 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":75,"inputBytes":655998,"outputBytes":308454} +2022-09-02 10:21:42 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-02 10:21:42 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":75,"inputBytes":656002,"outputBytes":308458} +2022-09-02 10:21:42 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-02 10:21:42 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":75,"inputBytes":656054,"outputBytes":308508} +2022-09-02 10:21:42 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-02 10:21:42 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-02 10:21:42 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":75,"inputBytes":655973,"outputBytes":307328} +2022-09-02 10:21:42 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-02 10:21:42 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":75,"inputBytes":3477304,"outputBytes":1687535} +2022-09-02 10:21:43 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":75,"inputBytes":3477304,"outputBytes":3108145} +2022-09-02 10:21:47 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30} +2022-09-02 10:21:49 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true} +2022-09-02 10:21:49 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-02 10:21:49 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-02 10:21:59 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":113,"errors":0,"warnings":0} +2022-09-02 10:21:59 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} +2022-09-02 10:21:59 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"} +2022-09-02 10:21:59 INFO:  Done... +2022-09-02 10:22:00 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":198} +2022-09-02 10:22:00 STATE: Copy: {"input":"types/human.d.ts"} +2022-09-02 10:22:00 INFO:  Analyze models: {"folders":8,"result":"models/models.json"} +2022-09-02 10:22:00 STATE: Models {"folder":"./models","models":13} +2022-09-02 10:22:00 STATE: Models {"folder":"../human-models/models","models":42} +2022-09-02 10:22:00 STATE: Models {"folder":"../blazepose/model/","models":4} +2022-09-02 10:22:00 STATE: Models {"folder":"../anti-spoofing/model","models":1} +2022-09-02 10:22:00 STATE: Models {"folder":"../efficientpose/models","models":3} +2022-09-02 10:22:00 STATE: Models {"folder":"../insightface/models","models":5} +2022-09-02 10:22:00 STATE: Models {"folder":"../movenet/models","models":3} +2022-09-02 10:22:00 STATE: Models {"folder":"../nanodet/models","models":4} +2022-09-02 10:22:00 STATE: Models: {"count":57,"totalSize":383017442} +2022-09-02 10:22:00 INFO:  Human Build complete... {"logFile":"test/build.log"}