enable webworker detection

pull/134/head
Vladimir Mandic 2021-04-25 07:51:01 -04:00
parent a8c9eafc97
commit 05df95fe4f
17 changed files with 68 additions and 26 deletions

View File

@ -1,6 +1,6 @@
# @vladmandic/human
Version: **1.7.0**
Version: **1.7.1**
Description: **Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gesture Recognition**
Author: **Vladimir Mandic <mandic00@live.com>**
@ -9,8 +9,13 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
## Changelog
### **HEAD -> main** 2021/04/24 mandic00@live.com
### **1.7.1** 2021/04/25 mandic00@live.com
### **origin/main** 2021/04/24 mandic00@live.com
- enable cross origin isolation
- rewrite posenet decoder
- remove efficientpose
- major version rebuild

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/human.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/human.js vendored

File diff suppressed because one or more lines are too long

4
dist/human.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -202,3 +202,37 @@
2021-04-24 18:43:26 INFO:  Generate types: ["src/human.ts"]
2021-04-24 18:43:31 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
2021-04-24 18:43:31 INFO:  Generate TypeDocs: ["src/human.ts"]
2021-04-25 07:49:35 INFO:  @vladmandic/human version 1.7.0
2021-04-25 07:49:35 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.0.0
2021-04-25 07:49:35 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true,"sourcemap":true,"bundle":true,"metafile":true,"target":"es2018"}
2021-04-25 07:49:36 STATE: Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":733,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:49:36 STATE: Build for: node type: node: {"imports":36,"importBytes":521379,"outputBytes":296354,"outputFiles":"dist/human.node.js"}
2021-04-25 07:49:36 STATE: Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":737,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:49:36 STATE: Build for: nodeGPU type: node: {"imports":36,"importBytes":521383,"outputBytes":296362,"outputFiles":"dist/human.node-gpu.js"}
2021-04-25 07:49:36 STATE: Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":783,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:49:36 STATE: Build for: nodeWASM type: node: {"imports":36,"importBytes":521429,"outputBytes":296406,"outputFiles":"dist/human.node-wasm.js"}
2021-04-25 07:49:36 STATE: Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:49:36 STATE: Build for: browserNoBundle type: esm: {"imports":36,"importBytes":522040,"outputBytes":296501,"outputFiles":"dist/human.esm-nobundle.js"}
2021-04-25 07:49:37 STATE: Build for: browserBundle type: tfjs: {"modules":1267,"moduleBytes":4085087,"imports":7,"importBytes":2488,"outputBytes":1101728,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:49:37 STATE: Build for: browserBundle type: iife: {"imports":36,"importBytes":1622374,"outputBytes":1394611,"outputFiles":"dist/human.js"}
2021-04-25 07:49:38 STATE: Build for: browserBundle type: esm: {"imports":36,"importBytes":1622374,"outputBytes":1394569,"outputFiles":"dist/human.esm.js"}
2021-04-25 07:49:38 INFO:  Generate types: ["src/human.ts"]
2021-04-25 07:49:43 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
2021-04-25 07:49:43 INFO:  Generate TypeDocs: ["src/human.ts"]
2021-04-25 07:50:15 INFO:  @vladmandic/human version 1.7.1
2021-04-25 07:50:15 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.0.0
2021-04-25 07:50:15 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true,"sourcemap":true,"bundle":true,"metafile":true,"target":"es2018"}
2021-04-25 07:50:15 STATE: Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":733,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:50:15 STATE: Build for: node type: node: {"imports":36,"importBytes":521379,"outputBytes":296354,"outputFiles":"dist/human.node.js"}
2021-04-25 07:50:15 STATE: Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":737,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:50:15 STATE: Build for: nodeGPU type: node: {"imports":36,"importBytes":521383,"outputBytes":296362,"outputFiles":"dist/human.node-gpu.js"}
2021-04-25 07:50:15 STATE: Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":783,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:50:15 STATE: Build for: nodeWASM type: node: {"imports":36,"importBytes":521429,"outputBytes":296406,"outputFiles":"dist/human.node-wasm.js"}
2021-04-25 07:50:15 STATE: Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:50:15 STATE: Build for: browserNoBundle type: esm: {"imports":36,"importBytes":522040,"outputBytes":296501,"outputFiles":"dist/human.esm-nobundle.js"}
2021-04-25 07:50:16 STATE: Build for: browserBundle type: tfjs: {"modules":1267,"moduleBytes":4085087,"imports":7,"importBytes":2488,"outputBytes":1101728,"outputFiles":"dist/tfjs.esm.js"}
2021-04-25 07:50:16 STATE: Build for: browserBundle type: iife: {"imports":36,"importBytes":1622374,"outputBytes":1394611,"outputFiles":"dist/human.js"}
2021-04-25 07:50:17 STATE: Build for: browserBundle type: esm: {"imports":36,"importBytes":1622374,"outputBytes":1394569,"outputFiles":"dist/human.esm.js"}
2021-04-25 07:50:17 INFO:  Generate types: ["src/human.ts"]
2021-04-25 07:50:22 INFO:  Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
2021-04-25 07:50:22 INFO:  Generate TypeDocs: ["src/human.ts"]

View File

@ -1,3 +1,5 @@
// paper: https://ai.googleblog.com/2020/08/on-device-real-time-body-pose-tracking.html
import { log, join } from '../helpers';
import * as tf from '../../dist/tfjs.esm.js';
import * as profile from '../profile';
@ -26,9 +28,6 @@ export async function predict(image, config) {
let points;
if (!config.profile) { // run through profiler or just execute
const resT = await model.predict(normalize);
// const segmentationT = resT.find((t) => (t.size === 16384))?.squeeze();
// const segmentation = segmentationT.arraySync(); // array 128 x 128
// segmentationT.dispose();
points = resT.find((t) => (t.size === 195 || t.size === 155)).dataSync(); // order of output tensors may change between models, full has 195 and upper has 155 items
resT.forEach((t) => t.dispose());
} else {

View File

@ -304,6 +304,9 @@ export class Human {
*/
if (this.config.backend && this.config.backend.length > 0) {
// @ts-ignore ignore missing type for WorkerGlobalScope as that is the point
if (typeof window === 'undefined' && typeof WorkerGlobalScope !== 'undefined' && this.config.debug) log('running inside web worker');
// force browser vs node backend
if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === 'tensorflow') this.config.backend = 'webgl';
if (this.tf.ENV.flags.IS_NODE && (this.config.backend === 'webgl' || this.config.backend === 'humangl')) this.config.backend = 'tensorflow';
@ -378,9 +381,10 @@ export class Human {
if (this.config.scoped) this.tf.engine().startScope();
this.analyze('Start Scope:');
// disable video optimization for inputs of type image
// disable video optimization for inputs of type image, but skip if inside worker thread
let previousVideoOptimized;
if (input && this.config.videoOptimized && (
// @ts-ignore ignore missing type for WorkerGlobalScope as that is the point
if (input && this.config.videoOptimized && (typeof window !== 'undefined') && (typeof WorkerGlobalScope !== 'undefined') && (
(typeof HTMLImageElement !== 'undefined' && input instanceof HTMLImageElement)
|| (typeof Image !== 'undefined' && input instanceof Image)
|| (typeof ImageData !== 'undefined' && input instanceof ImageData)

2
wiki

@ -1 +1 @@
Subproject commit e06119f8538250b84e4ff4caed40746b749a3531
Subproject commit 3b81af15f2560de5c06f20cbd8de57caf62682f2