diff --git a/package.json b/package.json index 402ff05c..83a3505e 100644 --- a/package.json +++ b/package.json @@ -19,22 +19,29 @@ "type": "git", "url": "git+https://github.com/vladmandic/human.git" }, - "dependencies": {}, + "dependencies": { + }, "peerDependencies": {}, "devDependencies": { - "@tensorflow/tfjs": "^2.7.0", + "@tensorflow/tfjs-backend-cpu": "^2.7.0", "@tensorflow/tfjs-backend-wasm": "^2.7.0", + "@tensorflow/tfjs-backend-webgl": "^2.7.0", + "@tensorflow/tfjs-converter": "^2.7.0", + "@tensorflow/tfjs-core": "^2.7.0", + "@tensorflow/tfjs-data": "^2.7.0", + "@tensorflow/tfjs-layers": "^2.7.0", "@tensorflow/tfjs-node": "^2.7.0", + "@tensorflow/tfjs": "^2.7.0", "@vladmandic/pilogger": "^0.2.7", "chokidar": "^3.4.3", "dayjs": "^1.9.6", "esbuild": "^0.8.9", - "eslint": "^7.13.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-json": "^2.1.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", + "eslint": "^7.13.0", "rimraf": "^3.0.2", "seedrandom": "^3.0.5", "simple-git": "^2.22.0" diff --git a/src/age/age.js b/src/age/age.js index 76f2178e..5cfa707a 100644 --- a/src/age/age.js +++ b/src/age/age.js @@ -1,4 +1,4 @@ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as profile from '../profile.js'; const models = {}; diff --git a/src/emotion/emotion.js b/src/emotion/emotion.js index 7da8c0b7..c167c5c1 100644 --- a/src/emotion/emotion.js +++ b/src/emotion/emotion.js @@ -1,4 +1,4 @@ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as profile from '../profile.js'; const annotations = ['angry', 'disgust', 'fear', 'happy', 'sad', 'surpise', 'neutral']; diff --git a/src/gender/gender.js b/src/gender/gender.js index 1f987782..d2902e8f 100644 --- a/src/gender/gender.js +++ b/src/gender/gender.js @@ -1,4 +1,4 @@ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as profile from '../profile.js'; const models = {}; diff --git a/src/hand/box.js b/src/hand/box.js index 1510b8f4..bcdcfcc9 100644 --- a/src/hand/box.js +++ b/src/hand/box.js @@ -14,7 +14,7 @@ * limitations under the License. * ============================================================================= */ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; function getBoxSize(box) { return [ diff --git a/src/hand/handdetector.js b/src/hand/handdetector.js index e5061820..3edc584b 100644 --- a/src/hand/handdetector.js +++ b/src/hand/handdetector.js @@ -15,7 +15,7 @@ * ============================================================================= */ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as box from './box'; class HandDetector { diff --git a/src/hand/handpipeline.js b/src/hand/handpipeline.js index 3042b370..ff7537ea 100644 --- a/src/hand/handpipeline.js +++ b/src/hand/handpipeline.js @@ -15,7 +15,7 @@ * ============================================================================= */ -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as box from './box'; import * as util from './util'; diff --git a/src/hand/handpose.js b/src/hand/handpose.js index aeae3d91..8a62020b 100644 --- a/src/hand/handpose.js +++ b/src/hand/handpose.js @@ -16,7 +16,7 @@ */ // https://storage.googleapis.com/tfjs-models/demos/handpose/index.html -import { tf } from '../../dist/tfjs.esm.js'; +import * as tf from '../../dist/tfjs.esm.js'; import * as handdetector from './handdetector'; import * as pipeline from './handpipeline'; import * as anchors from './anchors'; diff --git a/src/human.js b/src/human.js index 7b5713cf..f348a4fe 100644 --- a/src/human.js +++ b/src/human.js @@ -1,4 +1,4 @@ -import { tf, wasm } from '../dist/tfjs.esm.js'; +import * as tf from '../dist/tfjs.esm.js'; import * as facemesh from './face/facemesh.js'; import * as age from './age/age.js'; import * as gender from './gender/gender.js'; @@ -172,7 +172,7 @@ class Human { if (this.config.backend === 'wasm') { this.log('settings wasm path:', this.config.wasmPath); - wasm.setWasmPaths(this.config.wasmPath); + tf.setWasmPaths(this.config.wasmPath); const simd = await tf.env().getAsync('WASM_HAS_SIMD_SUPPORT'); if (!simd) this.log('warning: wasm simd support is not enabled'); } diff --git a/src/image.js b/src/image.js index fd89d0f0..63f48405 100644 --- a/src/image.js +++ b/src/image.js @@ -1,4 +1,4 @@ -import { tf } from '../dist/tfjs.esm.js'; +import * as tf from '../dist/tfjs.esm.js'; import * as fxImage from './imagefx.js'; // internal temp canvases diff --git a/src/tf.js b/src/tf.js index 517e7531..0eda0669 100644 --- a/src/tf.js +++ b/src/tf.js @@ -1,4 +1,44 @@ // wrapper to load tfjs in a single place so version can be changed quickly -export * as tf from '@tensorflow/tfjs/dist/index.js'; -export * as wasm from '@tensorflow/tfjs-backend-wasm/dist/index.js'; +// simplified +// { modules: 1061, moduleBytes: 3772720, outputBytes: 1531035 } + +export * from '@tensorflow/tfjs/dist/index.js'; +export * from '@tensorflow/tfjs-backend-wasm/dist/index.js'; + +// modular +// { modules: 1064, moduleBytes: 3793219, outputBytes: 1535600 } + +/* +// get versions of all packages. +import { version as tfjs } from '@tensorflow/tfjs/package.json'; +import { version as versionCore } from '@tensorflow/tfjs-core/package.json'; +import { version as versionData } from '@tensorflow/tfjs-data/package.json'; +import { version as versionLayers } from '@tensorflow/tfjs-layers/package.json'; +import { version as versionConverter } from '@tensorflow/tfjs-converter/package.json'; +// for backends, get version from source so it can register backend during import +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 +export * from '@tensorflow/tfjs-core/dist/index.js'; +export * from '@tensorflow/tfjs-layers/dist/index.js'; +export * from '@tensorflow/tfjs-converter/dist/index.js'; +export * as data from '@tensorflow/tfjs-data/dist/index.js'; +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 versions +export const version = { + tfjs, + 'tfjs-core': versionCore, + 'tfjs-data': versionData, + 'tfjs-layers': versionLayers, + 'tfjs-converter': versionConverter, + 'tfjs-backend-cpu': version_cpu, + 'tfjs-backend-webgl': version_webgl, + 'tfjs-backend-wasm': version_wasm, +}; +*/