From 19e4e49c41c5133f57599a13851a2ad98ae138f4 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 11 Sep 2021 16:11:00 -0400 Subject: [PATCH] start using partial definitions --- CHANGELOG.md | 3 +++ TODO.md | 3 ++- src/human.ts | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c256b262..5fe92efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ### **HEAD -> main** 2021/09/11 mandic00@live.com + +### **origin/main** 2021/09/11 mandic00@live.com + - simplify dependencies - fix file permissions - remove old build server diff --git a/TODO.md b/TODO.md index 896cbd5b..edc3fb1d 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,8 @@ WebGL shader optimizations for faster load and initial detection - Implement WebGL uniforms for shaders: - Fix shader packing: -- Event emitters +- Refactor Human as multiple partial class +- Refactor ImageFX as ESM
diff --git a/src/human.ts b/src/human.ts index e3b38eb8..eabe89dd 100644 --- a/src/human.ts +++ b/src/human.ts @@ -160,7 +160,7 @@ export class Human { * Creates instance of Human library that is futher used for all operations * @param userConfig: {@link Config} */ - constructor(userConfig?: Config | Record) { + constructor(userConfig?: Partial) { this.version = app.version; // expose version property on instance of class Object.defineProperty(this, 'version', { value: app.version }); // expose version property directly on class itself defaults.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`; @@ -280,7 +280,7 @@ export class Human { * - Not explicitly required as any required model is load implicitly on it's first run * @param userConfig?: {@link Config} */ - async load(userConfig?: Config | Record) { + async load(userConfig?: Partial) { this.state = 'load'; const timeStamp = now(); const count = Object.values(this.models).filter((model) => model).length; @@ -464,7 +464,7 @@ export class Human { * @param userConfig?: {@link Config} * @returns result: {@link Result} */ - async detect(input: Input, userConfig?: Config | Record): Promise { + async detect(input: Input, userConfig?: Partial): Promise { // detection happens inside a promise return new Promise(async (resolve) => { this.state = 'config'; @@ -716,7 +716,7 @@ export class Human { * - only used for `webgl` and `humangl` backends * @param userConfig?: Config */ - async warmup(userConfig?: Config | Record): Promise { + async warmup(userConfig?: Partial): Promise { const t0 = now(); if (userConfig) this.config = mergeDeep(this.config, userConfig) as Config; if (!this.config.warmup || this.config.warmup === 'none') return { error: 'null' };