mirror of https://github.com/vladmandic/human
update typedefs and typedocs
parent
ec53f70128
commit
597da8c7d4
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||||
"mainEntryPointFilePath": "types/lib/src/human.d.ts",
|
"mainEntryPointFilePath": "types/lib/src/human.d.ts",
|
||||||
"bundledPackages": ["@types/offscreencanvas", "@tensorflow/tfjs-core", "@tensorflow/tfjs-converter", "@tensorflow/tfjs-data"],
|
"bundledPackages": ["@tensorflow/tfjs-core", "@tensorflow/tfjs-converter", "@tensorflow/tfjs-data", "@tensorflow/tfjs-layers"],
|
||||||
"compiler": {
|
"compiler": {
|
||||||
"skipLibCheck": false
|
"skipLibCheck": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
"format": "esm",
|
"format": "esm",
|
||||||
"input": "src/human.ts",
|
"input": "src/human.ts",
|
||||||
"output": "dist/human.esm-nobundle.js",
|
"output": "dist/human.esm-nobundle.js",
|
||||||
"sourcemap": true,
|
"sourcemap": false,
|
||||||
"external": ["@tensorflow"]
|
"external": ["@tensorflow"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,54 @@
|
||||||
"radix":"off"
|
"radix":"off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"files": ["**/*.d.ts"],
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"commonjs": false,
|
||||||
|
"node": false,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"project": ["./tsconfig.json"]
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"airbnb-base",
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||||
|
"plugin:@typescript-eslint/strict",
|
||||||
|
"plugin:import/recommended",
|
||||||
|
"plugin:promise/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/array-type":"off",
|
||||||
|
"@typescript-eslint/ban-types":"off",
|
||||||
|
"@typescript-eslint/consistent-indexed-object-style":"off",
|
||||||
|
"@typescript-eslint/consistent-type-definitions":"off",
|
||||||
|
"@typescript-eslint/no-empty-interface":"off",
|
||||||
|
"@typescript-eslint/no-explicit-any":"off",
|
||||||
|
"@typescript-eslint/no-invalid-void-type":"off",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-arguments":"off",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-constraint":"off",
|
||||||
|
"comma-dangle":"off",
|
||||||
|
"indent":"off",
|
||||||
|
"lines-between-class-members":"off",
|
||||||
|
"max-classes-per-file":"off",
|
||||||
|
"max-len":"off",
|
||||||
|
"no-multiple-empty-lines":"off",
|
||||||
|
"no-shadow":"off",
|
||||||
|
"no-use-before-define":"off",
|
||||||
|
"quotes":"off",
|
||||||
|
"semi":"off"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"files": ["**/*.js"],
|
"files": ["**/*.js"],
|
||||||
"env": {
|
"env": {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### **HEAD -> main** 2022/09/27 mandic00@live.com
|
### **HEAD -> main** 2022/09/29 mandic00@live.com
|
||||||
|
|
||||||
- create funding.yml
|
- create funding.yml
|
||||||
- fix rotation interpolation
|
- fix rotation interpolation
|
||||||
|
|
24
TODO.md
24
TODO.md
|
@ -24,11 +24,11 @@ N/A
|
||||||
|
|
||||||
### Face with Attention
|
### Face with Attention
|
||||||
|
|
||||||
`FaceMesh-Attention` is not supported in browser using `WASM` backend due to missing kernel op in **TFJS**
|
`FaceMesh-Attention` is not supported when using `WASM` backend due to missing kernel op in **TFJS**
|
||||||
|
|
||||||
### Object Detection
|
### Object Detection
|
||||||
|
|
||||||
`NanoDet` model is not supported in in browser using `WASM` backend due to missing kernel op in **TFJS**
|
`NanoDet` model is not supported when using `WASM` backend due to missing kernel op in **TFJS**
|
||||||
|
|
||||||
### WebGPU
|
### WebGPU
|
||||||
|
|
||||||
|
@ -45,16 +45,20 @@ Enable via `about:config` -> `gfx.offscreencanvas.enabled`
|
||||||
## Pending Release Changes
|
## Pending Release Changes
|
||||||
|
|
||||||
- New methods [`human.webcam.*`](https://vladmandic.github.io/human/typedoc/classes/WebCam.html)
|
- New methods [`human.webcam.*`](https://vladmandic.github.io/human/typedoc/classes/WebCam.html)
|
||||||
Directgly configures and controls WebCam streams
|
Enables built-in configuration and control of **WebCam** streams
|
||||||
- New method [`human.video()`](https://vladmandic.github.io/human/typedoc/classes/Human.html#video)
|
- New method [`human.video()`](https://vladmandic.github.io/human/typedoc/classes/Human.html#video)
|
||||||
Runs continous detection of an input video instead of processing each frame manually using `human.detect()`
|
Runs continous detection of an input **video**
|
||||||
- New simple demo [*Live*](https://vladmandic.github.io/human/demo/video/index.html)
|
instead of processing each frame manually using `human.detect()`
|
||||||
Full HTML and JavaScript code in less than a screen
|
- New simple demo [*Live*](https://vladmandic.github.io/human/demo/video/index.html) | [*Code*](https://github.com/vladmandic/human/blob/main/demo/video/index.html)
|
||||||
- New advanced demo using BabylonJS <https://vladmandic.github.io/human-bjs-vrm>
|
*Full HTML and JavaScript code in less than a screen*
|
||||||
- Enable model cache when using web workers
|
- New advanced demo using **BabylonJS and VRM** [*Live*](https://vladmandic.github.io/human-bjs-vrm) | [*Code*](https://github.com/vladmandic/human-bjs-vrm)
|
||||||
- Fix for `face.rotation` interpolation
|
- Update **TypeDoc** generation [*Link*](https://vladmandic.github.io/human/typedoc)
|
||||||
|
- Update **TypeDefs** bundle generation [*Link*](https://github.com/vladmandic/human/blob/main/types/human.d.ts)
|
||||||
|
No external dependencies
|
||||||
|
- Fix model caching when using web workers
|
||||||
|
- Fix `face.rotation` when using interpolation
|
||||||
- Improve NodeJS resolver when using ESM
|
- Improve NodeJS resolver when using ESM
|
||||||
- Update demo `demo/typescript`
|
- Update demo `demo/typescript`
|
||||||
- Update demo `demo/faceid`
|
- Update demo `demo/faceid`
|
||||||
- Update demo `demo/nodejs/process-folder.js`
|
- Update demo `demo/nodejs/process-folder.js`
|
||||||
and re-process `/samples`
|
and re-process `/samples` [*Link*](https://vladmandic.github.io/human/samples)
|
||||||
|
|
40
build.js
40
build.js
|
@ -37,6 +37,21 @@ function copy(src, dst) {
|
||||||
fs.writeFileSync(dst, buffer);
|
fs.writeFileSync(dst, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function write(str, dst) {
|
||||||
|
fs.writeFileSync(dst, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter(str, src) {
|
||||||
|
if (!fs.existsSync(src)) return;
|
||||||
|
const buffer = fs.readFileSync(src, 'UTF-8');
|
||||||
|
const lines = buffer.split(/\r?\n/);
|
||||||
|
const out = [];
|
||||||
|
for (const line of lines) {
|
||||||
|
if (!line.includes(str)) out.push(line);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(src, out.join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
async function analyzeModels() {
|
async function analyzeModels() {
|
||||||
log.info('Analyze models:', { folders: modelsFolders.length, result: modelsOut });
|
log.info('Analyze models:', { folders: modelsFolders.length, result: modelsOut });
|
||||||
let totalSize = 0;
|
let totalSize = 0;
|
||||||
|
@ -95,13 +110,24 @@ async function main() {
|
||||||
});
|
});
|
||||||
log.state('API-Extractor:', { succeeeded: extractorResult.succeeded, errors: extractorResult.errorCount, warnings: extractorResult.warningCount });
|
log.state('API-Extractor:', { succeeeded: extractorResult.succeeded, errors: extractorResult.errorCount, warnings: extractorResult.warningCount });
|
||||||
// distribute typedefs
|
// distribute typedefs
|
||||||
log.state('Copy:', { input: 'types/human.d.ts' });
|
// log.state('Copy:', { input: 'types/human.d.ts' });
|
||||||
copy('types/human.d.ts', 'dist/human.esm-nobundle.d.ts');
|
// copy('types/human.d.ts', 'dist/human.esm-nobundle.d.ts');
|
||||||
copy('types/human.d.ts', 'dist/human.esm.d.ts');
|
// copy('types/human.d.ts', 'dist/human.esm.d.ts');
|
||||||
copy('types/human.d.ts', 'dist/human.d.ts');
|
// copy('types/human.d.ts', 'dist/human.d.ts');
|
||||||
copy('types/human.d.ts', 'dist/human.node-gpu.d.ts');
|
// copy('types/human.d.ts', 'dist/human.node-gpu.d.ts');
|
||||||
copy('types/human.d.ts', 'dist/human.node.d.ts');
|
// copy('types/human.d.ts', 'dist/human.node.d.ts');
|
||||||
copy('types/human.d.ts', 'dist/human.node-wasm.d.ts');
|
// copy('types/human.d.ts', 'dist/human.node-wasm.d.ts');
|
||||||
|
log.state('Filter:', { input: 'types/human.d.ts' });
|
||||||
|
filter('reference types', 'types/human.d.ts');
|
||||||
|
log.state('Link:', { input: 'types/human.d.ts' });
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.esm-nobundle.d.ts');
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.esm.d.ts');
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.d.ts');
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.node-gpu.d.ts');
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.node.d.ts');
|
||||||
|
write('export * from \'../types/human\';', 'dist/human.node-wasm.d.ts');
|
||||||
|
// export * from '../types/human';
|
||||||
|
|
||||||
// generate model signature
|
// generate model signature
|
||||||
await analyzeModels();
|
await analyzeModels();
|
||||||
log.info('Human Build complete...', { logFile });
|
log.info('Human Build complete...', { logFile });
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@
|
||||||
import * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human
|
import * as H from '../../dist/human.esm.js'; // equivalent of @vladmandic/Human
|
||||||
|
|
||||||
const humanConfig: Partial<H.Config> = { // user configuration for human, used to fine-tune behavior
|
const humanConfig: Partial<H.Config> = { // user configuration for human, used to fine-tune behavior
|
||||||
// backend: 'wasm' as const,
|
// backend: 'wasm',
|
||||||
// wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.20.0/dist/',
|
// wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.20.0/dist/',
|
||||||
// cacheSensitivity: 0,
|
// cacheSensitivity: 0,
|
||||||
// async: false,
|
// async: false,
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
"@tensorflow/tfjs-node": "^3.20.0",
|
"@tensorflow/tfjs-node": "^3.20.0",
|
||||||
"@tensorflow/tfjs-node-gpu": "^3.20.0",
|
"@tensorflow/tfjs-node-gpu": "^3.20.0",
|
||||||
"@tensorflow/tfjs-tflite": "0.0.1-alpha.8",
|
"@tensorflow/tfjs-tflite": "0.0.1-alpha.8",
|
||||||
|
"@types/emscripten": "^1.39.6",
|
||||||
"@types/node": "^18.7.23",
|
"@types/node": "^18.7.23",
|
||||||
"@types/offscreencanvas": "^2019.7.0",
|
"@types/offscreencanvas": "^2019.7.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||||
|
@ -98,6 +99,7 @@
|
||||||
"eslint-plugin-json": "^3.1.0",
|
"eslint-plugin-json": "^3.1.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^6.0.1",
|
"eslint-plugin-promise": "^6.0.1",
|
||||||
|
"long": "^5.2.0",
|
||||||
"node-fetch": "^3.2.10",
|
"node-fetch": "^3.2.10",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"seedrandom": "^3.0.5",
|
"seedrandom": "^3.0.5",
|
||||||
|
|
|
@ -209,10 +209,10 @@ export interface GestureConfig {
|
||||||
enabled: boolean,
|
enabled: boolean,
|
||||||
}
|
}
|
||||||
/** Possible TensorFlow backends */
|
/** Possible TensorFlow backends */
|
||||||
export type BackendType = ['cpu', 'wasm', 'webgl', 'humangl', 'tensorflow', 'webgpu'];
|
export type BackendEnum = '' | 'cpu' | 'wasm' | 'webgl' | 'humangl' | 'tensorflow' | 'webgpu';
|
||||||
|
|
||||||
/** Possible values for `human.warmup` */
|
/** Possible values for `human.warmup` */
|
||||||
export type WarmupType = ['' | 'none' | 'face' | 'full' | 'body'];
|
export type WarmupEnum = '' | 'none' | 'face' | 'full' | 'body';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration interface definition for **Human** library
|
* Configuration interface definition for **Human** library
|
||||||
|
@ -226,7 +226,7 @@ export interface Config {
|
||||||
* - NodeJS: `cpu`, `wasm`, `tensorflow`
|
* - NodeJS: `cpu`, `wasm`, `tensorflow`
|
||||||
* default: `webgl` for browser and `tensorflow` for nodejs
|
* default: `webgl` for browser and `tensorflow` for nodejs
|
||||||
*/
|
*/
|
||||||
backend: '' | 'cpu' | 'wasm' | 'webgl' | 'humangl' | 'tensorflow' | 'webgpu',
|
backend: BackendEnum,
|
||||||
|
|
||||||
/** Path to *.wasm files if backend is set to `wasm`
|
/** Path to *.wasm files if backend is set to `wasm`
|
||||||
*
|
*
|
||||||
|
@ -258,7 +258,7 @@ export interface Config {
|
||||||
*
|
*
|
||||||
* default: `full`
|
* default: `full`
|
||||||
*/
|
*/
|
||||||
warmup: '' | 'none' | 'face' | 'full' | 'body',
|
warmup: WarmupEnum,
|
||||||
|
|
||||||
/** Base model path (typically starting with file://, http:// or https://) for all models
|
/** Base model path (typically starting with file://, http:// or https://) for all models
|
||||||
* - individual modelPath values are relative to this path
|
* - individual modelPath values are relative to this path
|
||||||
|
|
|
@ -9,15 +9,17 @@ export * from './result';
|
||||||
/* Explict reexport of main @tensorflow/tfjs types */
|
/* Explict reexport of main @tensorflow/tfjs types */
|
||||||
export type { Tensor, TensorLike, GraphModel, Rank } from './tfjs/types';
|
export type { Tensor, TensorLike, GraphModel, Rank } from './tfjs/types';
|
||||||
|
|
||||||
|
// re-export types
|
||||||
export type { DrawOptions } from './draw/options';
|
export type { DrawOptions } from './draw/options';
|
||||||
export type { Descriptor } from './face/match';
|
|
||||||
export type { Box, Point } from './result';
|
export type { Box, Point } from './result';
|
||||||
export type { Models } from './models';
|
export { env, Env } from './util/env';
|
||||||
export type { Env } from './util/env';
|
|
||||||
export type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
|
export type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
|
||||||
export type { Emotion, Finger, FingerCurl, FingerDirection, HandType, Gender, Race, FaceLandmark, BodyLandmark, BodyAnnotation, ObjectType } from './result';
|
export type { Emotion, Finger, FingerCurl, FingerDirection, HandType, Gender, Race, FaceLandmark, BodyLandmark, BodyAnnotation, ObjectType } from './result';
|
||||||
export type { WebCamConfig } from './util/webcam';
|
export type { WebCam, WebCamConfig } from './util/webcam';
|
||||||
export { env } from './util/env';
|
// export type { Models, ModelStats, KernelOps } from './models';
|
||||||
|
export type { ModelInfo } from './tfjs/load';
|
||||||
|
|
||||||
|
// define enum types
|
||||||
|
|
||||||
/** Events dispatched by `human.events`
|
/** Events dispatched by `human.events`
|
||||||
* - `create`: triggered when Human object is instantiated
|
* - `create`: triggered when Human object is instantiated
|
||||||
|
@ -27,7 +29,6 @@ export { env } from './util/env';
|
||||||
* - `warmup`: triggered when warmup is complete
|
* - `warmup`: triggered when warmup is complete
|
||||||
*/
|
*/
|
||||||
export type Events = 'create' | 'load' | 'image' | 'result' | 'warmup' | 'error';
|
export type Events = 'create' | 'load' | 'image' | 'result' | 'warmup' | 'error';
|
||||||
|
|
||||||
/** Defines all possible canvas types */
|
/** Defines all possible canvas types */
|
||||||
export type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
|
export type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
|
||||||
/** Defines all possible image types */
|
/** Defines all possible image types */
|
||||||
|
@ -40,11 +41,3 @@ export type ImageObjects = ImageData | ImageBitmap
|
||||||
export type ExternalCanvas = typeof env.Canvas;
|
export type ExternalCanvas = typeof env.Canvas;
|
||||||
/** Defines all possible input types for **Human** detection */
|
/** Defines all possible input types for **Human** detection */
|
||||||
export type Input = Tensor | AnyCanvas | AnyImage | AnyVideo | ImageObjects | ExternalCanvas;
|
export type Input = Tensor | AnyCanvas | AnyImage | AnyVideo | ImageObjects | ExternalCanvas;
|
||||||
/** WebCam helper class */
|
|
||||||
export type { WebCam } from './util/webcam';
|
|
||||||
/** Defines model stats */
|
|
||||||
export type { ModelStats } from './models';
|
|
||||||
/** Defines individual model sizes */
|
|
||||||
export type { ModelInfo } from './tfjs/load';
|
|
||||||
/** Defines model kernel ops */
|
|
||||||
export type { KernelOps } from './models';
|
|
||||||
|
|
12
src/human.ts
12
src/human.ts
|
@ -11,6 +11,7 @@
|
||||||
import { log, now, mergeDeep, validate } from './util/util';
|
import { log, now, mergeDeep, validate } from './util/util';
|
||||||
import { defaults } from './config';
|
import { defaults } from './config';
|
||||||
import { env, Env } from './util/env';
|
import { env, Env } from './util/env';
|
||||||
|
import { WebCam } from './util/webcam';
|
||||||
import { setModelLoadOptions } from './tfjs/load';
|
import { setModelLoadOptions } from './tfjs/load';
|
||||||
import * as tf from '../dist/tfjs.esm.js';
|
import * as tf from '../dist/tfjs.esm.js';
|
||||||
import * as app from '../package.json';
|
import * as app from '../package.json';
|
||||||
|
@ -36,10 +37,9 @@ import * as persons from './util/persons';
|
||||||
import * as posenet from './body/posenet';
|
import * as posenet from './body/posenet';
|
||||||
import * as segmentation from './segmentation/segmentation';
|
import * as segmentation from './segmentation/segmentation';
|
||||||
import * as warmups from './warmup';
|
import * as warmups from './warmup';
|
||||||
import * as webcam from './util/webcam';
|
|
||||||
|
|
||||||
// type definitions
|
// type definitions
|
||||||
import type { Input, Tensor, DrawOptions, Config, Result, FaceResult, HandResult, BodyResult, ObjectResult, GestureResult, PersonResult, AnyCanvas, ModelStats } from './exports';
|
import type { Input, Tensor, DrawOptions, Config, Result, FaceResult, HandResult, BodyResult, ObjectResult, GestureResult, PersonResult, AnyCanvas } from './exports';
|
||||||
// type exports
|
// type exports
|
||||||
export * from './exports';
|
export * from './exports';
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export class Human {
|
||||||
|
|
||||||
/** Currently loaded models
|
/** Currently loaded models
|
||||||
* @internal
|
* @internal
|
||||||
* {@link Models}
|
* {@link models#Models}
|
||||||
*/
|
*/
|
||||||
models: models.Models;
|
models: models.Models;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ export class Human {
|
||||||
// include platform info
|
// include platform info
|
||||||
this.emit('create');
|
this.emit('create');
|
||||||
if (this.config.debug || this.env.browser) log(`version: ${this.version}`);
|
if (this.config.debug || this.env.browser) log(`version: ${this.version}`);
|
||||||
if (this.config.debug) log(`tfjs version: ${this.tf.version['tfjs-core'] as string}`);
|
if (this.config.debug) log(`tfjs version: ${this.tf.version['tfjs-core']}`);
|
||||||
const envTemp = JSON.parse(JSON.stringify(this.env));
|
const envTemp = JSON.parse(JSON.stringify(this.env));
|
||||||
delete envTemp.kernels;
|
delete envTemp.kernels;
|
||||||
delete envTemp.initial;
|
delete envTemp.initial;
|
||||||
|
@ -299,7 +299,7 @@ export class Human {
|
||||||
/** WebCam helper methods
|
/** WebCam helper methods
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public webcam = new webcam.WebCam();
|
public webcam = new WebCam();
|
||||||
|
|
||||||
/** Load method preloads all configured models on-demand
|
/** Load method preloads all configured models on-demand
|
||||||
* - Not explicitly required as any required model is load implicitly on it's first run
|
* - Not explicitly required as any required model is load implicitly on it's first run
|
||||||
|
@ -351,7 +351,7 @@ export class Human {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get model loading/loaded stats */
|
/** get model loading/loaded stats */
|
||||||
getModelStats(): ModelStats { return models.getModelStats(this); }
|
getModelStats(): models.ModelStats { return models.getModelStats(this); }
|
||||||
|
|
||||||
/** Warmup method pre-initializes all configured models for faster inference
|
/** Warmup method pre-initializes all configured models for faster inference
|
||||||
* - can take significant time on startup
|
* - can take significant time on startup
|
||||||
|
|
|
@ -61,6 +61,7 @@ export class Models {
|
||||||
antispoof: null | GraphModel | Promise<GraphModel> = null;
|
antispoof: null | GraphModel | Promise<GraphModel> = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** structure that holds global stats for currently loaded models */
|
||||||
export interface ModelStats {
|
export interface ModelStats {
|
||||||
numLoadedModels: number,
|
numLoadedModels: number,
|
||||||
numEnabledModels: undefined,
|
numEnabledModels: undefined,
|
||||||
|
@ -73,7 +74,11 @@ export interface ModelStats {
|
||||||
modelStats: ModelInfo[],
|
modelStats: ModelInfo[],
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getModelStats = (instance: Human): ModelStats => {
|
let instance: Human;
|
||||||
|
|
||||||
|
export const getModelStats = (currentInstance: Human): ModelStats => {
|
||||||
|
if (currentInstance) instance = currentInstance;
|
||||||
|
if (!instance) log('instance not registred');
|
||||||
let totalSizeFromManifest = 0;
|
let totalSizeFromManifest = 0;
|
||||||
let totalSizeWeights = 0;
|
let totalSizeWeights = 0;
|
||||||
let totalSizeLoading = 0;
|
let totalSizeLoading = 0;
|
||||||
|
@ -96,13 +101,16 @@ export const getModelStats = (instance: Human): ModelStats => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function reset(instance: Human): void {
|
export function reset(currentInstance: Human): void {
|
||||||
|
if (currentInstance) instance = currentInstance;
|
||||||
// if (instance.config.debug) log('resetting loaded models');
|
// if (instance.config.debug) log('resetting loaded models');
|
||||||
for (const model of Object.keys(instance.models)) instance.models[model as keyof Models] = null;
|
for (const model of Object.keys(instance.models)) instance.models[model as keyof Models] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load method preloads all instance.configured models on-demand */
|
/** Load method preloads all instance.configured models on-demand */
|
||||||
export async function load(instance: Human): Promise<void> {
|
export async function load(currentInstance: Human): Promise<void> {
|
||||||
|
if (currentInstance) instance = currentInstance;
|
||||||
|
if (!instance) log('instance not registred');
|
||||||
if (env.initial) reset(instance);
|
if (env.initial) reset(instance);
|
||||||
if (instance.config.hand.enabled) { // handpose model is a combo that must be loaded as a whole
|
if (instance.config.hand.enabled) { // handpose model is a combo that must be loaded as a whole
|
||||||
if (!instance.models.handpose && instance.config.hand.detector?.modelPath?.includes('handdetect')) {
|
if (!instance.models.handpose && instance.config.hand.detector?.modelPath?.includes('handdetect')) {
|
||||||
|
@ -143,14 +151,13 @@ export async function load(instance: Human): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let instance: Human;
|
|
||||||
export interface KernelOps { name: string, url: string, missing: string[], ops: string[] }
|
export interface KernelOps { name: string, url: string, missing: string[], ops: string[] }
|
||||||
|
|
||||||
export function validateModel(newInstance: Human | null, model: GraphModel | null, name: string): KernelOps | null {
|
export function validateModel(currentInstance: Human | null, model: GraphModel | null, name: string): KernelOps | null {
|
||||||
if (newInstance) instance = newInstance;
|
|
||||||
if (!model) return null;
|
if (!model) return null;
|
||||||
|
if (currentInstance) instance = currentInstance;
|
||||||
if (!instance) log('instance not registred');
|
if (!instance) log('instance not registred');
|
||||||
if (!instance.config.validateModels) return null;
|
if (!instance?.config?.validateModels) return null;
|
||||||
const simpleOps = ['const', 'placeholder', 'noop', 'pad', 'squeeze', 'add', 'sub', 'mul', 'div'];
|
const simpleOps = ['const', 'placeholder', 'noop', 'pad', 'squeeze', 'add', 'sub', 'mul', 'div'];
|
||||||
const ignoreOps = ['biasadd', 'fusedbatchnormv3', 'matmul'];
|
const ignoreOps = ['biasadd', 'fusedbatchnormv3', 'matmul'];
|
||||||
const ops: string[] = [];
|
const ops: string[] = [];
|
||||||
|
@ -182,13 +189,14 @@ export function validateModel(newInstance: Human | null, model: GraphModel | nul
|
||||||
return missing.length > 0 ? { name, missing, ops, url } : null;
|
return missing.length > 0 ? { name, missing, ops, url } : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validate(newInstance: Human): { name: string, missing: string[] }[] {
|
export function validate(currentInstance: Human): { name: string, missing: string[] }[] {
|
||||||
instance = newInstance;
|
if (currentInstance) instance = currentInstance;
|
||||||
|
if (!instance) log('instance not registred');
|
||||||
const missing: KernelOps[] = [];
|
const missing: KernelOps[] = [];
|
||||||
for (const defined of Object.keys(instance.models)) {
|
for (const defined of Object.keys(currentInstance.models)) {
|
||||||
const model: GraphModel | null = instance.models[defined as keyof Models] as GraphModel | null;
|
const model: GraphModel | null = currentInstance.models[defined as keyof Models] as GraphModel | null;
|
||||||
if (!model) continue;
|
if (!model) continue;
|
||||||
const res = validateModel(instance, model, defined);
|
const res = validateModel(currentInstance, model, defined);
|
||||||
if (res) missing.push(res);
|
if (res) missing.push(res);
|
||||||
}
|
}
|
||||||
return missing;
|
return missing;
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
2022-09-29 21:25:14 [32mDATA: [39m Build {"name":"@vladmandic/human","version":"2.11.0"}
|
2022-09-30 10:10:34 [32mDATA: [39m Build {"name":"@vladmandic/human","version":"2.11.0"}
|
||||||
2022-09-29 21:25:14 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.11.0"}
|
2022-09-30 10:10:34 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.11.0"}
|
||||||
2022-09-29 21:25:14 [36mINFO: [39m Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
|
2022-09-30 10:10:34 [36mINFO: [39m Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||||
2022-09-29 21:25:14 [36mINFO: [39m Toolchain: {"build":"0.7.14","esbuild":"0.15.10","typescript":"4.8.4","typedoc":"0.23.15","eslint":"8.24.0"}
|
2022-09-30 10:10:34 [36mINFO: [39m Toolchain: {"build":"0.7.14","esbuild":"0.15.10","typescript":"4.8.4","typedoc":"0.23.15","eslint":"8.24.0"}
|
||||||
2022-09-29 21:25:14 [36mINFO: [39m Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
|
2022-09-30 10:10:34 [36mINFO: [39m Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
|
2022-09-30 10:10:34 [35mSTATE:[39m Clean: {"locations":["dist/*","types/lib/*","typedoc/*"]}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m 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-30 10:10:34 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":76,"inputBytes":665091,"outputBytes":312560}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":76,"inputBytes":665243,"outputBytes":312739}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m 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-30 10:10:35 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":76,"inputBytes":665095,"outputBytes":312564}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":76,"inputBytes":665247,"outputBytes":312743}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m 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-30 10:10:35 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":76,"inputBytes":665147,"outputBytes":312614}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":76,"inputBytes":665299,"outputBytes":312793}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m 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-30 10:10:35 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m 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-30 10:10:35 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":76,"inputBytes":665066,"outputBytes":311419}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":76,"inputBytes":665218,"outputBytes":311543}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m 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-30 10:10:35 [35mSTATE:[39m 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-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":76,"inputBytes":3486397,"outputBytes":1691568}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":76,"inputBytes":3486549,"outputBytes":1691871}
|
||||||
2022-09-29 21:25:14 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":76,"inputBytes":3486397,"outputBytes":3115662}
|
2022-09-30 10:10:35 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":76,"inputBytes":3486549,"outputBytes":3116005}
|
||||||
2022-09-29 21:25:19 [35mSTATE:[39m Typings: {"input":"src/human.ts","output":"types/lib","files":15}
|
2022-09-30 10:10:39 [35mSTATE:[39m Typings: {"input":"src/human.ts","output":"types/lib","files":15}
|
||||||
2022-09-29 21:25:21 [35mSTATE:[39m TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":79,"generated":true}
|
2022-09-30 10:10:41 [35mSTATE:[39m TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":75,"generated":true}
|
||||||
2022-09-29 21:25:21 [35mSTATE:[39m Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":5850,"outputBytes":2632}
|
2022-09-30 10:10:41 [35mSTATE:[39m Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":5841,"outputBytes":2632}
|
||||||
2022-09-29 21:25:21 [35mSTATE:[39m Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17155,"outputBytes":9175}
|
2022-09-30 10:10:41 [35mSTATE:[39m Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17155,"outputBytes":9175}
|
||||||
2022-09-29 21:25:31 [35mSTATE:[39m Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":111,"errors":0,"warnings":0}
|
2022-09-30 10:10:52 [35mSTATE:[39m Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":111,"errors":0,"warnings":0}
|
||||||
2022-09-29 21:25:31 [35mSTATE:[39m ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
|
2022-09-30 10:10:52 [35mSTATE:[39m ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
|
||||||
2022-09-29 21:25:31 [35mSTATE:[39m Copy: {"input":"tfjs/tfjs.esm.d.ts"}
|
2022-09-30 10:10:52 [35mSTATE:[39m Copy: {"input":"tfjs/tfjs.esm.d.ts"}
|
||||||
2022-09-29 21:25:31 [36mINFO: [39m Done...
|
2022-09-30 10:10:52 [36mINFO: [39m Done...
|
||||||
2022-09-29 21:25:32 [32mDATA: [39m API {"level":"warning","category":"Extractor","id":"ae-forgotten-export","file":"/home/vlado/dev/human/types/lib/src/human.d.ts","line":170,"text":"The symbol \"webcam\" needs to be exported by the entry point human.d.ts"}
|
2022-09-30 10:10:53 [35mSTATE:[39m API-Extractor: {"succeeeded":true,"errors":0,"warnings":193}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m API-Extractor: {"succeeeded":true,"errors":0,"warnings":194}
|
2022-09-30 10:10:53 [35mSTATE:[39m Filter: {"input":"types/human.d.ts"}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Copy: {"input":"types/human.d.ts"}
|
2022-09-30 10:10:53 [35mSTATE:[39m Link: {"input":"types/human.d.ts"}
|
||||||
2022-09-29 21:25:32 [36mINFO: [39m Analyze models: {"folders":8,"result":"models/models.json"}
|
2022-09-30 10:10:53 [36mINFO: [39m Analyze models: {"folders":8,"result":"models/models.json"}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"./models","models":13}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"./models","models":13}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../human-models/models","models":42}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../human-models/models","models":42}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../blazepose/model/","models":4}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../blazepose/model/","models":4}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../anti-spoofing/model","models":1}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../anti-spoofing/model","models":1}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../efficientpose/models","models":3}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../efficientpose/models","models":3}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../insightface/models","models":5}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../insightface/models","models":5}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../movenet/models","models":3}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../movenet/models","models":3}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models {"folder":"../nanodet/models","models":4}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models {"folder":"../nanodet/models","models":4}
|
||||||
2022-09-29 21:25:32 [35mSTATE:[39m Models: {"count":57,"totalSize":383017442}
|
2022-09-30 10:10:53 [35mSTATE:[39m Models: {"count":57,"totalSize":383017442}
|
||||||
2022-09-29 21:25:32 [36mINFO: [39m Human Build complete... {"logFile":"test/build.log"}
|
2022-09-30 10:10:53 [36mINFO: [39m Human Build complete... {"logFile":"test/build.log"}
|
||||||
|
|
2003
test/test.log
2003
test/test.log
File diff suppressed because it is too large
Load Diff
|
@ -51,7 +51,7 @@
|
||||||
"indentSize": 2,
|
"indentSize": 2,
|
||||||
"tabSize": 2
|
"tabSize": 2
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules/", "types/", "dist/"],
|
"exclude": ["node_modules/", "types/", "dist/**/*.js"],
|
||||||
"include": ["src", "tfjs/*.ts", "types/human.d.ts", "test/**/*.ts", "demo/**/*.ts"],
|
"include": ["src", "tfjs/*.ts", "types/human.d.ts", "test/**/*.ts", "demo/**/*.ts"],
|
||||||
"typedocOptions": {
|
"typedocOptions": {
|
||||||
"externalPattern": ["node_modules/", "tfjs/"]
|
"externalPattern": ["node_modules/", "tfjs/"]
|
||||||
|
|
Loading…
Reference in New Issue