mirror of https://github.com/vladmandic/human
fix for conditional model loading
parent
2faa1ca945
commit
8a8e943a72
|
@ -387,6 +387,7 @@ async function main() {
|
|||
log('Human: demo starting ...');
|
||||
setupMenu();
|
||||
document.getElementById('log').innerText = `Human: version ${human.version} TensorFlow/JS: version ${human.tf.version_core}`;
|
||||
human.tf.ENV.set('WEBGL_FORCE_F16_TEXTURES', true);
|
||||
// this is not required, just pre-loads all models
|
||||
if (ui.modelsPreload) {
|
||||
status('loading');
|
||||
|
|
|
@ -66883,7 +66883,7 @@ var require_gender = __commonJS((exports) => {
|
|||
const confidence = Math.trunc(200 * Math.abs(data2[0] - 0.5)) / 100;
|
||||
if (confidence > config2.face.gender.minConfidence) {
|
||||
obj.gender = data2[0] <= 0.5 ? "female" : "male";
|
||||
obj.confidence = confidence;
|
||||
obj.confidence = Math.min(0.99, confidence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97910,7 +97910,7 @@ var config_default = {
|
|||
}
|
||||
}
|
||||
};
|
||||
var version3 = "0.8.6";
|
||||
var version3 = "0.8.7";
|
||||
const disableSkipFrames = {
|
||||
face: {detector: {skipFrames: 0}, age: {skipFrames: 0}, gender: {skipFrames: 0}, emotion: {skipFrames: 0}},
|
||||
hand: {skipFrames: 0}
|
||||
|
@ -98013,33 +98013,33 @@ class Human {
|
|||
}
|
||||
if (this.config.async) {
|
||||
[
|
||||
this.models.facemesh,
|
||||
this.models.age,
|
||||
this.models.gender,
|
||||
this.models.emotion,
|
||||
this.models.facemesh,
|
||||
this.models.posenet,
|
||||
this.models.handpose
|
||||
] = await Promise.all([
|
||||
this.models.age || (this.config.face.age.enabled ? age.load(this.config) : null),
|
||||
this.models.gender || (this.config.face.gender.enabled ? gender.load(this.config) : null),
|
||||
this.models.emotion || (this.config.face.emotion.enabled ? emotion.load(this.config) : null),
|
||||
this.models.facemesh || (this.config.face.enabled ? facemesh.load(this.config.face) : null),
|
||||
this.models.age || (this.config.face.enabled && this.config.face.age.enabled ? age.load(this.config) : null),
|
||||
this.models.gender || (this.config.face.enabled && this.config.face.gender.enabled ? gender.load(this.config) : null),
|
||||
this.models.emotion || (this.config.face.enabled && this.config.face.emotion.enabled ? emotion.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.hand) : null)
|
||||
]);
|
||||
} else {
|
||||
if (this.config.face.enabled && !this.models.facemesh)
|
||||
this.models.facemesh = await facemesh.load(this.config.face);
|
||||
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.hand);
|
||||
if (this.config.face.enabled && this.config.face.age.enabled && !this.models.age)
|
||||
this.models.age = await age.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.gender.enabled && !this.models.gender)
|
||||
this.models.gender = await gender.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion)
|
||||
this.models.emotion = await emotion.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.hand);
|
||||
}
|
||||
const current = Math.trunc(now2() - timeStamp2);
|
||||
if (current > (this.perf.load || 0))
|
||||
|
@ -99122,6 +99122,7 @@ async function main() {
|
|||
log2("Human: demo starting ...");
|
||||
setupMenu();
|
||||
document.getElementById("log").innerText = `Human: version ${human.version} TensorFlow/JS: version ${human.tf.version_core}`;
|
||||
human.tf.ENV.set("WEBGL_FORCE_F16_TEXTURES", true);
|
||||
if (ui.modelsPreload) {
|
||||
status("loading");
|
||||
await human.load(userConfig);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"inputs": {
|
||||
"demo/browser.js": {
|
||||
"bytes": 18768,
|
||||
"bytes": 18822,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/human.esm.js"
|
||||
|
@ -23,7 +23,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"bytes": 3443154,
|
||||
"bytes": 3443254,
|
||||
"imports": []
|
||||
}
|
||||
},
|
||||
|
@ -31,13 +31,13 @@
|
|||
"dist/demo-browser-index.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 5410315
|
||||
"bytes": 5410764
|
||||
},
|
||||
"dist/demo-browser-index.js": {
|
||||
"imports": [],
|
||||
"inputs": {
|
||||
"dist/human.esm.js": {
|
||||
"bytesInOutput": 3432471
|
||||
"bytesInOutput": 3432571
|
||||
},
|
||||
"demo/draw.js": {
|
||||
"bytesInOutput": 8898
|
||||
|
@ -46,10 +46,10 @@
|
|||
"bytesInOutput": 13813
|
||||
},
|
||||
"demo/browser.js": {
|
||||
"bytesInOutput": 16481
|
||||
"bytesInOutput": 16535
|
||||
}
|
||||
},
|
||||
"bytes": 3471785
|
||||
"bytes": 3471939
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66920,7 +66920,7 @@ var require_gender = __commonJS((exports) => {
|
|||
const confidence = Math.trunc(200 * Math.abs(data2[0] - 0.5)) / 100;
|
||||
if (confidence > config2.face.gender.minConfidence) {
|
||||
obj.gender = data2[0] <= 0.5 ? "female" : "male";
|
||||
obj.confidence = confidence;
|
||||
obj.confidence = Math.min(0.99, confidence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98285,7 +98285,7 @@ var config_default = {
|
|||
};
|
||||
|
||||
// package.json
|
||||
var version3 = "0.8.6";
|
||||
var version3 = "0.8.7";
|
||||
|
||||
// src/human.js
|
||||
const disableSkipFrames = {
|
||||
|
@ -98390,33 +98390,33 @@ class Human {
|
|||
}
|
||||
if (this.config.async) {
|
||||
[
|
||||
this.models.facemesh,
|
||||
this.models.age,
|
||||
this.models.gender,
|
||||
this.models.emotion,
|
||||
this.models.facemesh,
|
||||
this.models.posenet,
|
||||
this.models.handpose
|
||||
] = await Promise.all([
|
||||
this.models.age || (this.config.face.age.enabled ? age.load(this.config) : null),
|
||||
this.models.gender || (this.config.face.gender.enabled ? gender.load(this.config) : null),
|
||||
this.models.emotion || (this.config.face.emotion.enabled ? emotion.load(this.config) : null),
|
||||
this.models.facemesh || (this.config.face.enabled ? facemesh.load(this.config.face) : null),
|
||||
this.models.age || (this.config.face.enabled && this.config.face.age.enabled ? age.load(this.config) : null),
|
||||
this.models.gender || (this.config.face.enabled && this.config.face.gender.enabled ? gender.load(this.config) : null),
|
||||
this.models.emotion || (this.config.face.enabled && this.config.face.emotion.enabled ? emotion.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.hand) : null)
|
||||
]);
|
||||
} else {
|
||||
if (this.config.face.enabled && !this.models.facemesh)
|
||||
this.models.facemesh = await facemesh.load(this.config.face);
|
||||
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.hand);
|
||||
if (this.config.face.enabled && this.config.face.age.enabled && !this.models.age)
|
||||
this.models.age = await age.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.gender.enabled && !this.models.gender)
|
||||
this.models.gender = await gender.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion)
|
||||
this.models.emotion = await emotion.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.hand);
|
||||
}
|
||||
const current = Math.trunc(now2() - timeStamp);
|
||||
if (current > (this.perf.load || 0))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12527,7 +12527,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/gender/gender.js": {
|
||||
"bytes": 3193,
|
||||
"bytes": 3209,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/tf.js"
|
||||
|
@ -12600,7 +12600,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytes": 14460,
|
||||
"bytes": 14550,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/tf.js"
|
||||
|
@ -12695,7 +12695,7 @@
|
|||
"dist/human.esm.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 5460036
|
||||
"bytes": 5460397
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"imports": [],
|
||||
|
@ -12755,7 +12755,7 @@
|
|||
"bytesInOutput": 1826
|
||||
},
|
||||
"src/gender/gender.js": {
|
||||
"bytesInOutput": 2980
|
||||
"bytesInOutput": 2996
|
||||
},
|
||||
"src/emotion/emotion.js": {
|
||||
"bytesInOutput": 2697
|
||||
|
@ -13433,13 +13433,13 @@
|
|||
"bytesInOutput": 24
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytesInOutput": 12036
|
||||
"bytesInOutput": 12120
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytesInOutput": 0
|
||||
}
|
||||
},
|
||||
"bytes": 3443154
|
||||
"bytes": 3443254
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ async function predict(image, config) {
|
|||
const confidence = Math.trunc(200 * Math.abs((data[0] - 0.5))) / 100;
|
||||
if (confidence > config.face.gender.minConfidence) {
|
||||
obj.gender = data[0] <= 0.5 ? 'female' : 'male';
|
||||
obj.confidence = confidence;
|
||||
obj.confidence = Math.min(0.99, confidence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
src/human.js
12
src/human.js
|
@ -123,27 +123,27 @@ class Human {
|
|||
}
|
||||
if (this.config.async) {
|
||||
[
|
||||
this.models.facemesh,
|
||||
this.models.age,
|
||||
this.models.gender,
|
||||
this.models.emotion,
|
||||
this.models.facemesh,
|
||||
this.models.posenet,
|
||||
this.models.handpose,
|
||||
] = await Promise.all([
|
||||
this.models.age || (this.config.face.age.enabled ? age.load(this.config) : null),
|
||||
this.models.gender || (this.config.face.gender.enabled ? gender.load(this.config) : null),
|
||||
this.models.emotion || (this.config.face.emotion.enabled ? emotion.load(this.config) : null),
|
||||
this.models.facemesh || (this.config.face.enabled ? facemesh.load(this.config.face) : null),
|
||||
this.models.age || ((this.config.face.enabled && this.config.face.age.enabled) ? age.load(this.config) : null),
|
||||
this.models.gender || ((this.config.face.enabled && this.config.face.gender.enabled) ? gender.load(this.config) : null),
|
||||
this.models.emotion || ((this.config.face.enabled && this.config.face.emotion.enabled) ? emotion.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.hand) : null),
|
||||
]);
|
||||
} else {
|
||||
if (this.config.face.enabled && !this.models.facemesh) this.models.facemesh = await facemesh.load(this.config.face);
|
||||
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.hand);
|
||||
if (this.config.face.enabled && this.config.face.age.enabled && !this.models.age) this.models.age = await age.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.gender.enabled && !this.models.gender) this.models.gender = await gender.load(this.config);
|
||||
if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion) this.models.emotion = await emotion.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.hand);
|
||||
}
|
||||
const current = Math.trunc(now() - timeStamp);
|
||||
if (current > (this.perf.load || 0)) this.perf.load = current;
|
||||
|
|
Loading…
Reference in New Issue