mirror of https://github.com/vladmandic/human
added human.env diagnostic class
parent
1bd394e303
commit
116424f81b
|
@ -13,16 +13,23 @@ assignees: vladmandic
|
||||||
|
|
||||||
**Expected Behavior**
|
**Expected Behavior**
|
||||||
|
|
||||||
**Environment
|
**Environment**
|
||||||
|
|
||||||
- Module version?
|
- Human library version?
|
||||||
- Built-in demo or custom code?
|
- Built-in demo or custom code?
|
||||||
- Type of module used (e.g. `js`, `esm`, `esm-nobundle`)?
|
- Type of module used (e.g. `js`, `esm`, `esm-nobundle`)?
|
||||||
- Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)?
|
- TensorFlow/JS version (if not using bundled module)?
|
||||||
- OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)?
|
- Browser or NodeJS and version (e.g. *NodeJS 14.15* or *Chrome 89*)?
|
||||||
- Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)?
|
- OS and Hardware platform (e.g. *Windows 10*, *Ubuntu Linux on x64*, *Android 10*)?
|
||||||
|
- Packager (if any) (e.g, *webpack*, *rollup*, *parcel*, *esbuild*, etc.)?
|
||||||
|
- Framework (if any) (e.g. *React*, *NextJS*, etc.)?
|
||||||
|
|
||||||
|
**Diagnostics**
|
||||||
|
|
||||||
|
- Check out any applicable [diagnostic steps](https://github.com/vladmandic/human/wiki/Diag)
|
||||||
|
|
||||||
**Additional**
|
**Additional**
|
||||||
|
|
||||||
- For installation or startup issues include your `package.json`
|
- For installation or startup issues include your `package.json`
|
||||||
- For usage issues, it is recommended to post your code as [gist](https://gist.github.com/)
|
- For usage issues, it is recommended to post your code as [gist](https://gist.github.com/)
|
||||||
|
- For general questions, create a [discussion topic](https://github.com/vladmandic/human/discussions)
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
### **HEAD -> main** 2021/09/12 mandic00@live.com
|
### **HEAD -> main** 2021/09/12 mandic00@live.com
|
||||||
|
|
||||||
|
- release candidate
|
||||||
|
- parametrize face config
|
||||||
- mark all config items as optional
|
- mark all config items as optional
|
||||||
- redefine config and result interfaces
|
- redefine config and result interfaces
|
||||||
- fix usge of string enums
|
- fix usge of string enums
|
||||||
|
|
|
@ -72,6 +72,7 @@ Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) ap
|
||||||
- [**Performance Notes**](https://github.com/vladmandic/human/wiki/Performance)
|
- [**Performance Notes**](https://github.com/vladmandic/human/wiki/Performance)
|
||||||
- [**Performance Profiling**](https://github.com/vladmandic/human/wiki/Profiling)
|
- [**Performance Profiling**](https://github.com/vladmandic/human/wiki/Profiling)
|
||||||
- [**Platform Support**](https://github.com/vladmandic/human/wiki/Platforms)
|
- [**Platform Support**](https://github.com/vladmandic/human/wiki/Platforms)
|
||||||
|
- [**Diagnostic and Performance trace information**](https://github.com/vladmandic/human/wiki/Diag)
|
||||||
- [**List of Models & Credits**](https://github.com/vladmandic/human/wiki/Models)
|
- [**List of Models & Credits**](https://github.com/vladmandic/human/wiki/Models)
|
||||||
- [**Security & Privacy Policy**](https://github.com/vladmandic/human/blob/main/SECURITY.md)
|
- [**Security & Privacy Policy**](https://github.com/vladmandic/human/blob/main/SECURITY.md)
|
||||||
- [**License & Usage Restrictions**](https://github.com/vladmandic/human/blob/main/LICENSE)
|
- [**License & Usage Restrictions**](https://github.com/vladmandic/human/blob/main/LICENSE)
|
||||||
|
@ -309,6 +310,12 @@ For more info, see [**Configuration Details**](https://github.com/vladmandic/hum
|
||||||
|
|
||||||
<br><hr><br>
|
<br><hr><br>
|
||||||
|
|
||||||
|
## Diagnostics
|
||||||
|
|
||||||
|
- [How to get diagnostic information or performance trace information](https://github.com/vladmandic/human/wiki/Diag)
|
||||||
|
|
||||||
|
<br><hr><br>
|
||||||
|
|
||||||
`Human` library is written in `TypeScript` [4.3](https://www.typescriptlang.org/docs/handbook/intro.html)
|
`Human` library is written in `TypeScript` [4.3](https://www.typescriptlang.org/docs/handbook/intro.html)
|
||||||
Conforming to `JavaScript` [ECMAScript version 2020](https://www.ecma-international.org/ecma-262/11.0/index.html) standard
|
Conforming to `JavaScript` [ECMAScript version 2020](https://www.ecma-international.org/ecma-262/11.0/index.html) standard
|
||||||
Build target is `JavaScript` [EMCAScript version 2018](https://262.ecma-international.org/9.0/)
|
Build target is `JavaScript` [EMCAScript version 2018](https://262.ecma-international.org/9.0/)
|
||||||
|
|
|
@ -953,8 +953,7 @@ async function main() {
|
||||||
|
|
||||||
// create instance of human
|
// create instance of human
|
||||||
human = new Human(userConfig);
|
human = new Human(userConfig);
|
||||||
log('human version:', Human.version);
|
log('human version:', human.version);
|
||||||
log('tfjs version:', human.tf.version.tfjs);
|
|
||||||
userConfig = { ...human.config, ...userConfig };
|
userConfig = { ...human.config, ...userConfig };
|
||||||
if (typeof tf !== 'undefined') {
|
if (typeof tf !== 'undefined') {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
|
@ -962,6 +961,7 @@ async function main() {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
human.tf = tf; // use externally loaded version of tfjs
|
human.tf = tf; // use externally loaded version of tfjs
|
||||||
}
|
}
|
||||||
|
log('tfjs version:', human.tf.version.tfjs);
|
||||||
|
|
||||||
// setup main menu
|
// setup main menu
|
||||||
await setupMenu();
|
await setupMenu();
|
||||||
|
@ -1013,6 +1013,8 @@ async function main() {
|
||||||
log('overriding images list:', JSON.parse(params.get('images')));
|
log('overriding images list:', JSON.parse(params.get('images')));
|
||||||
await detectSampleImages();
|
await detectSampleImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (human.config.debug) log('environment:', human.env);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = main;
|
window.onload = main;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
const log = require('@vladmandic/pilogger');
|
||||||
|
const Human = require('../../dist/human.node.js').default; // or const Human = require('../dist/human.node-gpu.js').default;
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
debug: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const human = new Human(config);
|
||||||
|
await human.tf.ready();
|
||||||
|
log.info('Human:', human.version);
|
||||||
|
log.data('Environment', human.env);
|
||||||
|
await human.load();
|
||||||
|
const models = Object.keys(human.models).map((model) => ({ name: model, loaded: (human.models[model] !== null) }));
|
||||||
|
log.data('Models:', models);
|
||||||
|
log.info('Memory state:', human.tf.engine().memory());
|
||||||
|
// log.data('Config', human.config);
|
||||||
|
log.info('TFJS flags:', human.tf.ENV.flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
|
@ -83,8 +83,8 @@ function mergeDeep(...objects) {
|
||||||
|
|
||||||
// src/config.ts
|
// src/config.ts
|
||||||
var config = {
|
var config = {
|
||||||
backend: "humangl",
|
backend: "",
|
||||||
modelBasePath: "../models/",
|
modelBasePath: "",
|
||||||
wasmPath: "",
|
wasmPath: "",
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -182,27 +182,6 @@ var config = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/sysinfo.ts
|
|
||||||
function info() {
|
|
||||||
let platform = "";
|
|
||||||
let agent = "";
|
|
||||||
if (typeof navigator !== "undefined") {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
|
||||||
agent = navigator.userAgent.replace(raw[0], "");
|
|
||||||
if (platform[1])
|
|
||||||
agent = agent.replace(raw[1], "");
|
|
||||||
agent = agent.replace(/ /g, " ");
|
|
||||||
}
|
|
||||||
} else if (typeof process !== "undefined") {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
||||||
|
|
||||||
// dist/tfjs.esm.js
|
// dist/tfjs.esm.js
|
||||||
var tfjs_esm_exports = {};
|
var tfjs_esm_exports = {};
|
||||||
__export(tfjs_esm_exports, {
|
__export(tfjs_esm_exports, {
|
||||||
|
@ -11732,6 +11711,74 @@ SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
||||||
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
||||||
2Q==`;
|
2Q==`;
|
||||||
|
|
||||||
|
// src/env.ts
|
||||||
|
var env2 = {
|
||||||
|
browser: void 0,
|
||||||
|
node: void 0,
|
||||||
|
worker: void 0,
|
||||||
|
platform: void 0,
|
||||||
|
agent: void 0,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: void 0,
|
||||||
|
external: void 0
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: void 0,
|
||||||
|
simd: void 0,
|
||||||
|
multithread: void 0
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: void 0,
|
||||||
|
version: void 0,
|
||||||
|
renderer: void 0
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: void 0,
|
||||||
|
adapter: void 0
|
||||||
|
},
|
||||||
|
kernels: []
|
||||||
|
};
|
||||||
|
async function get() {
|
||||||
|
var _a;
|
||||||
|
env2.browser = typeof navigator !== "undefined";
|
||||||
|
env2.node = typeof process !== "undefined";
|
||||||
|
env2.worker = env2.browser ? typeof WorkerGlobalScope !== "undefined" : void 0;
|
||||||
|
env2.tfjs.version = tfjs_esm_exports.version_core;
|
||||||
|
if (typeof navigator !== "undefined") {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env2.platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
||||||
|
env2.agent = navigator.userAgent.replace(raw[0], "");
|
||||||
|
if (env2.platform[1])
|
||||||
|
env2.agent = env2.agent.replace(raw[1], "");
|
||||||
|
env2.agent = env2.agent.replace(/ /g, " ");
|
||||||
|
}
|
||||||
|
} else if (typeof process !== "undefined") {
|
||||||
|
env2.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env2.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
env2.backends = Object.keys(tfjs_esm_exports.engine().registryFactory);
|
||||||
|
env2.wasm.supported = env2.backends.includes("wasm");
|
||||||
|
if (env2.wasm.supported) {
|
||||||
|
env2.wasm.simd = await tfjs_esm_exports.env().getAsync("WASM_HAS_SIMD_SUPPORT");
|
||||||
|
env2.wasm.multithread = await tfjs_esm_exports.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
|
||||||
|
}
|
||||||
|
env2.webgl.supported = typeof tfjs_esm_exports.backend().gpgpu !== "undefined";
|
||||||
|
if (env2.webgl.supported) {
|
||||||
|
const gl = await tfjs_esm_exports.backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env2.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env2.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env2.webgpu.supported = env2.browser && typeof navigator["gpu"] !== "undefined";
|
||||||
|
if (env2.webgpu.supported)
|
||||||
|
env2.webgpu.adapter = (_a = await navigator["gpu"].requestAdapter()) == null ? void 0 : _a.name;
|
||||||
|
env2.kernels = tfjs_esm_exports.getKernelsForBackend(tfjs_esm_exports.getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
}
|
||||||
|
|
||||||
// package.json
|
// package.json
|
||||||
var version2 = "2.2.0";
|
var version2 = "2.2.0";
|
||||||
|
|
||||||
|
@ -11773,9 +11820,9 @@ var Human = class {
|
||||||
var _a;
|
var _a;
|
||||||
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
||||||
});
|
});
|
||||||
__privateAdd(this, _checkBackend, async (force = false) => {
|
__privateAdd(this, _checkBackend, async () => {
|
||||||
var _a;
|
var _a;
|
||||||
if (this.config.backend && this.config.backend.length > 0 && force || this.tf.getBackend() !== this.config.backend) {
|
if (__privateGet(this, _firstRun) || (this.config.backend && this.config.backend.length > 0 || this.tf.getBackend() !== this.config.backend)) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = "backend";
|
this.state = "backend";
|
||||||
if (this.config.backend && this.config.backend.length > 0) {
|
if (this.config.backend && this.config.backend.length > 0) {
|
||||||
|
@ -11787,7 +11834,7 @@ var Human = class {
|
||||||
this.config.backend = "humangl";
|
this.config.backend = "humangl";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
||||||
log("override: backend set to webgl while running in nodejs");
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = "tensorflow";
|
this.config.backend = "tensorflow";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
||||||
|
@ -11848,6 +11895,8 @@ var Human = class {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.next = (result) => calc(result || this.result);
|
this.next = (result) => calc(result || this.result);
|
||||||
|
@ -11943,9 +11992,13 @@ var Human = class {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
|
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tfjs_esm_exports.version_core}/dist/`;
|
||||||
|
config.modelBasePath = this.env.browser ? "../models/" : "file://models/";
|
||||||
|
config.backend = this.env.browser ? "humangl" : "tensorflow";
|
||||||
this.version = version2;
|
this.version = version2;
|
||||||
Object.defineProperty(this, "version", { value: version2 });
|
Object.defineProperty(this, "version", { value: version2 });
|
||||||
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tfjs_esm_exports.version_core}/dist/`;
|
|
||||||
this.config = mergeDeep(config, userConfig || {});
|
this.config = mergeDeep(config, userConfig || {});
|
||||||
this.tf = tfjs_esm_exports;
|
this.tf = tfjs_esm_exports;
|
||||||
this.draw = draw_exports;
|
this.draw = draw_exports;
|
||||||
|
@ -11978,7 +12031,6 @@ var Human = class {
|
||||||
this.process = { tensor: null, canvas: null };
|
this.process = { tensor: null, canvas: null };
|
||||||
this.faceTriangulation = triangulation;
|
this.faceTriangulation = triangulation;
|
||||||
this.faceUVMap = uvmap;
|
this.faceUVMap = uvmap;
|
||||||
this.sysinfo = info();
|
|
||||||
__privateSet(this, _lastInputSum, 1);
|
__privateSet(this, _lastInputSum, 1);
|
||||||
__privateGet(this, _emit).call(this, "create");
|
__privateGet(this, _emit).call(this, "create");
|
||||||
}
|
}
|
||||||
|
@ -12006,10 +12058,8 @@ var Human = class {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log(`tfjs version: ${this.tf.version_core}`);
|
log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("platform:", this.sysinfo.platform);
|
log("environment:", env2);
|
||||||
if (this.config.debug)
|
await __privateGet(this, _checkBackend).call(this);
|
||||||
log("agent:", this.sysinfo.agent);
|
|
||||||
await __privateGet(this, _checkBackend).call(this, true);
|
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("configuration:", this.config);
|
log("configuration:", this.config);
|
||||||
|
@ -12227,6 +12277,7 @@ _warmupNode = new WeakMap();
|
||||||
export {
|
export {
|
||||||
Human,
|
Human,
|
||||||
Human as default,
|
Human as default,
|
||||||
config as defaults
|
config as defaults,
|
||||||
|
env2 as env
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=human.esm-nobundle.js.map
|
//# sourceMappingURL=human.esm-nobundle.js.map
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -72,8 +72,8 @@ function mergeDeep(...objects) {
|
||||||
|
|
||||||
// src/config.ts
|
// src/config.ts
|
||||||
var config = {
|
var config = {
|
||||||
backend: "humangl",
|
backend: "",
|
||||||
modelBasePath: "../models/",
|
modelBasePath: "",
|
||||||
wasmPath: "",
|
wasmPath: "",
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -171,27 +171,6 @@ var config = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/sysinfo.ts
|
|
||||||
function info() {
|
|
||||||
let platform = "";
|
|
||||||
let agent = "";
|
|
||||||
if (typeof navigator !== "undefined") {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
|
||||||
agent = navigator.userAgent.replace(raw[0], "");
|
|
||||||
if (platform[1])
|
|
||||||
agent = agent.replace(raw[1], "");
|
|
||||||
agent = agent.replace(/ /g, " ");
|
|
||||||
}
|
|
||||||
} else if (typeof process !== "undefined") {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
||||||
|
|
||||||
// dist/tfjs.esm.js
|
// dist/tfjs.esm.js
|
||||||
var tfjs_esm_exports = {};
|
var tfjs_esm_exports = {};
|
||||||
__export(tfjs_esm_exports, {
|
__export(tfjs_esm_exports, {
|
||||||
|
@ -3446,7 +3425,7 @@ var require_tfjs_backend_wasm_threaded_simd = __commonJS({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createWasm() {
|
function createWasm() {
|
||||||
var info2 = { "a": asmLibraryArg };
|
var info = { "a": asmLibraryArg };
|
||||||
function receiveInstance(instance, module2) {
|
function receiveInstance(instance, module2) {
|
||||||
var exports3 = instance.exports;
|
var exports3 = instance.exports;
|
||||||
Module["asm"] = exports3;
|
Module["asm"] = exports3;
|
||||||
|
@ -3470,7 +3449,7 @@ var require_tfjs_backend_wasm_threaded_simd = __commonJS({
|
||||||
}
|
}
|
||||||
function instantiateArrayBuffer(receiver) {
|
function instantiateArrayBuffer(receiver) {
|
||||||
return getBinaryPromise().then(function(binary) {
|
return getBinaryPromise().then(function(binary) {
|
||||||
return WebAssembly.instantiate(binary, info2);
|
return WebAssembly.instantiate(binary, info);
|
||||||
}).then(receiver, function(reason) {
|
}).then(receiver, function(reason) {
|
||||||
err("failed to asynchronously prepare wasm: " + reason);
|
err("failed to asynchronously prepare wasm: " + reason);
|
||||||
abort(reason);
|
abort(reason);
|
||||||
|
@ -3479,7 +3458,7 @@ var require_tfjs_backend_wasm_threaded_simd = __commonJS({
|
||||||
function instantiateAsync() {
|
function instantiateAsync() {
|
||||||
if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") {
|
if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") {
|
||||||
return fetch(wasmBinaryFile, { credentials: "same-origin" }).then(function(response) {
|
return fetch(wasmBinaryFile, { credentials: "same-origin" }).then(function(response) {
|
||||||
var result = WebAssembly.instantiateStreaming(response, info2);
|
var result = WebAssembly.instantiateStreaming(response, info);
|
||||||
return result.then(receiveInstantiatedSource, function(reason) {
|
return result.then(receiveInstantiatedSource, function(reason) {
|
||||||
err("wasm streaming compile failed: " + reason);
|
err("wasm streaming compile failed: " + reason);
|
||||||
err("falling back to ArrayBuffer instantiation");
|
err("falling back to ArrayBuffer instantiation");
|
||||||
|
@ -3492,7 +3471,7 @@ var require_tfjs_backend_wasm_threaded_simd = __commonJS({
|
||||||
}
|
}
|
||||||
if (Module["instantiateWasm"]) {
|
if (Module["instantiateWasm"]) {
|
||||||
try {
|
try {
|
||||||
var exports2 = Module["instantiateWasm"](info2, receiveInstance);
|
var exports2 = Module["instantiateWasm"](info, receiveInstance);
|
||||||
return exports2;
|
return exports2;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
err("Module.instantiateWasm callback failed with error: " + e);
|
err("Module.instantiateWasm callback failed with error: " + e);
|
||||||
|
@ -5536,7 +5515,7 @@ var require_tfjs_backend_wasm = __commonJS({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createWasm() {
|
function createWasm() {
|
||||||
var info2 = { "a": asmLibraryArg };
|
var info = { "a": asmLibraryArg };
|
||||||
function receiveInstance(instance, module2) {
|
function receiveInstance(instance, module2) {
|
||||||
var exports3 = instance.exports;
|
var exports3 = instance.exports;
|
||||||
Module["asm"] = exports3;
|
Module["asm"] = exports3;
|
||||||
|
@ -5551,7 +5530,7 @@ var require_tfjs_backend_wasm = __commonJS({
|
||||||
}
|
}
|
||||||
function instantiateArrayBuffer(receiver) {
|
function instantiateArrayBuffer(receiver) {
|
||||||
return getBinaryPromise().then(function(binary) {
|
return getBinaryPromise().then(function(binary) {
|
||||||
return WebAssembly.instantiate(binary, info2);
|
return WebAssembly.instantiate(binary, info);
|
||||||
}).then(receiver, function(reason) {
|
}).then(receiver, function(reason) {
|
||||||
err("failed to asynchronously prepare wasm: " + reason);
|
err("failed to asynchronously prepare wasm: " + reason);
|
||||||
abort(reason);
|
abort(reason);
|
||||||
|
@ -5560,7 +5539,7 @@ var require_tfjs_backend_wasm = __commonJS({
|
||||||
function instantiateAsync() {
|
function instantiateAsync() {
|
||||||
if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") {
|
if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") {
|
||||||
return fetch(wasmBinaryFile, { credentials: "same-origin" }).then(function(response) {
|
return fetch(wasmBinaryFile, { credentials: "same-origin" }).then(function(response) {
|
||||||
var result = WebAssembly.instantiateStreaming(response, info2);
|
var result = WebAssembly.instantiateStreaming(response, info);
|
||||||
return result.then(receiveInstantiatedSource, function(reason) {
|
return result.then(receiveInstantiatedSource, function(reason) {
|
||||||
err("wasm streaming compile failed: " + reason);
|
err("wasm streaming compile failed: " + reason);
|
||||||
err("falling back to ArrayBuffer instantiation");
|
err("falling back to ArrayBuffer instantiation");
|
||||||
|
@ -5573,7 +5552,7 @@ var require_tfjs_backend_wasm = __commonJS({
|
||||||
}
|
}
|
||||||
if (Module["instantiateWasm"]) {
|
if (Module["instantiateWasm"]) {
|
||||||
try {
|
try {
|
||||||
var exports2 = Module["instantiateWasm"](info2, receiveInstance);
|
var exports2 = Module["instantiateWasm"](info, receiveInstance);
|
||||||
return exports2;
|
return exports2;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
err("Module.instantiateWasm callback failed with error: " + e);
|
err("Module.instantiateWasm callback failed with error: " + e);
|
||||||
|
@ -8203,13 +8182,13 @@ var Engine = class {
|
||||||
throw new Error(`Could not initialize any backends, all backend initializations failed.`);
|
throw new Error(`Could not initialize any backends, all backend initializations failed.`);
|
||||||
}
|
}
|
||||||
moveData(backend22, dataId) {
|
moveData(backend22, dataId) {
|
||||||
const info2 = this.state.tensorInfo.get(dataId);
|
const info = this.state.tensorInfo.get(dataId);
|
||||||
const srcBackend = info2.backend;
|
const srcBackend = info.backend;
|
||||||
const values = this.readSync(dataId);
|
const values = this.readSync(dataId);
|
||||||
const refCount = srcBackend.refCount(dataId);
|
const refCount = srcBackend.refCount(dataId);
|
||||||
srcBackend.disposeData(dataId, true);
|
srcBackend.disposeData(dataId, true);
|
||||||
info2.backend = backend22;
|
info.backend = backend22;
|
||||||
backend22.move(dataId, values, info2.shape, info2.dtype, refCount);
|
backend22.move(dataId, values, info.shape, info.dtype, refCount);
|
||||||
if (this.shouldCheckForMemLeaks()) {
|
if (this.shouldCheckForMemLeaks()) {
|
||||||
this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
|
this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
|
||||||
}
|
}
|
||||||
|
@ -8287,8 +8266,8 @@ var Engine = class {
|
||||||
checkKernelForMemLeak(kernelName, numDataIdsBefore, outInfos) {
|
checkKernelForMemLeak(kernelName, numDataIdsBefore, outInfos) {
|
||||||
const numDataIdsAfter = this.backend.numDataIds();
|
const numDataIdsAfter = this.backend.numDataIds();
|
||||||
let numOutputDataIds = 0;
|
let numOutputDataIds = 0;
|
||||||
outInfos.forEach((info2) => {
|
outInfos.forEach((info) => {
|
||||||
numOutputDataIds += info2.dtype === "complex64" ? 3 : 1;
|
numOutputDataIds += info.dtype === "complex64" ? 3 : 1;
|
||||||
});
|
});
|
||||||
const numMoves = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1];
|
const numMoves = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1];
|
||||||
const dataIdsLeaked = numDataIdsAfter - numDataIdsBefore - numOutputDataIds - numMoves;
|
const dataIdsLeaked = numDataIdsAfter - numDataIdsBefore - numOutputDataIds - numMoves;
|
||||||
|
@ -8423,10 +8402,10 @@ var Engine = class {
|
||||||
const t = new Tensor(shape, dtype, dataId, this.nextTensorId());
|
const t = new Tensor(shape, dtype, dataId, this.nextTensorId());
|
||||||
this.trackTensor(t, backend22);
|
this.trackTensor(t, backend22);
|
||||||
if (dtype === "string") {
|
if (dtype === "string") {
|
||||||
const info2 = this.state.tensorInfo.get(dataId);
|
const info = this.state.tensorInfo.get(dataId);
|
||||||
const newBytes = bytesFromStringArray(backendVals);
|
const newBytes = bytesFromStringArray(backendVals);
|
||||||
this.state.numBytes += newBytes - info2.bytes;
|
this.state.numBytes += newBytes - info.bytes;
|
||||||
info2.bytes = newBytes;
|
info.bytes = newBytes;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -8486,18 +8465,18 @@ var Engine = class {
|
||||||
if (!this.state.tensorInfo.has(a.dataId)) {
|
if (!this.state.tensorInfo.has(a.dataId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const info2 = this.state.tensorInfo.get(a.dataId);
|
const info = this.state.tensorInfo.get(a.dataId);
|
||||||
this.state.numTensors--;
|
this.state.numTensors--;
|
||||||
if (a.dtype === "string") {
|
if (a.dtype === "string") {
|
||||||
this.state.numStringTensors--;
|
this.state.numStringTensors--;
|
||||||
this.state.numBytes -= info2.bytes;
|
this.state.numBytes -= info.bytes;
|
||||||
}
|
}
|
||||||
if (a.dtype !== "complex64" && a.dtype !== "string") {
|
if (a.dtype !== "complex64" && a.dtype !== "string") {
|
||||||
const bytes = a.size * bytesPerElement(a.dtype);
|
const bytes = a.size * bytesPerElement(a.dtype);
|
||||||
this.state.numBytes -= bytes;
|
this.state.numBytes -= bytes;
|
||||||
}
|
}
|
||||||
if (info2.backend.disposeData(a.dataId)) {
|
if (info.backend.disposeData(a.dataId)) {
|
||||||
this.removeDataId(a.dataId, info2.backend);
|
this.removeDataId(a.dataId, info.backend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disposeVariables() {
|
disposeVariables() {
|
||||||
|
@ -8513,18 +8492,18 @@ var Engine = class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memory() {
|
memory() {
|
||||||
const info2 = this.backend.memory();
|
const info = this.backend.memory();
|
||||||
info2.numTensors = this.state.numTensors;
|
info.numTensors = this.state.numTensors;
|
||||||
info2.numDataBuffers = this.state.numDataBuffers;
|
info.numDataBuffers = this.state.numDataBuffers;
|
||||||
info2.numBytes = this.state.numBytes;
|
info.numBytes = this.state.numBytes;
|
||||||
if (this.state.numStringTensors > 0) {
|
if (this.state.numStringTensors > 0) {
|
||||||
info2.unreliable = true;
|
info.unreliable = true;
|
||||||
if (info2.reasons == null) {
|
if (info.reasons == null) {
|
||||||
info2.reasons = [];
|
info.reasons = [];
|
||||||
}
|
}
|
||||||
info2.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)");
|
info.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)");
|
||||||
}
|
}
|
||||||
return info2;
|
return info;
|
||||||
}
|
}
|
||||||
async profile(query) {
|
async profile(query) {
|
||||||
this.state.profiling = true;
|
this.state.profiling = true;
|
||||||
|
@ -8669,12 +8648,12 @@ var Engine = class {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
readSync(dataId) {
|
readSync(dataId) {
|
||||||
const info2 = this.state.tensorInfo.get(dataId);
|
const info = this.state.tensorInfo.get(dataId);
|
||||||
return info2.backend.readSync(dataId);
|
return info.backend.readSync(dataId);
|
||||||
}
|
}
|
||||||
read(dataId) {
|
read(dataId) {
|
||||||
const info2 = this.state.tensorInfo.get(dataId);
|
const info = this.state.tensorInfo.get(dataId);
|
||||||
return info2.backend.read(dataId);
|
return info.backend.read(dataId);
|
||||||
}
|
}
|
||||||
async time(query) {
|
async time(query) {
|
||||||
const start = now2();
|
const start = now2();
|
||||||
|
@ -9566,11 +9545,11 @@ var BrowserLocalStorage = class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async load() {
|
async load() {
|
||||||
const info2 = JSON.parse(this.LS.getItem(this.keys.info));
|
const info = JSON.parse(this.LS.getItem(this.keys.info));
|
||||||
if (info2 == null) {
|
if (info == null) {
|
||||||
throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);
|
throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);
|
||||||
}
|
}
|
||||||
if (info2.modelTopologyType !== "JSON") {
|
if (info.modelTopologyType !== "JSON") {
|
||||||
throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");
|
throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");
|
||||||
}
|
}
|
||||||
const out = {};
|
const out = {};
|
||||||
|
@ -9653,9 +9632,9 @@ var BrowserLocalStorageManager = class {
|
||||||
if (this.LS.getItem(keys.info) == null) {
|
if (this.LS.getItem(keys.info) == null) {
|
||||||
throw new Error(`Cannot find model at path '${path}'`);
|
throw new Error(`Cannot find model at path '${path}'`);
|
||||||
}
|
}
|
||||||
const info2 = JSON.parse(this.LS.getItem(keys.info));
|
const info = JSON.parse(this.LS.getItem(keys.info));
|
||||||
removeItems(keys);
|
removeItems(keys);
|
||||||
return info2;
|
return info;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var URL_SCHEME_SUFFIX = "://";
|
var URL_SCHEME_SUFFIX = "://";
|
||||||
|
@ -47529,7 +47508,7 @@ var MathBackendWebGL = class extends KernelBackend {
|
||||||
query = this.startTimer();
|
query = this.startTimer();
|
||||||
}
|
}
|
||||||
runProgram(this.gpgpu, binary, inputsData, outputData, customUniformValues);
|
runProgram(this.gpgpu, binary, inputsData, outputData, customUniformValues);
|
||||||
dataToDispose.forEach((info2) => this.disposeIntermediateTensorInfo(info2));
|
dataToDispose.forEach((info) => this.disposeIntermediateTensorInfo(info));
|
||||||
if (shouldTimeProgram) {
|
if (shouldTimeProgram) {
|
||||||
query = this.endTimer(query);
|
query = this.endTimer(query);
|
||||||
this.activeTimers.push({ name: program.constructor.name, query: this.getQueryTime(query) });
|
this.activeTimers.push({ name: program.constructor.name, query: this.getQueryTime(query) });
|
||||||
|
@ -71240,6 +71219,74 @@ SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
||||||
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
||||||
2Q==`;
|
2Q==`;
|
||||||
|
|
||||||
|
// src/env.ts
|
||||||
|
var env2 = {
|
||||||
|
browser: void 0,
|
||||||
|
node: void 0,
|
||||||
|
worker: void 0,
|
||||||
|
platform: void 0,
|
||||||
|
agent: void 0,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: void 0,
|
||||||
|
external: void 0
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: void 0,
|
||||||
|
simd: void 0,
|
||||||
|
multithread: void 0
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: void 0,
|
||||||
|
version: void 0,
|
||||||
|
renderer: void 0
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: void 0,
|
||||||
|
adapter: void 0
|
||||||
|
},
|
||||||
|
kernels: []
|
||||||
|
};
|
||||||
|
async function get3() {
|
||||||
|
var _a;
|
||||||
|
env2.browser = typeof navigator !== "undefined";
|
||||||
|
env2.node = typeof process !== "undefined";
|
||||||
|
env2.worker = env2.browser ? typeof WorkerGlobalScope !== "undefined" : void 0;
|
||||||
|
env2.tfjs.version = version9;
|
||||||
|
if (typeof navigator !== "undefined") {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env2.platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
||||||
|
env2.agent = navigator.userAgent.replace(raw[0], "");
|
||||||
|
if (env2.platform[1])
|
||||||
|
env2.agent = env2.agent.replace(raw[1], "");
|
||||||
|
env2.agent = env2.agent.replace(/ /g, " ");
|
||||||
|
}
|
||||||
|
} else if (typeof process !== "undefined") {
|
||||||
|
env2.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env2.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
env2.backends = Object.keys(engine().registryFactory);
|
||||||
|
env2.wasm.supported = env2.backends.includes("wasm");
|
||||||
|
if (env2.wasm.supported) {
|
||||||
|
env2.wasm.simd = await env().getAsync("WASM_HAS_SIMD_SUPPORT");
|
||||||
|
env2.wasm.multithread = await env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
|
||||||
|
}
|
||||||
|
env2.webgl.supported = typeof backend().gpgpu !== "undefined";
|
||||||
|
if (env2.webgl.supported) {
|
||||||
|
const gl = await backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env2.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env2.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env2.webgpu.supported = env2.browser && typeof navigator["gpu"] !== "undefined";
|
||||||
|
if (env2.webgpu.supported)
|
||||||
|
env2.webgpu.adapter = (_a = await navigator["gpu"].requestAdapter()) == null ? void 0 : _a.name;
|
||||||
|
env2.kernels = getKernelsForBackend(getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
}
|
||||||
|
|
||||||
// package.json
|
// package.json
|
||||||
var version17 = "2.2.0";
|
var version17 = "2.2.0";
|
||||||
|
|
||||||
|
@ -71281,9 +71328,9 @@ var Human = class {
|
||||||
var _a;
|
var _a;
|
||||||
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
||||||
});
|
});
|
||||||
__privateAdd(this, _checkBackend, async (force = false) => {
|
__privateAdd(this, _checkBackend, async () => {
|
||||||
var _a;
|
var _a;
|
||||||
if (this.config.backend && this.config.backend.length > 0 && force || this.tf.getBackend() !== this.config.backend) {
|
if (__privateGet(this, _firstRun) || (this.config.backend && this.config.backend.length > 0 || this.tf.getBackend() !== this.config.backend)) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = "backend";
|
this.state = "backend";
|
||||||
if (this.config.backend && this.config.backend.length > 0) {
|
if (this.config.backend && this.config.backend.length > 0) {
|
||||||
|
@ -71295,7 +71342,7 @@ var Human = class {
|
||||||
this.config.backend = "humangl";
|
this.config.backend = "humangl";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
||||||
log("override: backend set to webgl while running in nodejs");
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = "tensorflow";
|
this.config.backend = "tensorflow";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
||||||
|
@ -71356,6 +71403,8 @@ var Human = class {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
get3();
|
||||||
|
this.env = env2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.next = (result) => calc(result || this.result);
|
this.next = (result) => calc(result || this.result);
|
||||||
|
@ -71451,9 +71500,13 @@ var Human = class {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
get3();
|
||||||
|
this.env = env2;
|
||||||
|
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${version9}/dist/`;
|
||||||
|
config.modelBasePath = this.env.browser ? "../models/" : "file://models/";
|
||||||
|
config.backend = this.env.browser ? "humangl" : "tensorflow";
|
||||||
this.version = version17;
|
this.version = version17;
|
||||||
Object.defineProperty(this, "version", { value: version17 });
|
Object.defineProperty(this, "version", { value: version17 });
|
||||||
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${version9}/dist/`;
|
|
||||||
this.config = mergeDeep(config, userConfig || {});
|
this.config = mergeDeep(config, userConfig || {});
|
||||||
this.tf = tfjs_esm_exports;
|
this.tf = tfjs_esm_exports;
|
||||||
this.draw = draw_exports;
|
this.draw = draw_exports;
|
||||||
|
@ -71486,7 +71539,6 @@ var Human = class {
|
||||||
this.process = { tensor: null, canvas: null };
|
this.process = { tensor: null, canvas: null };
|
||||||
this.faceTriangulation = triangulation;
|
this.faceTriangulation = triangulation;
|
||||||
this.faceUVMap = uvmap;
|
this.faceUVMap = uvmap;
|
||||||
this.sysinfo = info();
|
|
||||||
__privateSet(this, _lastInputSum, 1);
|
__privateSet(this, _lastInputSum, 1);
|
||||||
__privateGet(this, _emit).call(this, "create");
|
__privateGet(this, _emit).call(this, "create");
|
||||||
}
|
}
|
||||||
|
@ -71514,10 +71566,8 @@ var Human = class {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log(`tfjs version: ${this.tf.version_core}`);
|
log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("platform:", this.sysinfo.platform);
|
log("environment:", env2);
|
||||||
if (this.config.debug)
|
await __privateGet(this, _checkBackend).call(this);
|
||||||
log("agent:", this.sysinfo.agent);
|
|
||||||
await __privateGet(this, _checkBackend).call(this, true);
|
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("configuration:", this.config);
|
log("configuration:", this.config);
|
||||||
|
@ -71735,7 +71785,8 @@ _warmupNode = new WeakMap();
|
||||||
export {
|
export {
|
||||||
Human,
|
Human,
|
||||||
Human as default,
|
Human as default,
|
||||||
config as defaults
|
config as defaults,
|
||||||
|
env2 as env
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -85,7 +85,8 @@ var require_tfjs_esm = __commonJS({
|
||||||
__export(exports, {
|
__export(exports, {
|
||||||
Human: () => Human,
|
Human: () => Human,
|
||||||
default: () => Human,
|
default: () => Human,
|
||||||
defaults: () => config
|
defaults: () => config,
|
||||||
|
env: () => env2
|
||||||
});
|
});
|
||||||
|
|
||||||
// src/helpers.ts
|
// src/helpers.ts
|
||||||
|
@ -127,8 +128,8 @@ function mergeDeep(...objects) {
|
||||||
|
|
||||||
// src/config.ts
|
// src/config.ts
|
||||||
var config = {
|
var config = {
|
||||||
backend: "humangl",
|
backend: "",
|
||||||
modelBasePath: "../models/",
|
modelBasePath: "",
|
||||||
wasmPath: "",
|
wasmPath: "",
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -226,29 +227,8 @@ var config = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/sysinfo.ts
|
|
||||||
function info() {
|
|
||||||
let platform = "";
|
|
||||||
let agent = "";
|
|
||||||
if (typeof navigator !== "undefined") {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
|
||||||
agent = navigator.userAgent.replace(raw[0], "");
|
|
||||||
if (platform[1])
|
|
||||||
agent = agent.replace(raw[1], "");
|
|
||||||
agent = agent.replace(/ /g, " ");
|
|
||||||
}
|
|
||||||
} else if (typeof process !== "undefined") {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/human.ts
|
// src/human.ts
|
||||||
var tf21 = __toModule(require_tfjs_esm());
|
var tf22 = __toModule(require_tfjs_esm());
|
||||||
|
|
||||||
// src/tfjs/backend.ts
|
// src/tfjs/backend.ts
|
||||||
var tf = __toModule(require_tfjs_esm());
|
var tf = __toModule(require_tfjs_esm());
|
||||||
|
@ -11783,6 +11763,75 @@ SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
||||||
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
||||||
2Q==`;
|
2Q==`;
|
||||||
|
|
||||||
|
// src/env.ts
|
||||||
|
var tf21 = __toModule(require_tfjs_esm());
|
||||||
|
var env2 = {
|
||||||
|
browser: void 0,
|
||||||
|
node: void 0,
|
||||||
|
worker: void 0,
|
||||||
|
platform: void 0,
|
||||||
|
agent: void 0,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: void 0,
|
||||||
|
external: void 0
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: void 0,
|
||||||
|
simd: void 0,
|
||||||
|
multithread: void 0
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: void 0,
|
||||||
|
version: void 0,
|
||||||
|
renderer: void 0
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: void 0,
|
||||||
|
adapter: void 0
|
||||||
|
},
|
||||||
|
kernels: []
|
||||||
|
};
|
||||||
|
async function get() {
|
||||||
|
var _a;
|
||||||
|
env2.browser = typeof navigator !== "undefined";
|
||||||
|
env2.node = typeof process !== "undefined";
|
||||||
|
env2.worker = env2.browser ? typeof WorkerGlobalScope !== "undefined" : void 0;
|
||||||
|
env2.tfjs.version = tf21.version_core;
|
||||||
|
if (typeof navigator !== "undefined") {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env2.platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
||||||
|
env2.agent = navigator.userAgent.replace(raw[0], "");
|
||||||
|
if (env2.platform[1])
|
||||||
|
env2.agent = env2.agent.replace(raw[1], "");
|
||||||
|
env2.agent = env2.agent.replace(/ /g, " ");
|
||||||
|
}
|
||||||
|
} else if (typeof process !== "undefined") {
|
||||||
|
env2.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env2.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
env2.backends = Object.keys(tf21.engine().registryFactory);
|
||||||
|
env2.wasm.supported = env2.backends.includes("wasm");
|
||||||
|
if (env2.wasm.supported) {
|
||||||
|
env2.wasm.simd = await tf21.env().getAsync("WASM_HAS_SIMD_SUPPORT");
|
||||||
|
env2.wasm.multithread = await tf21.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
|
||||||
|
}
|
||||||
|
env2.webgl.supported = typeof tf21.backend().gpgpu !== "undefined";
|
||||||
|
if (env2.webgl.supported) {
|
||||||
|
const gl = await tf21.backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env2.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env2.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env2.webgpu.supported = env2.browser && typeof navigator["gpu"] !== "undefined";
|
||||||
|
if (env2.webgpu.supported)
|
||||||
|
env2.webgpu.adapter = (_a = await navigator["gpu"].requestAdapter()) == null ? void 0 : _a.name;
|
||||||
|
env2.kernels = tf21.getKernelsForBackend(tf21.getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
}
|
||||||
|
|
||||||
// package.json
|
// package.json
|
||||||
var version = "2.2.0";
|
var version = "2.2.0";
|
||||||
|
|
||||||
|
@ -11811,7 +11860,7 @@ var Human = class {
|
||||||
return null;
|
return null;
|
||||||
if (!input)
|
if (!input)
|
||||||
return "input is not defined";
|
return "input is not defined";
|
||||||
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf21.Tensor))
|
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf22.Tensor))
|
||||||
return "input must be a tensor";
|
return "input must be a tensor";
|
||||||
try {
|
try {
|
||||||
this.tf.getBackend();
|
this.tf.getBackend();
|
||||||
|
@ -11824,9 +11873,9 @@ var Human = class {
|
||||||
var _a;
|
var _a;
|
||||||
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
||||||
});
|
});
|
||||||
__privateAdd(this, _checkBackend, async (force = false) => {
|
__privateAdd(this, _checkBackend, async () => {
|
||||||
var _a;
|
var _a;
|
||||||
if (this.config.backend && this.config.backend.length > 0 && force || this.tf.getBackend() !== this.config.backend) {
|
if (__privateGet(this, _firstRun) || (this.config.backend && this.config.backend.length > 0 || this.tf.getBackend() !== this.config.backend)) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = "backend";
|
this.state = "backend";
|
||||||
if (this.config.backend && this.config.backend.length > 0) {
|
if (this.config.backend && this.config.backend.length > 0) {
|
||||||
|
@ -11838,7 +11887,7 @@ var Human = class {
|
||||||
this.config.backend = "humangl";
|
this.config.backend = "humangl";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
||||||
log("override: backend set to webgl while running in nodejs");
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = "tensorflow";
|
this.config.backend = "tensorflow";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
||||||
|
@ -11899,6 +11948,8 @@ var Human = class {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.next = (result) => calc(result || this.result);
|
this.next = (result) => calc(result || this.result);
|
||||||
|
@ -11908,7 +11959,7 @@ var Human = class {
|
||||||
const resizeFact = 32;
|
const resizeFact = 32;
|
||||||
if (!input.shape[1] || !input.shape[2])
|
if (!input.shape[1] || !input.shape[2])
|
||||||
return false;
|
return false;
|
||||||
const reduced = tf21.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
const reduced = tf22.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
||||||
const reducedData = await reduced.data();
|
const reducedData = await reduced.data();
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let i = 0; i < reducedData.length / 3; i++)
|
for (let i = 0; i < reducedData.length / 3; i++)
|
||||||
|
@ -11982,8 +12033,8 @@ var Human = class {
|
||||||
if (!img)
|
if (!img)
|
||||||
return null;
|
return null;
|
||||||
let res;
|
let res;
|
||||||
if (typeof tf21["node"] !== "undefined") {
|
if (typeof tf22["node"] !== "undefined") {
|
||||||
const data = tf21["node"].decodeJpeg(img);
|
const data = tf22["node"].decodeJpeg(img);
|
||||||
const expanded = data.expandDims(0);
|
const expanded = data.expandDims(0);
|
||||||
this.tf.dispose(data);
|
this.tf.dispose(data);
|
||||||
res = await this.detect(expanded, this.config);
|
res = await this.detect(expanded, this.config);
|
||||||
|
@ -11994,11 +12045,15 @@ var Human = class {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
|
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf22.version_core}/dist/`;
|
||||||
|
config.modelBasePath = this.env.browser ? "../models/" : "file://models/";
|
||||||
|
config.backend = this.env.browser ? "humangl" : "tensorflow";
|
||||||
this.version = version;
|
this.version = version;
|
||||||
Object.defineProperty(this, "version", { value: version });
|
Object.defineProperty(this, "version", { value: version });
|
||||||
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf21.version_core}/dist/`;
|
|
||||||
this.config = mergeDeep(config, userConfig || {});
|
this.config = mergeDeep(config, userConfig || {});
|
||||||
this.tf = tf21;
|
this.tf = tf22;
|
||||||
this.draw = draw_exports;
|
this.draw = draw_exports;
|
||||||
this.state = "idle";
|
this.state = "idle";
|
||||||
__privateSet(this, _numTensors, 0);
|
__privateSet(this, _numTensors, 0);
|
||||||
|
@ -12029,7 +12084,6 @@ var Human = class {
|
||||||
this.process = { tensor: null, canvas: null };
|
this.process = { tensor: null, canvas: null };
|
||||||
this.faceTriangulation = triangulation;
|
this.faceTriangulation = triangulation;
|
||||||
this.faceUVMap = uvmap;
|
this.faceUVMap = uvmap;
|
||||||
this.sysinfo = info();
|
|
||||||
__privateSet(this, _lastInputSum, 1);
|
__privateSet(this, _lastInputSum, 1);
|
||||||
__privateGet(this, _emit).call(this, "create");
|
__privateGet(this, _emit).call(this, "create");
|
||||||
}
|
}
|
||||||
|
@ -12057,10 +12111,8 @@ var Human = class {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log(`tfjs version: ${this.tf.version_core}`);
|
log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("platform:", this.sysinfo.platform);
|
log("environment:", env2);
|
||||||
if (this.config.debug)
|
await __privateGet(this, _checkBackend).call(this);
|
||||||
log("agent:", this.sysinfo.agent);
|
|
||||||
await __privateGet(this, _checkBackend).call(this, true);
|
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("configuration:", this.config);
|
log("configuration:", this.config);
|
||||||
|
@ -12110,7 +12162,7 @@ var Human = class {
|
||||||
if (elapsedTime > 0)
|
if (elapsedTime > 0)
|
||||||
this.performance.segmentation = elapsedTime;
|
this.performance.segmentation = elapsedTime;
|
||||||
if (this.process.canvas) {
|
if (this.process.canvas) {
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
this.process = process4(this.process.canvas, this.config);
|
this.process = process4(this.process.canvas, this.config);
|
||||||
}
|
}
|
||||||
this.analyze("End Segmentation:");
|
this.analyze("End Segmentation:");
|
||||||
|
@ -12237,7 +12289,7 @@ var Human = class {
|
||||||
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
__privateGet(this, _emit).call(this, "detect");
|
__privateGet(this, _emit).call(this, "detect");
|
||||||
resolve(this.result);
|
resolve(this.result);
|
||||||
});
|
});
|
||||||
|
@ -12278,5 +12330,6 @@ _warmupNode = new WeakMap();
|
||||||
// Annotate the CommonJS export names for ESM import in node:
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
0 && (module.exports = {
|
0 && (module.exports = {
|
||||||
Human,
|
Human,
|
||||||
defaults
|
defaults,
|
||||||
|
env
|
||||||
});
|
});
|
||||||
|
|
|
@ -86,7 +86,8 @@ var require_tfjs_esm = __commonJS({
|
||||||
__export(exports, {
|
__export(exports, {
|
||||||
Human: () => Human,
|
Human: () => Human,
|
||||||
default: () => Human,
|
default: () => Human,
|
||||||
defaults: () => config
|
defaults: () => config,
|
||||||
|
env: () => env2
|
||||||
});
|
});
|
||||||
|
|
||||||
// src/helpers.ts
|
// src/helpers.ts
|
||||||
|
@ -128,8 +129,8 @@ function mergeDeep(...objects) {
|
||||||
|
|
||||||
// src/config.ts
|
// src/config.ts
|
||||||
var config = {
|
var config = {
|
||||||
backend: "humangl",
|
backend: "",
|
||||||
modelBasePath: "../models/",
|
modelBasePath: "",
|
||||||
wasmPath: "",
|
wasmPath: "",
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -227,29 +228,8 @@ var config = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/sysinfo.ts
|
|
||||||
function info() {
|
|
||||||
let platform = "";
|
|
||||||
let agent = "";
|
|
||||||
if (typeof navigator !== "undefined") {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
|
||||||
agent = navigator.userAgent.replace(raw[0], "");
|
|
||||||
if (platform[1])
|
|
||||||
agent = agent.replace(raw[1], "");
|
|
||||||
agent = agent.replace(/ /g, " ");
|
|
||||||
}
|
|
||||||
} else if (typeof process !== "undefined") {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/human.ts
|
// src/human.ts
|
||||||
var tf21 = __toModule(require_tfjs_esm());
|
var tf22 = __toModule(require_tfjs_esm());
|
||||||
|
|
||||||
// src/tfjs/backend.ts
|
// src/tfjs/backend.ts
|
||||||
var tf = __toModule(require_tfjs_esm());
|
var tf = __toModule(require_tfjs_esm());
|
||||||
|
@ -11784,6 +11764,75 @@ SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
||||||
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
||||||
2Q==`;
|
2Q==`;
|
||||||
|
|
||||||
|
// src/env.ts
|
||||||
|
var tf21 = __toModule(require_tfjs_esm());
|
||||||
|
var env2 = {
|
||||||
|
browser: void 0,
|
||||||
|
node: void 0,
|
||||||
|
worker: void 0,
|
||||||
|
platform: void 0,
|
||||||
|
agent: void 0,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: void 0,
|
||||||
|
external: void 0
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: void 0,
|
||||||
|
simd: void 0,
|
||||||
|
multithread: void 0
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: void 0,
|
||||||
|
version: void 0,
|
||||||
|
renderer: void 0
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: void 0,
|
||||||
|
adapter: void 0
|
||||||
|
},
|
||||||
|
kernels: []
|
||||||
|
};
|
||||||
|
async function get() {
|
||||||
|
var _a;
|
||||||
|
env2.browser = typeof navigator !== "undefined";
|
||||||
|
env2.node = typeof process !== "undefined";
|
||||||
|
env2.worker = env2.browser ? typeof WorkerGlobalScope !== "undefined" : void 0;
|
||||||
|
env2.tfjs.version = tf21.version_core;
|
||||||
|
if (typeof navigator !== "undefined") {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env2.platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
||||||
|
env2.agent = navigator.userAgent.replace(raw[0], "");
|
||||||
|
if (env2.platform[1])
|
||||||
|
env2.agent = env2.agent.replace(raw[1], "");
|
||||||
|
env2.agent = env2.agent.replace(/ /g, " ");
|
||||||
|
}
|
||||||
|
} else if (typeof process !== "undefined") {
|
||||||
|
env2.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env2.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
env2.backends = Object.keys(tf21.engine().registryFactory);
|
||||||
|
env2.wasm.supported = env2.backends.includes("wasm");
|
||||||
|
if (env2.wasm.supported) {
|
||||||
|
env2.wasm.simd = await tf21.env().getAsync("WASM_HAS_SIMD_SUPPORT");
|
||||||
|
env2.wasm.multithread = await tf21.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
|
||||||
|
}
|
||||||
|
env2.webgl.supported = typeof tf21.backend().gpgpu !== "undefined";
|
||||||
|
if (env2.webgl.supported) {
|
||||||
|
const gl = await tf21.backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env2.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env2.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env2.webgpu.supported = env2.browser && typeof navigator["gpu"] !== "undefined";
|
||||||
|
if (env2.webgpu.supported)
|
||||||
|
env2.webgpu.adapter = (_a = await navigator["gpu"].requestAdapter()) == null ? void 0 : _a.name;
|
||||||
|
env2.kernels = tf21.getKernelsForBackend(tf21.getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
}
|
||||||
|
|
||||||
// package.json
|
// package.json
|
||||||
var version = "2.2.0";
|
var version = "2.2.0";
|
||||||
|
|
||||||
|
@ -11812,7 +11861,7 @@ var Human = class {
|
||||||
return null;
|
return null;
|
||||||
if (!input)
|
if (!input)
|
||||||
return "input is not defined";
|
return "input is not defined";
|
||||||
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf21.Tensor))
|
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf22.Tensor))
|
||||||
return "input must be a tensor";
|
return "input must be a tensor";
|
||||||
try {
|
try {
|
||||||
this.tf.getBackend();
|
this.tf.getBackend();
|
||||||
|
@ -11825,9 +11874,9 @@ var Human = class {
|
||||||
var _a;
|
var _a;
|
||||||
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
||||||
});
|
});
|
||||||
__privateAdd(this, _checkBackend, async (force = false) => {
|
__privateAdd(this, _checkBackend, async () => {
|
||||||
var _a;
|
var _a;
|
||||||
if (this.config.backend && this.config.backend.length > 0 && force || this.tf.getBackend() !== this.config.backend) {
|
if (__privateGet(this, _firstRun) || (this.config.backend && this.config.backend.length > 0 || this.tf.getBackend() !== this.config.backend)) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = "backend";
|
this.state = "backend";
|
||||||
if (this.config.backend && this.config.backend.length > 0) {
|
if (this.config.backend && this.config.backend.length > 0) {
|
||||||
|
@ -11839,7 +11888,7 @@ var Human = class {
|
||||||
this.config.backend = "humangl";
|
this.config.backend = "humangl";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
||||||
log("override: backend set to webgl while running in nodejs");
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = "tensorflow";
|
this.config.backend = "tensorflow";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
||||||
|
@ -11900,6 +11949,8 @@ var Human = class {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.next = (result) => calc(result || this.result);
|
this.next = (result) => calc(result || this.result);
|
||||||
|
@ -11909,7 +11960,7 @@ var Human = class {
|
||||||
const resizeFact = 32;
|
const resizeFact = 32;
|
||||||
if (!input.shape[1] || !input.shape[2])
|
if (!input.shape[1] || !input.shape[2])
|
||||||
return false;
|
return false;
|
||||||
const reduced = tf21.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
const reduced = tf22.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
||||||
const reducedData = await reduced.data();
|
const reducedData = await reduced.data();
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let i = 0; i < reducedData.length / 3; i++)
|
for (let i = 0; i < reducedData.length / 3; i++)
|
||||||
|
@ -11983,8 +12034,8 @@ var Human = class {
|
||||||
if (!img)
|
if (!img)
|
||||||
return null;
|
return null;
|
||||||
let res;
|
let res;
|
||||||
if (typeof tf21["node"] !== "undefined") {
|
if (typeof tf22["node"] !== "undefined") {
|
||||||
const data = tf21["node"].decodeJpeg(img);
|
const data = tf22["node"].decodeJpeg(img);
|
||||||
const expanded = data.expandDims(0);
|
const expanded = data.expandDims(0);
|
||||||
this.tf.dispose(data);
|
this.tf.dispose(data);
|
||||||
res = await this.detect(expanded, this.config);
|
res = await this.detect(expanded, this.config);
|
||||||
|
@ -11995,11 +12046,15 @@ var Human = class {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
|
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf22.version_core}/dist/`;
|
||||||
|
config.modelBasePath = this.env.browser ? "../models/" : "file://models/";
|
||||||
|
config.backend = this.env.browser ? "humangl" : "tensorflow";
|
||||||
this.version = version;
|
this.version = version;
|
||||||
Object.defineProperty(this, "version", { value: version });
|
Object.defineProperty(this, "version", { value: version });
|
||||||
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf21.version_core}/dist/`;
|
|
||||||
this.config = mergeDeep(config, userConfig || {});
|
this.config = mergeDeep(config, userConfig || {});
|
||||||
this.tf = tf21;
|
this.tf = tf22;
|
||||||
this.draw = draw_exports;
|
this.draw = draw_exports;
|
||||||
this.state = "idle";
|
this.state = "idle";
|
||||||
__privateSet(this, _numTensors, 0);
|
__privateSet(this, _numTensors, 0);
|
||||||
|
@ -12030,7 +12085,6 @@ var Human = class {
|
||||||
this.process = { tensor: null, canvas: null };
|
this.process = { tensor: null, canvas: null };
|
||||||
this.faceTriangulation = triangulation;
|
this.faceTriangulation = triangulation;
|
||||||
this.faceUVMap = uvmap;
|
this.faceUVMap = uvmap;
|
||||||
this.sysinfo = info();
|
|
||||||
__privateSet(this, _lastInputSum, 1);
|
__privateSet(this, _lastInputSum, 1);
|
||||||
__privateGet(this, _emit).call(this, "create");
|
__privateGet(this, _emit).call(this, "create");
|
||||||
}
|
}
|
||||||
|
@ -12058,10 +12112,8 @@ var Human = class {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log(`tfjs version: ${this.tf.version_core}`);
|
log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("platform:", this.sysinfo.platform);
|
log("environment:", env2);
|
||||||
if (this.config.debug)
|
await __privateGet(this, _checkBackend).call(this);
|
||||||
log("agent:", this.sysinfo.agent);
|
|
||||||
await __privateGet(this, _checkBackend).call(this, true);
|
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("configuration:", this.config);
|
log("configuration:", this.config);
|
||||||
|
@ -12111,7 +12163,7 @@ var Human = class {
|
||||||
if (elapsedTime > 0)
|
if (elapsedTime > 0)
|
||||||
this.performance.segmentation = elapsedTime;
|
this.performance.segmentation = elapsedTime;
|
||||||
if (this.process.canvas) {
|
if (this.process.canvas) {
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
this.process = process4(this.process.canvas, this.config);
|
this.process = process4(this.process.canvas, this.config);
|
||||||
}
|
}
|
||||||
this.analyze("End Segmentation:");
|
this.analyze("End Segmentation:");
|
||||||
|
@ -12238,7 +12290,7 @@ var Human = class {
|
||||||
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
__privateGet(this, _emit).call(this, "detect");
|
__privateGet(this, _emit).call(this, "detect");
|
||||||
resolve(this.result);
|
resolve(this.result);
|
||||||
});
|
});
|
||||||
|
@ -12279,5 +12331,6 @@ _warmupNode = new WeakMap();
|
||||||
// Annotate the CommonJS export names for ESM import in node:
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
0 && (module.exports = {
|
0 && (module.exports = {
|
||||||
Human,
|
Human,
|
||||||
defaults
|
defaults,
|
||||||
|
env
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,8 @@ var require_tfjs_esm = __commonJS({
|
||||||
__export(exports, {
|
__export(exports, {
|
||||||
Human: () => Human,
|
Human: () => Human,
|
||||||
default: () => Human,
|
default: () => Human,
|
||||||
defaults: () => config
|
defaults: () => config,
|
||||||
|
env: () => env2
|
||||||
});
|
});
|
||||||
|
|
||||||
// src/helpers.ts
|
// src/helpers.ts
|
||||||
|
@ -127,8 +128,8 @@ function mergeDeep(...objects) {
|
||||||
|
|
||||||
// src/config.ts
|
// src/config.ts
|
||||||
var config = {
|
var config = {
|
||||||
backend: "humangl",
|
backend: "",
|
||||||
modelBasePath: "../models/",
|
modelBasePath: "",
|
||||||
wasmPath: "",
|
wasmPath: "",
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -226,29 +227,8 @@ var config = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/sysinfo.ts
|
|
||||||
function info() {
|
|
||||||
let platform = "";
|
|
||||||
let agent = "";
|
|
||||||
if (typeof navigator !== "undefined") {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
|
||||||
agent = navigator.userAgent.replace(raw[0], "");
|
|
||||||
if (platform[1])
|
|
||||||
agent = agent.replace(raw[1], "");
|
|
||||||
agent = agent.replace(/ /g, " ");
|
|
||||||
}
|
|
||||||
} else if (typeof process !== "undefined") {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/human.ts
|
// src/human.ts
|
||||||
var tf21 = __toModule(require_tfjs_esm());
|
var tf22 = __toModule(require_tfjs_esm());
|
||||||
|
|
||||||
// src/tfjs/backend.ts
|
// src/tfjs/backend.ts
|
||||||
var tf = __toModule(require_tfjs_esm());
|
var tf = __toModule(require_tfjs_esm());
|
||||||
|
@ -11783,6 +11763,75 @@ SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
||||||
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
||||||
2Q==`;
|
2Q==`;
|
||||||
|
|
||||||
|
// src/env.ts
|
||||||
|
var tf21 = __toModule(require_tfjs_esm());
|
||||||
|
var env2 = {
|
||||||
|
browser: void 0,
|
||||||
|
node: void 0,
|
||||||
|
worker: void 0,
|
||||||
|
platform: void 0,
|
||||||
|
agent: void 0,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: void 0,
|
||||||
|
external: void 0
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: void 0,
|
||||||
|
simd: void 0,
|
||||||
|
multithread: void 0
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: void 0,
|
||||||
|
version: void 0,
|
||||||
|
renderer: void 0
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: void 0,
|
||||||
|
adapter: void 0
|
||||||
|
},
|
||||||
|
kernels: []
|
||||||
|
};
|
||||||
|
async function get() {
|
||||||
|
var _a;
|
||||||
|
env2.browser = typeof navigator !== "undefined";
|
||||||
|
env2.node = typeof process !== "undefined";
|
||||||
|
env2.worker = env2.browser ? typeof WorkerGlobalScope !== "undefined" : void 0;
|
||||||
|
env2.tfjs.version = tf21.version_core;
|
||||||
|
if (typeof navigator !== "undefined") {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env2.platform = platformMatch && platformMatch[0] ? platformMatch[0].replace(/\(|\)/g, "") : "";
|
||||||
|
env2.agent = navigator.userAgent.replace(raw[0], "");
|
||||||
|
if (env2.platform[1])
|
||||||
|
env2.agent = env2.agent.replace(raw[1], "");
|
||||||
|
env2.agent = env2.agent.replace(/ /g, " ");
|
||||||
|
}
|
||||||
|
} else if (typeof process !== "undefined") {
|
||||||
|
env2.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env2.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
env2.backends = Object.keys(tf21.engine().registryFactory);
|
||||||
|
env2.wasm.supported = env2.backends.includes("wasm");
|
||||||
|
if (env2.wasm.supported) {
|
||||||
|
env2.wasm.simd = await tf21.env().getAsync("WASM_HAS_SIMD_SUPPORT");
|
||||||
|
env2.wasm.multithread = await tf21.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");
|
||||||
|
}
|
||||||
|
env2.webgl.supported = typeof tf21.backend().gpgpu !== "undefined";
|
||||||
|
if (env2.webgl.supported) {
|
||||||
|
const gl = await tf21.backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env2.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env2.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
env2.webgpu.supported = env2.browser && typeof navigator["gpu"] !== "undefined";
|
||||||
|
if (env2.webgpu.supported)
|
||||||
|
env2.webgpu.adapter = (_a = await navigator["gpu"].requestAdapter()) == null ? void 0 : _a.name;
|
||||||
|
env2.kernels = tf21.getKernelsForBackend(tf21.getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
}
|
||||||
|
|
||||||
// package.json
|
// package.json
|
||||||
var version = "2.2.0";
|
var version = "2.2.0";
|
||||||
|
|
||||||
|
@ -11811,7 +11860,7 @@ var Human = class {
|
||||||
return null;
|
return null;
|
||||||
if (!input)
|
if (!input)
|
||||||
return "input is not defined";
|
return "input is not defined";
|
||||||
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf21.Tensor))
|
if (this.tf.ENV.flags.IS_NODE && !(input instanceof tf22.Tensor))
|
||||||
return "input must be a tensor";
|
return "input must be a tensor";
|
||||||
try {
|
try {
|
||||||
this.tf.getBackend();
|
this.tf.getBackend();
|
||||||
|
@ -11824,9 +11873,9 @@ var Human = class {
|
||||||
var _a;
|
var _a;
|
||||||
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
return (_a = this.events) == null ? void 0 : _a.dispatchEvent(new Event(event));
|
||||||
});
|
});
|
||||||
__privateAdd(this, _checkBackend, async (force = false) => {
|
__privateAdd(this, _checkBackend, async () => {
|
||||||
var _a;
|
var _a;
|
||||||
if (this.config.backend && this.config.backend.length > 0 && force || this.tf.getBackend() !== this.config.backend) {
|
if (__privateGet(this, _firstRun) || (this.config.backend && this.config.backend.length > 0 || this.tf.getBackend() !== this.config.backend)) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = "backend";
|
this.state = "backend";
|
||||||
if (this.config.backend && this.config.backend.length > 0) {
|
if (this.config.backend && this.config.backend.length > 0) {
|
||||||
|
@ -11838,7 +11887,7 @@ var Human = class {
|
||||||
this.config.backend = "humangl";
|
this.config.backend = "humangl";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === "webgl" || this.config.backend === "humangl")) {
|
||||||
log("override: backend set to webgl while running in nodejs");
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = "tensorflow";
|
this.config.backend = "tensorflow";
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === "webgpu") {
|
||||||
|
@ -11899,6 +11948,8 @@ var Human = class {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.next = (result) => calc(result || this.result);
|
this.next = (result) => calc(result || this.result);
|
||||||
|
@ -11908,7 +11959,7 @@ var Human = class {
|
||||||
const resizeFact = 32;
|
const resizeFact = 32;
|
||||||
if (!input.shape[1] || !input.shape[2])
|
if (!input.shape[1] || !input.shape[2])
|
||||||
return false;
|
return false;
|
||||||
const reduced = tf21.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
const reduced = tf22.image.resizeBilinear(input, [Math.trunc(input.shape[1] / resizeFact), Math.trunc(input.shape[2] / resizeFact)]);
|
||||||
const reducedData = await reduced.data();
|
const reducedData = await reduced.data();
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let i = 0; i < reducedData.length / 3; i++)
|
for (let i = 0; i < reducedData.length / 3; i++)
|
||||||
|
@ -11982,8 +12033,8 @@ var Human = class {
|
||||||
if (!img)
|
if (!img)
|
||||||
return null;
|
return null;
|
||||||
let res;
|
let res;
|
||||||
if (typeof tf21["node"] !== "undefined") {
|
if (typeof tf22["node"] !== "undefined") {
|
||||||
const data = tf21["node"].decodeJpeg(img);
|
const data = tf22["node"].decodeJpeg(img);
|
||||||
const expanded = data.expandDims(0);
|
const expanded = data.expandDims(0);
|
||||||
this.tf.dispose(data);
|
this.tf.dispose(data);
|
||||||
res = await this.detect(expanded, this.config);
|
res = await this.detect(expanded, this.config);
|
||||||
|
@ -11994,11 +12045,15 @@ var Human = class {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
get();
|
||||||
|
this.env = env2;
|
||||||
|
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf22.version_core}/dist/`;
|
||||||
|
config.modelBasePath = this.env.browser ? "../models/" : "file://models/";
|
||||||
|
config.backend = this.env.browser ? "humangl" : "tensorflow";
|
||||||
this.version = version;
|
this.version = version;
|
||||||
Object.defineProperty(this, "version", { value: version });
|
Object.defineProperty(this, "version", { value: version });
|
||||||
config.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf21.version_core}/dist/`;
|
|
||||||
this.config = mergeDeep(config, userConfig || {});
|
this.config = mergeDeep(config, userConfig || {});
|
||||||
this.tf = tf21;
|
this.tf = tf22;
|
||||||
this.draw = draw_exports;
|
this.draw = draw_exports;
|
||||||
this.state = "idle";
|
this.state = "idle";
|
||||||
__privateSet(this, _numTensors, 0);
|
__privateSet(this, _numTensors, 0);
|
||||||
|
@ -12029,7 +12084,6 @@ var Human = class {
|
||||||
this.process = { tensor: null, canvas: null };
|
this.process = { tensor: null, canvas: null };
|
||||||
this.faceTriangulation = triangulation;
|
this.faceTriangulation = triangulation;
|
||||||
this.faceUVMap = uvmap;
|
this.faceUVMap = uvmap;
|
||||||
this.sysinfo = info();
|
|
||||||
__privateSet(this, _lastInputSum, 1);
|
__privateSet(this, _lastInputSum, 1);
|
||||||
__privateGet(this, _emit).call(this, "create");
|
__privateGet(this, _emit).call(this, "create");
|
||||||
}
|
}
|
||||||
|
@ -12057,10 +12111,8 @@ var Human = class {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log(`tfjs version: ${this.tf.version_core}`);
|
log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("platform:", this.sysinfo.platform);
|
log("environment:", env2);
|
||||||
if (this.config.debug)
|
await __privateGet(this, _checkBackend).call(this);
|
||||||
log("agent:", this.sysinfo.agent);
|
|
||||||
await __privateGet(this, _checkBackend).call(this, true);
|
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug)
|
if (this.config.debug)
|
||||||
log("configuration:", this.config);
|
log("configuration:", this.config);
|
||||||
|
@ -12110,7 +12162,7 @@ var Human = class {
|
||||||
if (elapsedTime > 0)
|
if (elapsedTime > 0)
|
||||||
this.performance.segmentation = elapsedTime;
|
this.performance.segmentation = elapsedTime;
|
||||||
if (this.process.canvas) {
|
if (this.process.canvas) {
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
this.process = process4(this.process.canvas, this.config);
|
this.process = process4(this.process.canvas, this.config);
|
||||||
}
|
}
|
||||||
this.analyze("End Segmentation:");
|
this.analyze("End Segmentation:");
|
||||||
|
@ -12237,7 +12289,7 @@ var Human = class {
|
||||||
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
return join2(faceRes, bodyRes, handRes, gestureRes, shape);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tf21.dispose(this.process.tensor);
|
tf22.dispose(this.process.tensor);
|
||||||
__privateGet(this, _emit).call(this, "detect");
|
__privateGet(this, _emit).call(this, "detect");
|
||||||
resolve(this.result);
|
resolve(this.result);
|
||||||
});
|
});
|
||||||
|
@ -12278,5 +12330,6 @@ _warmupNode = new WeakMap();
|
||||||
// Annotate the CommonJS export names for ESM import in node:
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
0 && (module.exports = {
|
0 && (module.exports = {
|
||||||
Human,
|
Human,
|
||||||
defaults
|
defaults,
|
||||||
|
env
|
||||||
});
|
});
|
||||||
|
|
|
@ -246,9 +246,11 @@ export interface Config {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
backend: 'humangl', // select tfjs backend to use, leave empty to use default backend
|
backend: '', // select tfjs backend to use, leave empty to use default backend
|
||||||
// can be 'webgl', 'wasm', 'cpu', or 'humangl' which is a custom version of webgl
|
// can be 'webgl', 'wasm', 'cpu', or 'humangl' which is a custom version of webgl
|
||||||
modelBasePath: '../models/', // base path for all models
|
// default set to `humangl` for browsers and `tensorflow` for nodejs
|
||||||
|
modelBasePath: '', // base path for all models
|
||||||
|
// default set to `../models/` for browsers and `file://models/` for nodejs
|
||||||
wasmPath: '', // path for wasm binaries, only used for backend: wasm
|
wasmPath: '', // path for wasm binaries, only used for backend: wasm
|
||||||
// default set to download from jsdeliv during Human class instantiation
|
// default set to download from jsdeliv during Human class instantiation
|
||||||
debug: true, // print additional status messages to console
|
debug: true, // print additional status messages to console
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
import * as tf from '../dist/tfjs.esm.js';
|
||||||
|
|
||||||
|
export interface Env {
|
||||||
|
browser: undefined | boolean,
|
||||||
|
node: undefined | boolean,
|
||||||
|
worker: undefined | boolean,
|
||||||
|
platform: undefined | string,
|
||||||
|
agent: undefined | string,
|
||||||
|
backends: string[],
|
||||||
|
tfjs: {
|
||||||
|
version: undefined | string,
|
||||||
|
external: undefined | boolean,
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: undefined | boolean,
|
||||||
|
simd: undefined | boolean,
|
||||||
|
multithread: undefined | boolean,
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: undefined | boolean,
|
||||||
|
version: undefined | string,
|
||||||
|
renderer: undefined | string,
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: undefined | boolean,
|
||||||
|
adapter: undefined | string,
|
||||||
|
},
|
||||||
|
kernels: string[],
|
||||||
|
}
|
||||||
|
|
||||||
|
export const env: Env = {
|
||||||
|
browser: undefined,
|
||||||
|
node: undefined,
|
||||||
|
worker: undefined,
|
||||||
|
platform: undefined,
|
||||||
|
agent: undefined,
|
||||||
|
backends: [],
|
||||||
|
tfjs: {
|
||||||
|
version: undefined,
|
||||||
|
external: undefined,
|
||||||
|
},
|
||||||
|
wasm: {
|
||||||
|
supported: undefined,
|
||||||
|
simd: undefined,
|
||||||
|
multithread: undefined,
|
||||||
|
},
|
||||||
|
webgl: {
|
||||||
|
supported: undefined,
|
||||||
|
version: undefined,
|
||||||
|
renderer: undefined,
|
||||||
|
},
|
||||||
|
webgpu: {
|
||||||
|
supported: undefined,
|
||||||
|
adapter: undefined,
|
||||||
|
},
|
||||||
|
kernels: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export function cpuinfo() {
|
||||||
|
const cpu = { model: '', flags: [] };
|
||||||
|
if (env.node && env.platform?.startsWith('linux')) {
|
||||||
|
// eslint-disable-next-line global-require
|
||||||
|
const fs = require('fs');
|
||||||
|
try {
|
||||||
|
const data = fs.readFileSync('/proc/cpuinfo').toString();
|
||||||
|
for (const line of data.split('\n')) {
|
||||||
|
if (line.startsWith('model name')) {
|
||||||
|
cpu.model = line.match(/:(.*)/g)[0].replace(':', '').trim();
|
||||||
|
}
|
||||||
|
if (line.startsWith('flags')) {
|
||||||
|
cpu.flags = line.match(/:(.*)/g)[0].replace(':', '').trim().split(' ').sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch { /**/ }
|
||||||
|
}
|
||||||
|
if (!env['cpu']) Object.defineProperty(env, 'cpu', { value: cpu });
|
||||||
|
else env['cpu'] = cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get() {
|
||||||
|
env.browser = typeof navigator !== 'undefined';
|
||||||
|
env.node = typeof process !== 'undefined';
|
||||||
|
// @ts-ignore WorkerGlobalScope evaluated in browser only
|
||||||
|
env.worker = env.browser ? (typeof WorkerGlobalScope !== 'undefined') : undefined;
|
||||||
|
env.tfjs.version = tf.version_core;
|
||||||
|
|
||||||
|
// get platform and agent
|
||||||
|
if (typeof navigator !== 'undefined') {
|
||||||
|
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
||||||
|
if (raw && raw[0]) {
|
||||||
|
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
||||||
|
env.platform = (platformMatch && platformMatch[0]) ? platformMatch[0].replace(/\(|\)/g, '') : '';
|
||||||
|
env.agent = navigator.userAgent.replace(raw[0], '');
|
||||||
|
if (env.platform[1]) env.agent = env.agent.replace(raw[1], '');
|
||||||
|
env.agent = env.agent.replace(/ /g, ' ');
|
||||||
|
}
|
||||||
|
} else if (typeof process !== 'undefined') {
|
||||||
|
env.platform = `${process.platform} ${process.arch}`;
|
||||||
|
env.agent = `NodeJS ${process.version}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// analyze backends
|
||||||
|
env.backends = Object.keys(tf.engine().registryFactory);
|
||||||
|
env.wasm.supported = env.backends.includes('wasm');
|
||||||
|
if (env.wasm.supported) {
|
||||||
|
env.wasm.simd = await tf.env().getAsync('WASM_HAS_SIMD_SUPPORT');
|
||||||
|
env.wasm.multithread = await tf.env().getAsync('WASM_HAS_MULTITHREAD_SUPPORT');
|
||||||
|
}
|
||||||
|
|
||||||
|
env.webgl.supported = typeof tf.backend().gpgpu !== 'undefined';
|
||||||
|
if (env.webgl.supported) {
|
||||||
|
// @ts-ignore getGPGPUContext only exists on WebGL backend
|
||||||
|
const gl = await tf.backend().getGPGPUContext().gl;
|
||||||
|
if (gl) {
|
||||||
|
env.webgl.version = gl.getParameter(gl.VERSION);
|
||||||
|
env.webgl.renderer = gl.getParameter(gl.RENDERER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
env.webgpu.supported = env.browser && typeof navigator['gpu'] !== 'undefined';
|
||||||
|
if (env.webgpu.supported) env.webgpu.adapter = (await navigator['gpu'].requestAdapter())?.name;
|
||||||
|
|
||||||
|
// enumerate kernels
|
||||||
|
env.kernels = tf.getKernelsForBackend(tf.getBackend()).map((kernel) => kernel.kernelName);
|
||||||
|
|
||||||
|
// get cpu info
|
||||||
|
// cpuinfo();
|
||||||
|
}
|
30
src/human.ts
30
src/human.ts
|
@ -5,7 +5,6 @@
|
||||||
import { log, now, mergeDeep } from './helpers';
|
import { log, now, mergeDeep } from './helpers';
|
||||||
import { Config, defaults } from './config';
|
import { Config, defaults } from './config';
|
||||||
import { Result, FaceResult, HandResult, BodyResult, ObjectResult, GestureResult } from './result';
|
import { Result, FaceResult, HandResult, BodyResult, ObjectResult, GestureResult } from './result';
|
||||||
import * as sysinfo from './sysinfo';
|
|
||||||
import * as tf from '../dist/tfjs.esm.js';
|
import * as tf from '../dist/tfjs.esm.js';
|
||||||
import * as backend from './tfjs/backend';
|
import * as backend from './tfjs/backend';
|
||||||
import * as models from './models';
|
import * as models from './models';
|
||||||
|
@ -26,6 +25,7 @@ import * as draw from './draw/draw';
|
||||||
import * as persons from './persons';
|
import * as persons from './persons';
|
||||||
import * as interpolate from './interpolate';
|
import * as interpolate from './interpolate';
|
||||||
import * as sample from './sample';
|
import * as sample from './sample';
|
||||||
|
import * as env from './env';
|
||||||
import * as app from '../package.json';
|
import * as app from '../package.json';
|
||||||
import { Tensor, GraphModel } from './tfjs/types';
|
import { Tensor, GraphModel } from './tfjs/types';
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import { Tensor, GraphModel } from './tfjs/types';
|
||||||
export * from './config';
|
export * from './config';
|
||||||
export * from './result';
|
export * from './result';
|
||||||
export type { DrawOptions } from './draw/draw';
|
export type { DrawOptions } from './draw/draw';
|
||||||
|
export { env } from './env';
|
||||||
|
|
||||||
/** Defines all possible input types for **Human** detection
|
/** Defines all possible input types for **Human** detection
|
||||||
* @typedef Input Type
|
* @typedef Input Type
|
||||||
|
@ -93,6 +94,10 @@ export class Human {
|
||||||
* - Can be embedded or externally provided
|
* - Can be embedded or externally provided
|
||||||
*/
|
*/
|
||||||
tf: TensorFlow;
|
tf: TensorFlow;
|
||||||
|
/**
|
||||||
|
* Object containing environment information used for diagnostics
|
||||||
|
*/
|
||||||
|
env: env.Env;
|
||||||
/** Draw helper classes that can draw detected objects on canvas using specified draw
|
/** Draw helper classes that can draw detected objects on canvas using specified draw
|
||||||
* - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method
|
* - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method
|
||||||
* - face: draw detected faces
|
* - face: draw detected faces
|
||||||
|
@ -141,8 +146,6 @@ export class Human {
|
||||||
faceTriangulation: typeof facemesh.triangulation;
|
faceTriangulation: typeof facemesh.triangulation;
|
||||||
/** Refernce UV map of 468 values, used for 3D mapping of the face mesh */
|
/** Refernce UV map of 468 values, used for 3D mapping of the face mesh */
|
||||||
faceUVMap: typeof facemesh.uvmap;
|
faceUVMap: typeof facemesh.uvmap;
|
||||||
/** Platform and agent information detected by Human */
|
|
||||||
sysinfo: { platform: string, agent: string };
|
|
||||||
/** Performance object that contains values for all recently performed operations */
|
/** Performance object that contains values for all recently performed operations */
|
||||||
performance: Record<string, number>; // perf members are dynamically defined as needed
|
performance: Record<string, number>; // perf members are dynamically defined as needed
|
||||||
#numTensors: number;
|
#numTensors: number;
|
||||||
|
@ -159,9 +162,13 @@ export class Human {
|
||||||
* @param userConfig: {@link Config}
|
* @param userConfig: {@link Config}
|
||||||
*/
|
*/
|
||||||
constructor(userConfig?: Partial<Config>) {
|
constructor(userConfig?: Partial<Config>) {
|
||||||
|
env.get();
|
||||||
|
this.env = env.env;
|
||||||
|
defaults.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`;
|
||||||
|
defaults.modelBasePath = this.env.browser ? '../models/' : 'file://models/';
|
||||||
|
defaults.backend = this.env.browser ? 'humangl' : 'tensorflow';
|
||||||
this.version = app.version; // expose version property on instance of class
|
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
|
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/`;
|
|
||||||
this.config = mergeDeep(defaults, userConfig || {});
|
this.config = mergeDeep(defaults, userConfig || {});
|
||||||
this.tf = tf;
|
this.tf = tf;
|
||||||
this.draw = draw;
|
this.draw = draw;
|
||||||
|
@ -199,7 +206,6 @@ export class Human {
|
||||||
this.faceTriangulation = facemesh.triangulation;
|
this.faceTriangulation = facemesh.triangulation;
|
||||||
this.faceUVMap = facemesh.uvmap;
|
this.faceUVMap = facemesh.uvmap;
|
||||||
// include platform info
|
// include platform info
|
||||||
this.sysinfo = sysinfo.info();
|
|
||||||
this.#lastInputSum = 1;
|
this.#lastInputSum = 1;
|
||||||
this.#emit('create');
|
this.#emit('create');
|
||||||
}
|
}
|
||||||
|
@ -287,10 +293,9 @@ export class Human {
|
||||||
if (this.#firstRun) { // print version info on first run and check for correct backend setup
|
if (this.#firstRun) { // print version info on first run and check for correct backend setup
|
||||||
if (this.config.debug) log(`version: ${this.version}`);
|
if (this.config.debug) log(`version: ${this.version}`);
|
||||||
if (this.config.debug) log(`tfjs version: ${this.tf.version_core}`);
|
if (this.config.debug) log(`tfjs version: ${this.tf.version_core}`);
|
||||||
if (this.config.debug) log('platform:', this.sysinfo.platform);
|
if (this.config.debug) log('environment:', env.env);
|
||||||
if (this.config.debug) log('agent:', this.sysinfo.agent);
|
|
||||||
|
|
||||||
await this.#checkBackend(true);
|
await this.#checkBackend();
|
||||||
if (this.tf.ENV.flags.IS_BROWSER) {
|
if (this.tf.ENV.flags.IS_BROWSER) {
|
||||||
if (this.config.debug) log('configuration:', this.config);
|
if (this.config.debug) log('configuration:', this.config);
|
||||||
if (this.config.debug) log('tf flags:', this.tf.ENV.flags);
|
if (this.config.debug) log('tf flags:', this.tf.ENV.flags);
|
||||||
|
@ -316,8 +321,8 @@ export class Human {
|
||||||
|
|
||||||
// check if backend needs initialization if it changed
|
// check if backend needs initialization if it changed
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
#checkBackend = async (force = false) => {
|
#checkBackend = async () => {
|
||||||
if (this.config.backend && (this.config.backend.length > 0) && force || (this.tf.getBackend() !== this.config.backend)) {
|
if (this.#firstRun || (this.config.backend && (this.config.backend.length > 0) || (this.tf.getBackend() !== this.config.backend))) {
|
||||||
const timeStamp = now();
|
const timeStamp = now();
|
||||||
this.state = 'backend';
|
this.state = 'backend';
|
||||||
/* force backend reload
|
/* force backend reload
|
||||||
|
@ -343,7 +348,7 @@ export class Human {
|
||||||
this.config.backend = 'humangl';
|
this.config.backend = 'humangl';
|
||||||
}
|
}
|
||||||
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === 'webgl' || this.config.backend === 'humangl')) {
|
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === 'webgl' || this.config.backend === 'humangl')) {
|
||||||
log('override: backend set to webgl while running in nodejs');
|
log(`override: backend set to ${this.config.backend} while running in nodejs`);
|
||||||
this.config.backend = 'tensorflow';
|
this.config.backend = 'tensorflow';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,6 +415,9 @@ export class Human {
|
||||||
this.tf.enableProdMode();
|
this.tf.enableProdMode();
|
||||||
await this.tf.ready();
|
await this.tf.ready();
|
||||||
this.performance.backend = Math.trunc(now() - timeStamp);
|
this.performance.backend = Math.trunc(now() - timeStamp);
|
||||||
|
|
||||||
|
env.get(); // update env on backend init
|
||||||
|
this.env = env.env;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/**
|
|
||||||
* Helper function that returns basic system info
|
|
||||||
*/
|
|
||||||
export function info(): { platform: string, agent: string } {
|
|
||||||
let platform = '';
|
|
||||||
let agent = '';
|
|
||||||
if (typeof navigator !== 'undefined') {
|
|
||||||
const raw = navigator.userAgent.match(/\(([^()]+)\)/g);
|
|
||||||
if (raw && raw[0]) {
|
|
||||||
const platformMatch = raw[0].match(/\(([^()]+)\)/g);
|
|
||||||
platform = (platformMatch && platformMatch[0]) ? platformMatch[0].replace(/\(|\)/g, '') : '';
|
|
||||||
agent = navigator.userAgent.replace(raw[0], '');
|
|
||||||
if (platform[1]) agent = agent.replace(raw[1], '');
|
|
||||||
agent = agent.replace(/ /g, ' ');
|
|
||||||
}
|
|
||||||
} else if (typeof process !== 'undefined') {
|
|
||||||
platform = `${process.platform} ${process.arch}`;
|
|
||||||
agent = `NodeJS ${process.version}`;
|
|
||||||
}
|
|
||||||
return { platform, agent };
|
|
||||||
}
|
|
2047
test/build.log
2047
test/build.log
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -110,6 +110,7 @@
|
||||||
<h3>Variables</h3>
|
<h3>Variables</h3>
|
||||||
<ul class="tsd-index-list">
|
<ul class="tsd-index-list">
|
||||||
<li class="tsd-kind-variable"><a href="index.html#defaults" class="tsd-kind-icon">defaults</a></li>
|
<li class="tsd-kind-variable"><a href="index.html#defaults" class="tsd-kind-icon">defaults</a></li>
|
||||||
|
<li class="tsd-kind-variable"><a href="index.html#env" class="tsd-kind-icon">env</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
@ -131,7 +132,7 @@
|
||||||
<div class="tsd-signature tsd-kind-icon">Error<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>error<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></div>
|
<div class="tsd-signature tsd-kind-icon">Error<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>error<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></div>
|
||||||
<aside class="tsd-sources">
|
<aside class="tsd-sources">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L54">human.ts:54</a></li>
|
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L55">human.ts:55</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
<div class="tsd-comment tsd-typography">
|
<div class="tsd-comment tsd-typography">
|
||||||
|
@ -154,7 +155,7 @@
|
||||||
<div class="tsd-signature tsd-kind-icon">Events<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"create"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"load"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"image"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"result"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"warmup"</span></div>
|
<div class="tsd-signature tsd-kind-icon">Events<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"create"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"load"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"image"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"result"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"warmup"</span></div>
|
||||||
<aside class="tsd-sources">
|
<aside class="tsd-sources">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L49">human.ts:49</a></li>
|
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L50">human.ts:50</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
<div class="tsd-comment tsd-typography">
|
<div class="tsd-comment tsd-typography">
|
||||||
|
@ -191,7 +192,7 @@
|
||||||
<div class="tsd-signature tsd-kind-icon">Input<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">typeof </span><span class="tsd-signature-type">Image</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ImageData</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ImageBitmap</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLImageElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLMediaElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLVideoElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></div>
|
<div class="tsd-signature tsd-kind-icon">Input<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Tensor</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">typeof </span><span class="tsd-signature-type">Image</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ImageData</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ImageBitmap</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLImageElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLMediaElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLVideoElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">HTMLCanvasElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">OffscreenCanvas</span></div>
|
||||||
<aside class="tsd-sources">
|
<aside class="tsd-sources">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L40">human.ts:40</a></li>
|
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L41">human.ts:41</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
<div class="tsd-comment tsd-typography">
|
<div class="tsd-comment tsd-typography">
|
||||||
|
@ -206,7 +207,7 @@
|
||||||
<div class="tsd-signature tsd-kind-icon">Tensor<wbr>Flow<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">typeof </span><span class="tsd-signature-type">tf</span></div>
|
<div class="tsd-signature tsd-kind-icon">Tensor<wbr>Flow<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">typeof </span><span class="tsd-signature-type">tf</span></div>
|
||||||
<aside class="tsd-sources">
|
<aside class="tsd-sources">
|
||||||
<ul>
|
<ul>
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L59">human.ts:59</a></li>
|
<li>Defined in <a href="https://github.com/vladmandic/human/blob/main/src/human.ts#L60">human.ts:60</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
<div class="tsd-comment tsd-typography">
|
<div class="tsd-comment tsd-typography">
|
||||||
|
@ -233,10 +234,20 @@
|
||||||
</aside>
|
</aside>
|
||||||
<div class="tsd-comment tsd-typography">
|
<div class="tsd-comment tsd-typography">
|
||||||
<div class="lead">
|
<div class="lead">
|
||||||
<p><a href="https://github.com/vladmandic/human/blob/main/src/config.ts#L244">Default values</a> for {@Config}</p>
|
<p><a href="https://github.com/vladmandic/human/blob/main/src/config.ts#L244">See all default Config values...</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="tsd-panel tsd-member tsd-kind-variable">
|
||||||
|
<a name="env" class="tsd-anchor"></a>
|
||||||
|
<h3><span class="tsd-flag ts-flagConst">Const</span> env</h3>
|
||||||
|
<div class="tsd-signature tsd-kind-icon">env<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Env</span><span class="tsd-signature-symbol"> = ...</span></div>
|
||||||
|
<aside class="tsd-sources">
|
||||||
|
<ul>
|
||||||
|
<li>Defined in env.ts:31</li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
||||||
|
@ -333,6 +344,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -270,6 +270,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -276,6 +276,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -468,6 +468,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -449,6 +449,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -289,6 +289,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -243,6 +243,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -285,6 +285,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -243,6 +243,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -215,6 +215,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -215,6 +215,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -491,6 +491,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -544,6 +544,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -208,6 +208,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -345,6 +345,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -302,6 +302,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -285,6 +285,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -289,6 +289,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -318,6 +318,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -366,6 +366,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -230,6 +230,9 @@
|
||||||
<li class=" tsd-kind-variable">
|
<li class=" tsd-kind-variable">
|
||||||
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
<a href="../index.html#defaults" class="tsd-kind-icon">defaults</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-variable">
|
||||||
|
<a href="../index.html#env" class="tsd-kind-icon">env</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -209,7 +209,7 @@ export interface Config {
|
||||||
segmentation: Partial<SegmentationConfig>;
|
segmentation: Partial<SegmentationConfig>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* [Default values](https://github.com/vladmandic/human/blob/main/src/config.ts#L244) for {@Config}
|
* [See all default Config values...](https://github.com/vladmandic/human/blob/main/src/config.ts#L244)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
declare const config: Config;
|
declare const config: Config;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
export interface Env {
|
||||||
|
browser: undefined | boolean;
|
||||||
|
node: undefined | boolean;
|
||||||
|
worker: undefined | boolean;
|
||||||
|
platform: undefined | string;
|
||||||
|
agent: undefined | string;
|
||||||
|
backends: string[];
|
||||||
|
tfjs: {
|
||||||
|
version: undefined | string;
|
||||||
|
external: undefined | boolean;
|
||||||
|
};
|
||||||
|
wasm: {
|
||||||
|
supported: undefined | boolean;
|
||||||
|
simd: undefined | boolean;
|
||||||
|
multithread: undefined | boolean;
|
||||||
|
};
|
||||||
|
webgl: {
|
||||||
|
supported: undefined | boolean;
|
||||||
|
version: undefined | string;
|
||||||
|
renderer: undefined | string;
|
||||||
|
};
|
||||||
|
webgpu: {
|
||||||
|
supported: undefined | boolean;
|
||||||
|
adapter: undefined | string;
|
||||||
|
};
|
||||||
|
kernels: string[];
|
||||||
|
}
|
||||||
|
export declare const env: Env;
|
||||||
|
export declare function cpuinfo(): void;
|
||||||
|
export declare function get(): Promise<void>;
|
|
@ -7,10 +7,12 @@ import * as tf from '../dist/tfjs.esm.js';
|
||||||
import * as facemesh from './blazeface/facemesh';
|
import * as facemesh from './blazeface/facemesh';
|
||||||
import * as image from './image/image';
|
import * as image from './image/image';
|
||||||
import * as draw from './draw/draw';
|
import * as draw from './draw/draw';
|
||||||
|
import * as env from './env';
|
||||||
import { Tensor, GraphModel } from './tfjs/types';
|
import { Tensor, GraphModel } from './tfjs/types';
|
||||||
export * from './config';
|
export * from './config';
|
||||||
export * from './result';
|
export * from './result';
|
||||||
export type { DrawOptions } from './draw/draw';
|
export type { DrawOptions } from './draw/draw';
|
||||||
|
export { env } from './env';
|
||||||
/** Defines all possible input types for **Human** detection
|
/** Defines all possible input types for **Human** detection
|
||||||
* @typedef Input Type
|
* @typedef Input Type
|
||||||
*/
|
*/
|
||||||
|
@ -72,6 +74,10 @@ export declare class Human {
|
||||||
* - Can be embedded or externally provided
|
* - Can be embedded or externally provided
|
||||||
*/
|
*/
|
||||||
tf: TensorFlow;
|
tf: TensorFlow;
|
||||||
|
/**
|
||||||
|
* Object containing environment information used for diagnostics
|
||||||
|
*/
|
||||||
|
env: env.Env;
|
||||||
/** Draw helper classes that can draw detected objects on canvas using specified draw
|
/** Draw helper classes that can draw detected objects on canvas using specified draw
|
||||||
* - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method
|
* - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method
|
||||||
* - face: draw detected faces
|
* - face: draw detected faces
|
||||||
|
@ -120,11 +126,6 @@ export declare class Human {
|
||||||
faceTriangulation: typeof facemesh.triangulation;
|
faceTriangulation: typeof facemesh.triangulation;
|
||||||
/** Refernce UV map of 468 values, used for 3D mapping of the face mesh */
|
/** Refernce UV map of 468 values, used for 3D mapping of the face mesh */
|
||||||
faceUVMap: typeof facemesh.uvmap;
|
faceUVMap: typeof facemesh.uvmap;
|
||||||
/** Platform and agent information detected by Human */
|
|
||||||
sysinfo: {
|
|
||||||
platform: string;
|
|
||||||
agent: string;
|
|
||||||
};
|
|
||||||
/** Performance object that contains values for all recently performed operations */
|
/** Performance object that contains values for all recently performed operations */
|
||||||
performance: Record<string, number>;
|
performance: Record<string, number>;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
/**
|
|
||||||
* Helper function that returns basic system info
|
|
||||||
*/
|
|
||||||
export declare function info(): {
|
|
||||||
platform: string;
|
|
||||||
agent: string;
|
|
||||||
};
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit ec49beb9f19c0abde3e62b24ba2c7749ef54c9aa
|
Subproject commit ee12bda3113d3d893c898a9827f9c174d4058fb8
|
Loading…
Reference in New Issue