update backend

pull/293/head
Vladimir Mandic 2022-09-02 10:22:24 -04:00
parent 0c8567bb1f
commit e4b12ddff0
13 changed files with 225 additions and 224 deletions

View File

@ -9,7 +9,7 @@
## Changelog ## Changelog
### **HEAD -> main** 2022/09/01 mandic00@live.com ### **HEAD -> main** 2022/09/02 mandic00@live.com
- add browser iife tests - add browser iife tests
- minor bug fixes and increased test coverage - minor bug fixes and increased test coverage

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

14
dist/human.esm.js vendored
View File

@ -83885,6 +83885,8 @@ async function check(instance2, force = false) {
if (instance2.config.debug) if (instance2.config.debug)
log("setting backend:", instance2.config.backend); log("setting backend:", instance2.config.backend);
if (instance2.config.backend === "wasm") { if (instance2.config.backend === "wasm") {
if (instance2.config.debug)
log("backend wasm: set custom params");
if (env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY) if (env().flagRegistry.CANVAS2D_WILL_READ_FREQUENTLY)
env().set("CANVAS2D_WILL_READ_FREQUENTLY", true); env().set("CANVAS2D_WILL_READ_FREQUENTLY", true);
if (instance2.config.debug) if (instance2.config.debug)
@ -83916,18 +83918,12 @@ async function check(instance2, force = false) {
} }
} }
if (getBackend() === "humangl") { if (getBackend() === "humangl") {
if (env().flagRegistry.CHECK_COMPUTATION_FOR_ERRORS) if (instance2.config.debug)
env().set("CHECK_COMPUTATION_FOR_ERRORS", false); log("backend humangl: set custom params");
if (env().flagRegistry.WEBGL_CPU_FORWARD)
env().set("WEBGL_CPU_FORWARD", true);
if (env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS) if (env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS)
env().set("WEBGL_USE_SHAPES_UNIFORMS", true); env().set("WEBGL_USE_SHAPES_UNIFORMS", true);
if (env().flagRegistry.CPU_HANDOFF_SIZE_THRESHOLD)
env().set("CPU_HANDOFF_SIZE_THRESHOLD", 256);
if (env().flagRegistry.WEBGL_EXP_CONV) if (env().flagRegistry.WEBGL_EXP_CONV)
env().set("WEBGL_EXP_CONV", true); env().set("WEBGL_EXP_CONV", true);
if (env().flagRegistry.USE_SETTIMEOUTCUSTOM)
env().set("USE_SETTIMEOUTCUSTOM", true);
if (typeof instance2.config.deallocate !== "undefined" && instance2.config.deallocate) { if (typeof instance2.config.deallocate !== "undefined" && instance2.config.deallocate) {
log("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:", true); log("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:", true);
env().set("WEBGL_DELETE_TEXTURE_THRESHOLD", 0); env().set("WEBGL_DELETE_TEXTURE_THRESHOLD", 0);
@ -83939,6 +83935,8 @@ async function check(instance2, force = false) {
} }
} }
if (getBackend() === "webgpu") { if (getBackend() === "webgpu") {
if (instance2.config.debug)
log("backend webgpu: set custom params");
} }
enableProdMode(); enableProdMode();
await ready(); await ready();

File diff suppressed because one or more lines are too long

258
dist/human.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

View File

@ -122,6 +122,7 @@ export async function check(instance: Human, force = false) {
// customize wasm // customize wasm
if (instance.config.backend === '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 (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 (instance.config.debug) log('wasm path:', instance.config.wasmPath);
if (typeof tf.setWasmPaths !== 'undefined') tf.setWasmPaths(instance.config.wasmPath, instance.config.wasmPlatformFetch); 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 // customize humangl
if (tf.getBackend() === 'humangl') { if (tf.getBackend() === 'humangl') {
if (tf.env().flagRegistry.CHECK_COMPUTATION_FOR_ERRORS) tf.env().set('CHECK_COMPUTATION_FOR_ERRORS', false); if (instance.config.debug) log('backend humangl: set custom params');
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); // default=false <https://github.com/tensorflow/tfjs/issues/5205>
if (tf.env().flagRegistry.WEBGL_USE_SHAPES_UNIFORMS) tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); if (tf.env().flagRegistry.WEBGL_EXP_CONV) tf.env().set('WEBGL_EXP_CONV', true); // default=false <https://github.com/tensorflow/tfjs/issues/6678>
if (tf.env().flagRegistry.CPU_HANDOFF_SIZE_THRESHOLD) tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); // if (tf.env().flagRegistry['WEBGL_PACK_DEPTHWISECONV']) tf.env().set('WEBGL_PACK_DEPTHWISECONV', false); // default=true <https://github.com/tensorflow/tfjs/pull/4909>
if (tf.env().flagRegistry.WEBGL_EXP_CONV) tf.env().set('WEBGL_EXP_CONV', true); // <https://github.com/tensorflow/tfjs/issues/6678> // 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.USE_SETTIMEOUTCUSTOM) tf.env().set('USE_SETTIMEOUTCUSTOM', true); // <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_PACK_DEPTHWISECONV']) tf.env().set('WEBGL_PACK_DEPTHWISECONV', false); // 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 (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 (typeof instance.config.deallocate !== 'undefined' && instance.config.deallocate) { // hidden param
log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true); log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true);
tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0); tf.env().set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0);
@ -170,6 +170,7 @@ export async function check(instance: Human, force = false) {
// customize webgpu // customize webgpu
if (tf.getBackend() === '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_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_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); // if (tf.env().flagRegistry['WEBGPU_CPU_FORWARD']) tf.env().set('WEBGPU_CPU_FORWARD', true);

View File

@ -21,8 +21,8 @@ export const config = {
preserveDrawingBuffer: false, preserveDrawingBuffer: false,
depth: false, depth: false,
stencil: false, stencil: false,
failIfMajorPerformanceCaveat: false, failIfMajorPerformanceCaveat: false, // default=true
desynchronized: true, desynchronized: true, // default=undefined
}, },
}; };

View File

@ -1,39 +1,39 @@
2022-09-02 08:07:35 DATA:  Build {"name":"@vladmandic/human","version":"2.9.4"} 2022-09-02 10:21:42 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 10:21:42 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 10:21:42 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 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 08:07:35 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} 2022-09-02 10:21:42 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 10:21:42 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 08:07:40 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":30} 2022-09-02 10:21:47 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 10:21:49 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 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 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 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 08:07:53 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":113,"errors":0,"warnings":0} 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 08:07:53 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} 2022-09-02 10:21:59 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 10:21:59 STATE: Copy: {"input":"tfjs/tfjs.esm.d.ts"}
2022-09-02 08:07:53 INFO:  Done... 2022-09-02 10:21:59 INFO:  Done...
2022-09-02 08:07:54 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":198} 2022-09-02 10:22:00 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 10:22:00 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 10:22:00 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2022-09-02 08:07:54 STATE: Models {"folder":"./models","models":13} 2022-09-02 10:22:00 STATE: Models {"folder":"./models","models":13}
2022-09-02 08:07:54 STATE: Models {"folder":"../human-models/models","models":42} 2022-09-02 10:22:00 STATE: Models {"folder":"../human-models/models","models":42}
2022-09-02 08:07:54 STATE: Models {"folder":"../blazepose/model/","models":4} 2022-09-02 10:22:00 STATE: Models {"folder":"../blazepose/model/","models":4}
2022-09-02 08:07:54 STATE: Models {"folder":"../anti-spoofing/model","models":1} 2022-09-02 10:22:00 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2022-09-02 08:07:54 STATE: Models {"folder":"../efficientpose/models","models":3} 2022-09-02 10:22:00 STATE: Models {"folder":"../efficientpose/models","models":3}
2022-09-02 08:07:54 STATE: Models {"folder":"../insightface/models","models":5} 2022-09-02 10:22:00 STATE: Models {"folder":"../insightface/models","models":5}
2022-09-02 08:07:54 STATE: Models {"folder":"../movenet/models","models":3} 2022-09-02 10:22:00 STATE: Models {"folder":"../movenet/models","models":3}
2022-09-02 08:07:54 STATE: Models {"folder":"../nanodet/models","models":4} 2022-09-02 10:22:00 STATE: Models {"folder":"../nanodet/models","models":4}
2022-09-02 08:07:55 STATE: Models: {"count":57,"totalSize":383017442} 2022-09-02 10:22:00 STATE: Models: {"count":57,"totalSize":383017442}
2022-09-02 08:07:55 INFO:  Human Build complete... {"logFile":"test/build.log"} 2022-09-02 10:22:00 INFO:  Human Build complete... {"logFile":"test/build.log"}

View File

@ -5,20 +5,22 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, shrink-to-fit=yes"> <meta name="viewport" content="width=device-width, shrink-to-fit=yes">
<style> <style>
html { font-size: 14px; font-variant: small-caps; } html { font-size: 10px; font-variant: small-caps; }
body { margin: 0; background: black; color: white; width: 100vw; } body { margin: 0; background: black; color: white; width: 100vw; }
</style> </style>
</head> </head>
<body> <body>
<pre id="log" style="line-height: 150%; overflow-x: hidden; white-space: pre-wrap"></pre> <pre id="log" style="line-height: 150%; overflow-x: hidden; white-space: pre-wrap"></pre>
<script type="module"> <script type="module">
import { Human } from 'https://vladmandic.github.io/human/dist/human.esm.js'; /// import { Human } from 'https://vladmandic.github.io/human/dist/human.esm.js';
import { Human } from '../dist/human.esm.js';
const testConfig = { const testConfig = {
debug: true, debug: true,
async: false, async: false,
modelBasePath: 'https://vladmandic.github.io/human-models/models/', modelBasePath: 'https://vladmandic.github.io/human-models/models/',
cacheSensitivity: 0, cacheSensitivity: 0,
cacheModels: false,
warmup: 'face', warmup: 'face',
face: { iris: { enabled: false }, emotion: { enabled: false } }, face: { iris: { enabled: false }, emotion: { enabled: false } },
body: { enabled: false }, body: { enabled: false },
@ -47,31 +49,30 @@
async function main() { async function main() {
const human = new Human(testConfig); const human = new Human(testConfig);
log('human', human.version, { config: human.config }); log('human', human.version, { config: human.config });
for (const backend of ['wasm', 'webgl', 'humangl', 'webgpu', 'test1', 'test2', 'test3', 'test4']) { // for (const backend of ['wasm', 'webgl', 'humangl', 'webgpu', 'test1', 'test2', 'test3', 'test4']) {
// for (const backend of ['webgl']) {
for (const backend of ['webgl', 'humangl', 'test1', 'test2', 'test3', 'test4']) {
human.reset();
if (backend === 'test1') { if (backend === 'test1') {
human.config.backend = 'humangl'; human.config.backend = 'humangl';
await human.init(); await human.init();
human.tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', false);
human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); human.tf.env().set('WEBGL_EXP_CONV', false);
human.tf.env().set('WEBGL_EXP_CONV', true);
} else if (backend === 'test2') { } else if (backend === 'test2') {
human.config.backend = 'humangl'; human.config.backend = 'humangl';
await human.init(); await human.init();
human.tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256);
human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true);
// human.tf.env().set('WEBGL_EXP_CONV', true); human.tf.env().set('WEBGL_EXP_CONV', false);
} else if (backend === 'test3') { } else if (backend === 'test3') {
human.config.backend = 'humangl'; human.config.backend = 'humangl';
await human.init(); await human.init();
human.tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', false);
// human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); human.tf.env().set('WEBGL_EXP_CONV', true);
// human.tf.env().set('WEBGL_EXP_CONV', true);
} else if (backend === 'test4') { } else if (backend === 'test4') {
human.config.backend = 'humangl'; human.config.backend = 'humangl';
await human.init(); await human.init();
// human.tf.env().set('CPU_HANDOFF_SIZE_THRESHOLD', 256); human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true);
// human.tf.env().set('WEBGL_USE_SHAPES_UNIFORMS', true); human.tf.env().set('WEBGL_EXP_CONV', true);
// human.tf.env().set('WEBGL_EXP_CONV', true);
} else { } else {
human.config.backend = backend; human.config.backend = backend;
await human.init(); await human.init();
@ -80,17 +81,18 @@
continue; // wrong backend continue; // wrong backend
} }
} }
human.reset();
let res; let res;
/*
for (const model of Object.keys(human.models)) { for (const model of Object.keys(human.models)) {
if (human.models[model]) human.models[model] = null; if (human.models[model]) human.models[model] = null;
} }
await human.load(testConfig); await human.load(testConfig);
*/
const ops = await human.check(); const ops = await human.check();
if (ops && ops.length > 0) log(backend, { backend: human.tf.getBackend(), ops }); if (ops && ops.length > 0) log(backend, { backend: human.tf.getBackend(), ops });
const env = JSON.parse(JSON.stringify(human.env)); const env = JSON.parse(JSON.stringify(human.env));
env.kernels = human.env.kernels.length; env.kernels = human.env.kernels.length;
log(backend, { backend: human.tf.getBackend(), env }); log(backend, { backend: human.tf.getBackend(), env, tfjs: human.tf.env().flags });
for (const warmup of ['none', 'face', 'body']) { for (const warmup of ['none', 'face', 'body']) {
testConfig.warmup = warmup; testConfig.warmup = warmup;
res = await human.warmup(testConfig); res = await human.warmup(testConfig);