mirror of https://github.com/vladmandic/human
modularize pipeline models
parent
4ef898b01a
commit
c688254269
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"bytes": 1783928,
|
||||
"bytes": 1784266,
|
||||
"imports": []
|
||||
}
|
||||
},
|
||||
|
@ -38,14 +38,14 @@
|
|||
"dist/demo-browser-index.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2678104
|
||||
"bytes": 2678448
|
||||
},
|
||||
"dist/demo-browser-index.js": {
|
||||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {
|
||||
"dist/human.esm.js": {
|
||||
"bytesInOutput": 1776683
|
||||
"bytesInOutput": 1777021
|
||||
},
|
||||
"demo/draw.js": {
|
||||
"bytesInOutput": 7668
|
||||
|
@ -60,7 +60,7 @@
|
|||
"bytesInOutput": 19407
|
||||
}
|
||||
},
|
||||
"bytes": 1830418
|
||||
"bytes": 1830756
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
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
|
@ -179,7 +179,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytes": 2456,
|
||||
"bytes": 2720,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -227,8 +227,8 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"bytes": 3306,
|
||||
"src/gesture/gesture.js": {
|
||||
"bytes": 2981,
|
||||
"imports": []
|
||||
},
|
||||
"src/hand/anchors.js": {
|
||||
|
@ -269,7 +269,7 @@
|
|||
]
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytes": 3075,
|
||||
"bytes": 3187,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -290,7 +290,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytes": 16049,
|
||||
"bytes": 16057,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -317,7 +317,7 @@
|
|||
"path": "src/hand/handpose.js"
|
||||
},
|
||||
{
|
||||
"path": "src/gesture.js"
|
||||
"path": "src/gesture/gesture.js"
|
||||
},
|
||||
{
|
||||
"path": "src/image.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.esm.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2582694
|
||||
"bytes": 2583057
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"imports": [],
|
||||
|
@ -381,7 +381,7 @@
|
|||
"bytesInOutput": 9453
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytesInOutput": 1885
|
||||
"bytesInOutput": 2123
|
||||
},
|
||||
"src/profile.js": {
|
||||
"bytesInOutput": 860
|
||||
|
@ -441,9 +441,9 @@
|
|||
"bytesInOutput": 127032
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytesInOutput": 1829
|
||||
"bytesInOutput": 1929
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"src/gesture/gesture.js": {
|
||||
"bytesInOutput": 2255
|
||||
},
|
||||
"src/imagefx.js": {
|
||||
|
@ -471,7 +471,7 @@
|
|||
"bytesInOutput": 22
|
||||
}
|
||||
},
|
||||
"bytes": 1783928
|
||||
"bytes": 1784266
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -179,7 +179,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytes": 2456,
|
||||
"bytes": 2720,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -227,8 +227,8 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"bytes": 3306,
|
||||
"src/gesture/gesture.js": {
|
||||
"bytes": 2981,
|
||||
"imports": []
|
||||
},
|
||||
"src/hand/anchors.js": {
|
||||
|
@ -269,7 +269,7 @@
|
|||
]
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytes": 3075,
|
||||
"bytes": 3187,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -290,7 +290,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytes": 16049,
|
||||
"bytes": 16057,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -317,7 +317,7 @@
|
|||
"path": "src/hand/handpose.js"
|
||||
},
|
||||
{
|
||||
"path": "src/gesture.js"
|
||||
"path": "src/gesture/gesture.js"
|
||||
},
|
||||
{
|
||||
"path": "src/image.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2549656
|
||||
"bytes": 2550003
|
||||
},
|
||||
"dist/human.js": {
|
||||
"imports": [],
|
||||
|
@ -379,7 +379,7 @@
|
|||
"bytesInOutput": 9431
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytesInOutput": 1868
|
||||
"bytesInOutput": 2101
|
||||
},
|
||||
"src/profile.js": {
|
||||
"bytesInOutput": 850
|
||||
|
@ -439,9 +439,9 @@
|
|||
"bytesInOutput": 127032
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytesInOutput": 1814
|
||||
"bytesInOutput": 1910
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"src/gesture/gesture.js": {
|
||||
"bytesInOutput": 2235
|
||||
},
|
||||
"src/imagefx.js": {
|
||||
|
@ -469,7 +469,7 @@
|
|||
"bytesInOutput": 22
|
||||
}
|
||||
},
|
||||
"bytes": 1783239
|
||||
"bytes": 1783568
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
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
|
@ -179,7 +179,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytes": 2456,
|
||||
"bytes": 2720,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -227,8 +227,8 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"bytes": 3306,
|
||||
"src/gesture/gesture.js": {
|
||||
"bytes": 2981,
|
||||
"imports": []
|
||||
},
|
||||
"src/hand/anchors.js": {
|
||||
|
@ -269,7 +269,7 @@
|
|||
]
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytes": 3075,
|
||||
"bytes": 3187,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -290,7 +290,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"src/human.js": {
|
||||
"bytes": 16049,
|
||||
"bytes": 16057,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -317,7 +317,7 @@
|
|||
"path": "src/hand/handpose.js"
|
||||
},
|
||||
{
|
||||
"path": "src/gesture.js"
|
||||
"path": "src/gesture/gesture.js"
|
||||
},
|
||||
{
|
||||
"path": "src/image.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.node-gpu.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 685654
|
||||
"bytes": 686025
|
||||
},
|
||||
"dist/human.node-gpu.js": {
|
||||
"imports": [],
|
||||
|
@ -382,7 +382,7 @@
|
|||
"bytesInOutput": 9509
|
||||
},
|
||||
"src/face/facemesh.js": {
|
||||
"bytesInOutput": 1930
|
||||
"bytesInOutput": 2168
|
||||
},
|
||||
"src/profile.js": {
|
||||
"bytesInOutput": 860
|
||||
|
@ -442,9 +442,9 @@
|
|||
"bytesInOutput": 127034
|
||||
},
|
||||
"src/hand/handpose.js": {
|
||||
"bytesInOutput": 1873
|
||||
"bytesInOutput": 1973
|
||||
},
|
||||
"src/gesture.js": {
|
||||
"src/gesture/gesture.js": {
|
||||
"bytesInOutput": 2259
|
||||
},
|
||||
"src/imagefx.js": {
|
||||
|
@ -469,7 +469,7 @@
|
|||
"bytesInOutput": 21
|
||||
}
|
||||
},
|
||||
"bytes": 249907
|
||||
"bytes": 250245
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,17 +38,18 @@ class MediaPipeFaceMesh {
|
|||
}
|
||||
}
|
||||
|
||||
let faceModels = [null, null, null];
|
||||
async function load(config) {
|
||||
const models = await Promise.all([
|
||||
blazeface.load(config),
|
||||
tf.loadGraphModel(config.face.mesh.modelPath, { fromTFHub: config.face.mesh.modelPath.includes('tfhub.dev') }),
|
||||
tf.loadGraphModel(config.face.iris.modelPath, { fromTFHub: config.face.iris.modelPath.includes('tfhub.dev') }),
|
||||
faceModels = await Promise.all([
|
||||
(!faceModels[0] && config.face.enabled) ? blazeface.load(config) : null,
|
||||
(!faceModels[1] && config.face.mesh.enabled) ? tf.loadGraphModel(config.face.mesh.modelPath, { fromTFHub: config.face.mesh.modelPath.includes('tfhub.dev') }) : null,
|
||||
(!faceModels[2] && config.face.iris.enabled) ? tf.loadGraphModel(config.face.iris.modelPath, { fromTFHub: config.face.iris.modelPath.includes('tfhub.dev') }) : null,
|
||||
]);
|
||||
const faceMesh = new MediaPipeFaceMesh(models[0], models[1], models[2], config);
|
||||
const faceMesh = new MediaPipeFaceMesh(faceModels[0], faceModels[1], faceModels[2], config);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.face.mesh.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
if (config.face.mesh.enabled) console.log(`Human: load model: ${config.face.mesh.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.face.iris.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
if (config.face.iris.enabled) console.log(`Human: load model: ${config.face.iris.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
return faceMesh;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ exports.face = (res) => {
|
|||
if (!res) return [];
|
||||
const gestures = [];
|
||||
for (const face of res) {
|
||||
// if (face.annotations['rightCheek'] && face.annotations['leftCheek'] && (face.annotations['rightCheek'].length > 0) && (face.annotations['leftCheek'].length > 0)) {
|
||||
// gestures.push(`facing ${((face.annotations['rightCheek'][0][2] > 0) || (face.annotations['leftCheek'][0][2] < 0)) ? 'right' : 'left'}`);
|
||||
// }
|
||||
if (face.mesh && face.mesh.length > 0) {
|
||||
const eyeFacing = face.mesh[35][2] - face.mesh[263][2];
|
||||
if (Math.abs(eyeFacing) < 10) gestures.push('facing camera');
|
|
@ -69,16 +69,16 @@ exports.HandPose = HandPose;
|
|||
|
||||
async function load(config) {
|
||||
const [handDetectorModel, handPoseModel] = await Promise.all([
|
||||
tf.loadGraphModel(config.hand.detector.modelPath, { fromTFHub: config.hand.detector.modelPath.includes('tfhub.dev') }),
|
||||
tf.loadGraphModel(config.hand.skeleton.modelPath, { fromTFHub: config.hand.skeleton.modelPath.includes('tfhub.dev') }),
|
||||
config.hand.enabled ? tf.loadGraphModel(config.hand.detector.modelPath, { fromTFHub: config.hand.detector.modelPath.includes('tfhub.dev') }) : null,
|
||||
config.hand.landmarks ? tf.loadGraphModel(config.hand.skeleton.modelPath, { fromTFHub: config.hand.skeleton.modelPath.includes('tfhub.dev') }) : null,
|
||||
]);
|
||||
const detector = new handdetector.HandDetector(handDetectorModel, config.hand.inputSize, anchors.anchors);
|
||||
const pipe = new pipeline.HandPipeline(detector, handPoseModel, config.hand.inputSize);
|
||||
const handpose = new HandPose(pipe);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.hand.detector.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
if (config.hand.enabled) console.log(`Human: load model: ${config.hand.detector.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.hand.skeleton.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
if (config.hand.landmarks) console.log(`Human: load model: ${config.hand.skeleton.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
return handpose;
|
||||
}
|
||||
exports.load = load;
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as emotion from './emotion/emotion.js';
|
|||
import * as embedding from './embedding/embedding.js';
|
||||
import * as posenet from './body/posenet.js';
|
||||
import * as handpose from './hand/handpose.js';
|
||||
import * as gesture from './gesture.js';
|
||||
import * as gesture from './gesture/gesture.js';
|
||||
import * as image from './image.js';
|
||||
import * as profile from './profile.js';
|
||||
import * as config from '../config.js';
|
||||
|
|
Loading…
Reference in New Issue