mirror of https://github.com/vladmandic/human
code cleanup and enable minification
parent
44ae1b517a
commit
61c4d7ae6d
10
config.js
10
config.js
|
@ -144,16 +144,6 @@ export default {
|
|||
modelType: 'MobileNet', // Human includes MobileNet version, but you can switch to ResNet
|
||||
},
|
||||
|
||||
pose: { // TBD: not currently in use
|
||||
enabled: false,
|
||||
scoreThreshold: 0.6, // threshold for deciding when to remove boxes based on score
|
||||
// in non-maximum suppression
|
||||
iouThreshold: 0.3, // threshold for deciding whether boxes overlap too much
|
||||
// in non-maximum suppression
|
||||
modelPath: '../models/blazepose.json',
|
||||
inputSize: 256, // fixed value
|
||||
},
|
||||
|
||||
hand: {
|
||||
enabled: true,
|
||||
rotation: false, // use best-guess rotated hand image or just box with rotation as-is
|
||||
|
|
|
@ -512,7 +512,8 @@ function setupMenu() {
|
|||
}
|
||||
|
||||
async function main() {
|
||||
log('demo starting ...');
|
||||
log('Demo starting ...');
|
||||
log('Browser:', navigator?.userAgent);
|
||||
setupMenu();
|
||||
document.getElementById('log').innerText = `Human: version ${human.version}`;
|
||||
if (ui.modelsPreload && !ui.useWorker) {
|
||||
|
@ -526,7 +527,7 @@ async function main() {
|
|||
status('human: ready');
|
||||
document.getElementById('loader').style.display = 'none';
|
||||
document.getElementById('play').style.display = 'block';
|
||||
log('ready');
|
||||
log('Demo ready...');
|
||||
}
|
||||
|
||||
window.onload = main;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="content-type">
|
||||
<meta content="text/html">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition; Author: Vladimir Mandic <https://github.com/vladmandic>">
|
||||
<meta name="description" content="Human: 3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition; Author: Vladimir Mandic <https://github.com/vladmandic>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.6, minimum-scale=0.3, maximum-scale=3.0, shrink-to-fit=yes, user-scalable=yes">
|
||||
<meta name="theme-color" content="#000000"/>
|
||||
<meta name="application-name" content="Human">
|
||||
|
@ -39,7 +39,7 @@
|
|||
.canvas { margin: 0 auto; }
|
||||
.bench { position: absolute; right: 0; bottom: 0; }
|
||||
.compare-image { width: 200px; position: absolute; top: 150px; left: 30px; box-shadow: 0 0 2px 2px black; background: black; }
|
||||
.loader { width: 300px; height: 300px; border: 3px solid transparent; border-radius: 50%; border-top: 4px solid #f15e41; animation: spin 4s linear infinite; position: absolute; top: 30%; left: 50%; margin-left: -150px; z-index: 15; }
|
||||
.loader { width: 300px; height: 300px; border: 3px solid transparent; border-radius: 50%; border-top: 4px solid #f15e41; animation: spin 4s linear infinite; position: absolute; bottom: 25%; left: 50%; margin-left: -150px; z-index: 15; }
|
||||
.loader::before, .loader::after { content: ""; position: absolute; top: 6px; bottom: 6px; left: 6px; right: 6px; border-radius: 50%; border: 4px solid transparent; }
|
||||
.loader::before { border-top-color: #bad375; animation: 3s spin linear infinite; }
|
||||
.loader::after { border-top-color: #26a9e0; animation: spin 1.5s linear infinite; }
|
||||
|
|
31
src/human.js
31
src/human.js
|
@ -7,7 +7,6 @@ import * as gender from './gender/gender.js';
|
|||
import * as emotion from './emotion/emotion.js';
|
||||
import * as embedding from './embedding/embedding.js';
|
||||
import * as posenet from './posenet/posenet.js';
|
||||
import * as blazepose from './blazepose/blazepose.js';
|
||||
import * as handpose from './handpose/handpose.js';
|
||||
import * as gesture from './gesture/gesture.js';
|
||||
import * as image from './image.js';
|
||||
|
@ -120,7 +119,6 @@ class Human {
|
|||
log('configuration:', this.config);
|
||||
log('tf flags:', tf.ENV.flags);
|
||||
}
|
||||
this.firstRun = false;
|
||||
}
|
||||
|
||||
if (this.config.async) {
|
||||
|
@ -132,7 +130,6 @@ class Human {
|
|||
this.models.embedding,
|
||||
this.models.posenet,
|
||||
this.models.handpose,
|
||||
this.models.blazepose,
|
||||
] = await Promise.all([
|
||||
this.models.facemesh || (this.config.face.enabled ? facemesh.load(this.config) : null),
|
||||
this.models.age || ((this.config.face.enabled && this.config.face.age.enabled) ? age.load(this.config) : null),
|
||||
|
@ -141,7 +138,6 @@ class Human {
|
|||
this.models.embedding || ((this.config.face.enabled && this.config.face.embedding.enabled) ? embedding.load(this.config) : null),
|
||||
this.models.posenet || (this.config.body.enabled ? posenet.load(this.config) : null),
|
||||
this.models.handpose || (this.config.hand.enabled ? handpose.load(this.config) : null),
|
||||
this.models.blazepose || (this.config.pose.enabled ? blazepose.load(this.config) : null),
|
||||
]);
|
||||
} else {
|
||||
if (this.config.face.enabled && !this.models.facemesh) this.models.facemesh = await facemesh.load(this.config);
|
||||
|
@ -151,8 +147,13 @@ class Human {
|
|||
if (this.config.face.enabled && this.config.face.embedding.enabled && !this.models.embedding) this.models.embedding = await embedding.load(this.config);
|
||||
if (this.config.body.enabled && !this.models.posenet) this.models.posenet = await posenet.load(this.config);
|
||||
if (this.config.hand.enabled && !this.models.handpose) this.models.handpose = await handpose.load(this.config);
|
||||
if (this.config.pose.enabled && !this.models.blazepose) this.models.blazepose = await blazepose.load(this.config);
|
||||
}
|
||||
|
||||
if (this.firstRun) {
|
||||
log('tf engine state:', tf.engine().state.numBytes, 'bytes', tf.engine().state.numTensors, 'tensors');
|
||||
this.firstRun = false;
|
||||
}
|
||||
|
||||
const current = Math.trunc(now() - timeStamp);
|
||||
if (current > (this.perf.load || 0)) this.perf.load = current;
|
||||
}
|
||||
|
@ -348,7 +349,6 @@ class Human {
|
|||
}
|
||||
|
||||
let poseRes;
|
||||
let blazeposeRes;
|
||||
let handRes;
|
||||
let faceRes;
|
||||
|
||||
|
@ -397,19 +397,6 @@ class Human {
|
|||
}
|
||||
this.analyze('End Body:');
|
||||
|
||||
// run posenet
|
||||
this.analyze('Start Pose:');
|
||||
if (this.config.async) {
|
||||
blazeposeRes = this.config.pose.enabled ? blazepose.predict(process.tensor, this.config) : [];
|
||||
if (this.perf.pose) delete this.perf.pose;
|
||||
} else {
|
||||
this.state = 'run:pose';
|
||||
timeStamp = now();
|
||||
blazeposeRes = this.config.pose.enabled ? await blazepose.predict(process.tensor, this.config) : [];
|
||||
this.perf.pose = Math.trunc(now() - timeStamp);
|
||||
}
|
||||
this.analyze('End Pose:');
|
||||
|
||||
// run handpose
|
||||
this.analyze('Start Hand:');
|
||||
if (this.config.async) {
|
||||
|
@ -425,7 +412,7 @@ class Human {
|
|||
|
||||
// if async wait for results
|
||||
if (this.config.async) {
|
||||
[faceRes, poseRes, blazeposeRes, handRes] = await Promise.all([faceRes, poseRes, blazeposeRes, handRes]);
|
||||
[faceRes, poseRes, handRes] = await Promise.all([faceRes, poseRes, handRes]);
|
||||
}
|
||||
process.tensor.dispose();
|
||||
|
||||
|
@ -442,7 +429,7 @@ class Human {
|
|||
|
||||
this.perf.total = Math.trunc(now() - timeStart);
|
||||
this.state = 'idle';
|
||||
resolve({ face: faceRes, body: poseRes, hand: handRes, pose: blazeposeRes, gesture: gestureRes, performance: this.perf, canvas: process.canvas });
|
||||
resolve({ face: faceRes, body: poseRes, hand: handRes, gesture: gestureRes, performance: this.perf, canvas: process.canvas });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -504,7 +491,7 @@ class Human {
|
|||
else res = await this.warmupCanvas();
|
||||
this.config.videoOptimized = video;
|
||||
const t1 = now();
|
||||
log('Warmup', this.config.warmup, (t1 - t0), res);
|
||||
log('Warmup', this.config.warmup, Math.round(t1 - t0), 'ms', res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit f31fa056967450ba8427bb2768db92cbe9b8cd8e
|
||||
Subproject commit 0ce580ced2bdf5f2f231dfae6c3d3f90053af6f6
|
Loading…
Reference in New Issue