From ccad4a8c20596b76fb89fa380c89c8b6308b7268 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 6 Jun 2021 12:58:06 -0400 Subject: [PATCH] update wasm to tfjs 3.7.0 --- CHANGELOG.md | 2 ++ demo/index.js | 4 ++-- src/tfjs/tf-browser.ts | 28 +++++++++++++++++----------- tsconfig.json | 2 ++ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25eca82e..c3af11b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Repository: **** ### **HEAD -> main** 2021/06/05 mandic00@live.com +- modularize build platform +- enable body segmentation and background replacement in demo - minor git corruption - unified build - enable body segmentation and background replacement diff --git a/demo/index.js b/demo/index.js index 31de8852..9d940842 100644 --- a/demo/index.js +++ b/demo/index.js @@ -30,7 +30,7 @@ let human; let userConfig = { warmup: 'none', backend: 'humangl', - wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.6.0/dist/', + wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.7.0/dist/', /* async: false, cacheSensitivity: 0, @@ -255,7 +255,7 @@ async function drawResults(input) { const processing = result.canvas ? `processing: ${result.canvas.width} x ${result.canvas.height}` : ''; const avgDetect = ui.detectFPS.length > 0 ? Math.trunc(10 * ui.detectFPS.reduce((a, b) => a + b, 0) / ui.detectFPS.length) / 10 : 0; const avgDraw = ui.drawFPS.length > 0 ? Math.trunc(10 * ui.drawFPS.reduce((a, b) => a + b, 0) / ui.drawFPS.length) / 10 : 0; - const warning = (ui.detectFPS.length > 5) && (avgDetect < 5) ? 'warning: your performance is low: try switching to higher performance backend, lowering resolution or disabling some models' : ''; + const warning = (ui.detectFPS.length > 5) && (avgDetect < 2) ? 'warning: your performance is low: try switching to higher performance backend, lowering resolution or disabling some models' : ''; const fps = avgDetect > 0 ? `FPS process:${avgDetect} refresh:${avgDraw}` : ''; document.getElementById('log').innerHTML = ` video: ${ui.camera.name} | facing: ${ui.camera.facing} | screen: ${window.innerWidth} x ${window.innerHeight} camera: ${ui.camera.width} x ${ui.camera.height} ${processing}
diff --git a/src/tfjs/tf-browser.ts b/src/tfjs/tf-browser.ts index f22a2023..309e3345 100644 --- a/src/tfjs/tf-browser.ts +++ b/src/tfjs/tf-browser.ts @@ -2,15 +2,9 @@ * Creates tfjs bundle used by Human browser build target */ -// simplified -// { modules: 1250, moduleBytes: 4013323, imports: 7, importBytes: 2255, outputBytes: 2991826, outputFiles: 'dist/tfjs.esm.js' } -// export * from '@tensorflow/tfjs/dist/index.js'; -// export * from '@tensorflow/tfjs-backend-wasm'; - -// modular -// { modules: 1253, moduleBytes: 4029357, imports: 7, importBytes: 2285, outputBytes: 2998298, outputFiles: 'dist/tfjs.esm.js' } - -// get versions of all packages. +// import from dist +// modules: 1299, moduleBytes: 4230827, imports: 7, importBytes: 2478, outputBytes: 2357435 +// get versions of all packages import * as packageBundle from '@tensorflow/tfjs/package.json'; import * as packageCore from '@tensorflow/tfjs-core/package.json'; import * as packageData from '@tensorflow/tfjs-data/package.json'; @@ -21,7 +15,7 @@ import { version_cpu } from '@tensorflow/tfjs-backend-cpu/dist/index.js'; import { version_webgl } from '@tensorflow/tfjs-backend-webgl/dist/index.js'; import { version_wasm } from '@tensorflow/tfjs-backend-wasm/dist/index.js'; -// export all - compiled +// export all export * from '@tensorflow/tfjs-core/dist/index.js'; export * from '@tensorflow/tfjs-layers/dist/index.js'; export * from '@tensorflow/tfjs-converter/dist/index.js'; @@ -30,8 +24,20 @@ export * from '@tensorflow/tfjs-backend-cpu/dist/index.js'; export * from '@tensorflow/tfjs-backend-webgl/dist/index.js'; export * from '@tensorflow/tfjs-backend-wasm/dist/index.js'; -// export all - sources +// import from src +// modules: 1681, moduleBytes: 5711239, imports: 7, importBytes: 2701, outputBytes: 2107830 +// get versions of all packages /* +import * as packageBundle from '@tensorflow/tfjs/package.json'; +import * as packageCore from '@tensorflow/tfjs-core/package.json'; +import * as packageData from '@tensorflow/tfjs-data/package.json'; +import * as packageLayers from '@tensorflow/tfjs-layers/package.json'; +import * as packageConverter from '@tensorflow/tfjs-converter/package.json'; +import { version_cpu } from '@tensorflow/tfjs-backend-cpu/src/index'; +import { version_webgl } from '@tensorflow/tfjs-backend-webgl/src/index'; +import { version_wasm } from '@tensorflow/tfjs-backend-wasm/src/index'; + +// export all export * from '@tensorflow/tfjs-core/src/index'; export * from '@tensorflow/tfjs-layers/src/index'; export * from '@tensorflow/tfjs-converter/src/index'; diff --git a/tsconfig.json b/tsconfig.json index 9c034389..6cca18ac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -50,6 +50,8 @@ "readme": "none", "out": "typedoc", "entryPoints": "src/human.ts", + "exclude": ["**/node_modules/**"], + "externalPattern": ["**/node_modules/**"], "logLevel": "Info", "logger": "none", "theme": "wiki/theme/"