mirror of https://github.com/vladmandic/human
optimized model loader
parent
7a7272c49c
commit
94986ced0d
|
@ -0,0 +1,31 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFazCCA1OgAwIBAgIUKQKodDBJnuweJs5IcTyL4NIp3vgwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwRTELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB0Zsb3JpZGExDjAMBgNVBAcMBU1p
|
||||||
|
YW1pMRQwEgYDVQQKDAtAdmxhZG1hbmRpYzAeFw0yMDExMDcxNTE3NDNaFw0yMTEx
|
||||||
|
MDcxNTE3NDNaMEUxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdGbG9yaWRhMQ4wDAYD
|
||||||
|
VQQHDAVNaWFtaTEUMBIGA1UECgwLQHZsYWRtYW5kaWMwggIiMA0GCSqGSIb3DQEB
|
||||||
|
AQUAA4ICDwAwggIKAoICAQDSC88PF8NyLkagK5mAZ/d739SOU16l2Cx3zE35zZQh
|
||||||
|
O29+1L4L+oMksLYipo+FMgtGO+MSzFsvGgKCs2sDSdfyoNSTZ3QaN4BAZ0sbq+wL
|
||||||
|
cke7yRBTM/XIGOQfhqq8yC2q8/zXwUbZg0UsCAxDGNwUr0Qlm829laIU/UN1KcYS
|
||||||
|
57Nebl1z05wMEvYmyl4JBAl9ozne7KS9DyW7jbrAXE8TaEy3+pY66kx5GG6v2+up
|
||||||
|
ScITGm4YPmPPlpOF1UjQloosgxdVa+fVp8aNCa/rf0JNO0Uhb3OKOZ+4kYmpfPn/
|
||||||
|
trwoKWAa6CV1uAJ+3zDkLMq1JNlrV4OMp1QvX0wzA47a/n466JMN9SFb0Ng5wf19
|
||||||
|
VOtT5Zu7chDStBudVjxlMDfUixvhvn4sjbaLNYR1fyWPoNXwr0KX2lpTP1QOzp9/
|
||||||
|
Sd0iiJ8RPfXn8Xo26MStu4I52CZjS7yEMgJGCLH/mgPuSbrHHYYrrrCPJgmQOZG2
|
||||||
|
TNMI+E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qqPFheIbGnmKw1lrRML8
|
||||||
|
87ZbN6t01+v2YyYe6Mc7p80s1R3jc8aVX8ca2KcYwsJAkg/xz0q5RJwsE1is5UY=
|
||||||
|
-----END CERTIFICATE-----
|
|
@ -9,21 +9,25 @@
|
||||||
- passthrough data compression
|
- passthrough data compression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const process = require('process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const path = require('path');
|
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
|
const path = require('path');
|
||||||
const chokidar = require('chokidar');
|
const chokidar = require('chokidar');
|
||||||
const process = require('process');
|
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
const log = require('@vladmandic/pilogger');
|
const log = require('@vladmandic/pilogger');
|
||||||
|
|
||||||
// app configuration
|
// app configuration
|
||||||
// must provide your own server key and certificate, can be self-signed
|
// you can provide your server key and certificate or use provided self-signed ones
|
||||||
|
// self-signed certificate generated using:
|
||||||
|
// openssl req -x509 -newkey rsa:4096 -nodes -keyout dev-server.key -out dev-server.crt -days 365 -subj "/C=US/ST=Florida/L=Miami/O=@vladmandic"
|
||||||
// client app does not work without secure server since browsers enforce https for webcam access
|
// client app does not work without secure server since browsers enforce https for webcam access
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync('/home/vlado/dev/piproxy/cert/private.pem'),
|
// key: fs.readFileSync('/home/vlado/dev/piproxy/cert/private.pem'),
|
||||||
cert: fs.readFileSync('/home/vlado/dev/piproxy/cert/fullchain.pem'),
|
// cert: fs.readFileSync('/home/vlado/dev/piproxy/cert/fullchain.pem'),
|
||||||
|
key: fs.readFileSync('./dev-server.key'),
|
||||||
|
cert: fs.readFileSync('./dev-server.crt'),
|
||||||
root: '.',
|
root: '.',
|
||||||
default: 'demo/index.html',
|
default: 'demo/index.html',
|
||||||
port: 8000,
|
port: 8000,
|
||||||
|
@ -57,7 +61,7 @@ async function build(f, msg) {
|
||||||
if (!es) es = await esbuild.startService();
|
if (!es) es = await esbuild.startService();
|
||||||
// common build options
|
// common build options
|
||||||
const cfg = {
|
const cfg = {
|
||||||
minify: false,
|
minify: true,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
logLevel: 'error',
|
logLevel: 'error',
|
||||||
|
@ -79,8 +83,10 @@ async function build(f, msg) {
|
||||||
cfg.outfile = 'dist/demo-browser-index.js';
|
cfg.outfile = 'dist/demo-browser-index.js';
|
||||||
cfg.metafile = 'dist/demo-browser-index.json';
|
cfg.metafile = 'dist/demo-browser-index.json';
|
||||||
await es.build(cfg);
|
await es.build(cfg);
|
||||||
|
// done
|
||||||
log.state('Build complete');
|
log.state('Build complete');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// catch errors and print where it occured
|
||||||
log.error('Build error', JSON.stringify(err.errors || err, null, 2));
|
log.error('Build error', JSON.stringify(err.errors || err, null, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +103,7 @@ async function watch() {
|
||||||
useFsEvents: false,
|
useFsEvents: false,
|
||||||
atomic: true,
|
atomic: true,
|
||||||
});
|
});
|
||||||
|
// single event handler for file add/change/delete
|
||||||
watcher
|
watcher
|
||||||
.on('add', (evt) => build(evt, 'add'))
|
.on('add', (evt) => build(evt, 'add'))
|
||||||
.on('change', (evt) => build(evt, 'modify'))
|
.on('change', (evt) => build(evt, 'modify'))
|
||||||
|
@ -106,17 +113,16 @@ async function watch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get file content for a valid url request
|
// get file content for a valid url request
|
||||||
function content(url) {
|
function handle(url) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let obj = { ok: false };
|
let obj = { ok: false };
|
||||||
obj.file = url;
|
obj.file = url;
|
||||||
if (!fs.existsSync(obj.file)) resolve(null);
|
if (!fs.existsSync(obj.file)) resolve(null);
|
||||||
obj.stat = fs.statSync(obj.file);
|
obj.stat = fs.statSync(obj.file);
|
||||||
// should really use streams here instead of reading entire content in-memory, but this is micro-http2 not intended to serve huge files
|
|
||||||
if (obj.stat.isFile()) obj.ok = true;
|
if (obj.stat.isFile()) obj.ok = true;
|
||||||
if (!obj.ok && obj.stat.isDirectory()) {
|
if (!obj.ok && obj.stat.isDirectory()) {
|
||||||
obj.file = path.join(obj.file, options.default);
|
obj.file = path.join(obj.file, options.default);
|
||||||
obj = content(obj.file);
|
obj = handle(obj.file);
|
||||||
}
|
}
|
||||||
resolve(obj);
|
resolve(obj);
|
||||||
});
|
});
|
||||||
|
@ -124,7 +130,8 @@ function content(url) {
|
||||||
|
|
||||||
// process http requests
|
// process http requests
|
||||||
async function httpRequest(req, res) {
|
async function httpRequest(req, res) {
|
||||||
content(path.join(__dirname, options.root, req.url)).then((result) => {
|
handle(path.join(__dirname, options.root, req.url)).then((result) => {
|
||||||
|
// get original ip of requestor, regardless if it's behind proxy or not
|
||||||
const forwarded = (req.headers['forwarded'] || '').match(/for="\[(.*)\]:/);
|
const forwarded = (req.headers['forwarded'] || '').match(/for="\[(.*)\]:/);
|
||||||
const ip = (Array.isArray(forwarded) ? forwarded[1] : null) || req.headers['x-forwarded-for'] || req.ip || req.socket.remoteAddress;
|
const ip = (Array.isArray(forwarded) ? forwarded[1] : null) || req.headers['x-forwarded-for'] || req.ip || req.socket.remoteAddress;
|
||||||
if (!result || !result.ok) {
|
if (!result || !result.ok) {
|
||||||
|
@ -136,7 +143,8 @@ async function httpRequest(req, res) {
|
||||||
const contentType = mime[ext] || 'application/octet-stream';
|
const contentType = mime[ext] || 'application/octet-stream';
|
||||||
const accept = req.headers['accept-encoding'] ? req.headers['accept-encoding'].includes('br') : false; // does target accept brotli compressed data
|
const accept = req.headers['accept-encoding'] ? req.headers['accept-encoding'].includes('br') : false; // does target accept brotli compressed data
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Powered-By': `NodeJS/${process.version}`, // 'Content-Length': result.stat.size,
|
// 'Content-Length': result.stat.size, // not using as it's misleading for compressed streams
|
||||||
|
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Powered-By': `NodeJS/${process.version}`,
|
||||||
});
|
});
|
||||||
const compress = zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }); // instance of brotli compression with level 5
|
const compress = zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }); // instance of brotli compression with level 5
|
||||||
const stream = fs.createReadStream(result.file);
|
const stream = fs.createReadStream(result.file);
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDSC88PF8NyLkag
|
||||||
|
K5mAZ/d739SOU16l2Cx3zE35zZQhO29+1L4L+oMksLYipo+FMgtGO+MSzFsvGgKC
|
||||||
|
s2sDSdfyoNSTZ3QaN4BAZ0sbq+wLcke7yRBTM/XIGOQfhqq8yC2q8/zXwUbZg0Us
|
||||||
|
CAxDGNwUr0Qlm829laIU/UN1KcYS57Nebl1z05wMEvYmyl4JBAl9ozne7KS9DyW7
|
||||||
|
jbrAXE8TaEy3+pY66kx5GG6v2+upScITGm4YPmPPlpOF1UjQloosgxdVa+fVp8aN
|
||||||
|
Ca/rf0JNO0Uhb3OKOZ+4kYmpfPn/trwoKWAa6CV1uAJ+3zDkLMq1JNlrV4OMp1Qv
|
||||||
|
X0wzA47a/n466JMN9SFb0Ng5wf19VOtT5Zu7chDStBudVjxlMDfUixvhvn4sjbaL
|
||||||
|
NYR1fyWPoNXwr0KX2lpTP1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xuML31VmxRKxc20kIUDzmF8VJQ+0Avf85C
|
||||||
|
6yz99gfeXzl+qq2teKyrv9nCc47pEhN6JZXPhV53yPk5PmuBX5jPcHxiW1kNddhH
|
||||||
|
0n3cUuHv/rJ+3vvG555z46vJF9+R7c0u8LfZiTMCggEBAMQd4a/IN0xXM1+2U3SL
|
||||||
|
sSew+XR+FMPK25aGJmHAkKz9L8CWlzmj6cCy2LevT2aMSqYU3eeGOZ//at1nAV5c
|
||||||
|
shsaHA30RQ5hUkyWhZLdHnzK752NeQTQyJH3W3+4C9NNMIm6m/QCdLeqPflqSxK9
|
||||||
|
sPH5ZueN2UOXW+R5oTVKMmxd51RnNhZdasamnPrSBFrTK/EA3pOZNsOKKRqo0jz3
|
||||||
|
Eyb7vcUSI6OYXFQU7OwO1RGvpKvSJb5Y0wo11DrtRnO16i5gaGDg9u9e8ofISJSz
|
||||||
|
kcrZOKCGst1HQ1mXhbB+sbSh0aPnJog4I+OHxkgMdvyVO6vQjXExnAIxzzi8wZ25
|
||||||
|
+oECggEBAIT6q/sn8xFt5Jwc/0Z7YUjd415Nknam09tnbB+UPRR6lt6JFoILx8by
|
||||||
|
5Y1sN30HWDv27v9G32oZhUDii3Rt3PkbYLqlHy7XBMEXA9WIUo+3Be7mtdL8Wfrj
|
||||||
|
0zn0b7Hks9a9KsElG1dXUopwjMRL3M22UamaN7e/gl5jz2I7pyc5oaqz9GRDV5yG
|
||||||
|
slb6gGZ5naMycJD3p8vutXbmgKRr9beRp55UICAbEMdr5p3ks8bfR33Z6t+a97u1
|
||||||
|
IxI5x5Lb0fdfvL8JK3nRWn7Uzbmm5Ni/OaODNKP+fIm9m2yDAs8LM8RGpPtk6i0d
|
||||||
|
qIRta3H9KNw2Mhpkm77TtUSV/W5aOmY=
|
||||||
|
-----END PRIVATE KEY-----
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -23,7 +23,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytes": 1277954,
|
"bytes": 1278477,
|
||||||
"imports": []
|
"imports": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -31,28 +31,28 @@
|
||||||
"dist/demo-browser-index.js.map": {
|
"dist/demo-browser-index.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 5531295
|
"bytes": 5520787
|
||||||
},
|
},
|
||||||
"dist/demo-browser-index.js": {
|
"dist/demo-browser-index.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytesInOutput": 1664401
|
"bytesInOutput": 1288376
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"bytesInOutput": 8716
|
"bytesInOutput": 0
|
||||||
},
|
},
|
||||||
"demo/draw.js": {
|
"demo/draw.js": {
|
||||||
"bytesInOutput": 7451
|
"bytesInOutput": 4708
|
||||||
},
|
},
|
||||||
"demo/menu.js": {
|
"demo/menu.js": {
|
||||||
"bytesInOutput": 12462
|
"bytesInOutput": 9573
|
||||||
},
|
},
|
||||||
"demo/browser.js": {
|
"demo/browser.js": {
|
||||||
"bytesInOutput": 15743
|
"bytesInOutput": 11364
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 1708895
|
"bytes": 1322785
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -153,7 +153,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/age/age.js": {
|
"src/age/age.js": {
|
||||||
"bytes": 1766,
|
"bytes": 1908,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/body/modelPoseNet.js": {
|
"src/body/modelPoseNet.js": {
|
||||||
"bytes": 3539,
|
"bytes": 3658,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -277,7 +277,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/emotion/emotion.js": {
|
"src/emotion/emotion.js": {
|
||||||
"bytes": 2778,
|
"bytes": 2924,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -288,7 +288,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/face/blazeface.js": {
|
"src/face/blazeface.js": {
|
||||||
"bytes": 7098,
|
"bytes": 7226,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -304,7 +304,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/face/facemesh.js": {
|
"src/face/facemesh.js": {
|
||||||
"bytes": 2355,
|
"bytes": 2603,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -360,7 +360,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/gender/gender.js": {
|
"src/gender/gender.js": {
|
||||||
"bytes": 3042,
|
"bytes": 3189,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -412,7 +412,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"src/hand/handpose.js": {
|
"src/hand/handpose.js": {
|
||||||
"bytes": 2839,
|
"bytes": 3095,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -433,7 +433,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/human.js": {
|
"src/human.js": {
|
||||||
"bytes": 14049,
|
"bytes": 13709,
|
||||||
"imports": [
|
"imports": [
|
||||||
{
|
{
|
||||||
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
"path": "node_modules/@tensorflow/tfjs/dist/tf.node.js"
|
||||||
|
@ -513,7 +513,7 @@
|
||||||
"dist/human.esm.js.map": {
|
"dist/human.esm.js.map": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
"inputs": {},
|
"inputs": {},
|
||||||
"bytes": 5418185
|
"bytes": 5419375
|
||||||
},
|
},
|
||||||
"dist/human.esm.js": {
|
"dist/human.esm.js": {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
@ -576,7 +576,7 @@
|
||||||
"bytesInOutput": 760
|
"bytesInOutput": 760
|
||||||
},
|
},
|
||||||
"src/face/blazeface.js": {
|
"src/face/blazeface.js": {
|
||||||
"bytesInOutput": 3012
|
"bytesInOutput": 3091
|
||||||
},
|
},
|
||||||
"src/face/keypoints.js": {
|
"src/face/keypoints.js": {
|
||||||
"bytesInOutput": 1946
|
"bytesInOutput": 1946
|
||||||
|
@ -597,19 +597,19 @@
|
||||||
"bytesInOutput": 9991
|
"bytesInOutput": 9991
|
||||||
},
|
},
|
||||||
"src/face/facemesh.js": {
|
"src/face/facemesh.js": {
|
||||||
"bytesInOutput": 1136
|
"bytesInOutput": 1286
|
||||||
},
|
},
|
||||||
"src/profile.js": {
|
"src/profile.js": {
|
||||||
"bytesInOutput": 620
|
"bytesInOutput": 620
|
||||||
},
|
},
|
||||||
"src/age/age.js": {
|
"src/age/age.js": {
|
||||||
"bytesInOutput": 893
|
"bytesInOutput": 972
|
||||||
},
|
},
|
||||||
"src/gender/gender.js": {
|
"src/gender/gender.js": {
|
||||||
"bytesInOutput": 1389
|
"bytesInOutput": 1471
|
||||||
},
|
},
|
||||||
"src/emotion/emotion.js": {
|
"src/emotion/emotion.js": {
|
||||||
"bytesInOutput": 1345
|
"bytesInOutput": 1428
|
||||||
},
|
},
|
||||||
"src/body/modelBase.js": {
|
"src/body/modelBase.js": {
|
||||||
"bytesInOutput": 433
|
"bytesInOutput": 433
|
||||||
|
@ -639,7 +639,7 @@
|
||||||
"bytesInOutput": 1062
|
"bytesInOutput": 1062
|
||||||
},
|
},
|
||||||
"src/body/modelPoseNet.js": {
|
"src/body/modelPoseNet.js": {
|
||||||
"bytesInOutput": 846
|
"bytesInOutput": 916
|
||||||
},
|
},
|
||||||
"src/body/posenet.js": {
|
"src/body/posenet.js": {
|
||||||
"bytesInOutput": 474
|
"bytesInOutput": 474
|
||||||
|
@ -660,7 +660,7 @@
|
||||||
"bytesInOutput": 127001
|
"bytesInOutput": 127001
|
||||||
},
|
},
|
||||||
"src/hand/handpose.js": {
|
"src/hand/handpose.js": {
|
||||||
"bytesInOutput": 1105
|
"bytesInOutput": 1263
|
||||||
},
|
},
|
||||||
"src/gesture.js": {
|
"src/gesture.js": {
|
||||||
"bytesInOutput": 1220
|
"bytesInOutput": 1220
|
||||||
|
@ -678,13 +678,13 @@
|
||||||
"bytesInOutput": 3020
|
"bytesInOutput": 3020
|
||||||
},
|
},
|
||||||
"src/human.js": {
|
"src/human.js": {
|
||||||
"bytesInOutput": 7397
|
"bytesInOutput": 7219
|
||||||
},
|
},
|
||||||
"src/human.js": {
|
"src/human.js": {
|
||||||
"bytesInOutput": 0
|
"bytesInOutput": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytes": 1277954
|
"bytes": 1278477
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,11 @@ let frame = Number.MAX_SAFE_INTEGER;
|
||||||
const zoom = [0, 0]; // 0..1 meaning 0%..100%
|
const zoom = [0, 0]; // 0..1 meaning 0%..100%
|
||||||
|
|
||||||
async function load(config) {
|
async function load(config) {
|
||||||
if (!models.age) models.age = await tf.loadGraphModel(config.face.age.modelPath);
|
if (!models.age) {
|
||||||
|
models.age = await tf.loadGraphModel(config.face.age.modelPath);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.face.age.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
|
}
|
||||||
return models.age;
|
return models.age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ exports.PoseNet = PoseNet;
|
||||||
async function loadMobileNet(config) {
|
async function loadMobileNet(config) {
|
||||||
const graphModel = await tf.loadGraphModel(config.modelPath);
|
const graphModel = await tf.loadGraphModel(config.modelPath);
|
||||||
const mobilenet = new modelMobileNet.MobileNet(graphModel, config.outputStride);
|
const mobilenet = new modelMobileNet.MobileNet(graphModel, config.outputStride);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
return new PoseNet(mobilenet);
|
return new PoseNet(mobilenet);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,11 @@ const rgb = [0.2989, 0.5870, 0.1140]; // factors for red/green/blue colors when
|
||||||
const scale = 1; // score multiplication factor
|
const scale = 1; // score multiplication factor
|
||||||
|
|
||||||
async function load(config) {
|
async function load(config) {
|
||||||
if (!models.emotion) models.emotion = await tf.loadGraphModel(config.face.emotion.modelPath);
|
if (!models.emotion) {
|
||||||
|
models.emotion = await tf.loadGraphModel(config.face.emotion.modelPath);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.face.emotion.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
|
}
|
||||||
return models.emotion;
|
return models.emotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,8 @@ class BlazeFaceModel {
|
||||||
async function load(config) {
|
async function load(config) {
|
||||||
const blazeface = await tf.loadGraphModel(config.detector.modelPath, { fromTFHub: config.detector.modelPath.includes('tfhub.dev') });
|
const blazeface = await tf.loadGraphModel(config.detector.modelPath, { fromTFHub: config.detector.modelPath.includes('tfhub.dev') });
|
||||||
const model = new BlazeFaceModel(blazeface, config);
|
const model = new BlazeFaceModel(blazeface, config);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.detector.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@ async function load(config) {
|
||||||
tf.loadGraphModel(config.iris.modelPath, { fromTFHub: config.iris.modelPath.includes('tfhub.dev') }),
|
tf.loadGraphModel(config.iris.modelPath, { fromTFHub: config.iris.modelPath.includes('tfhub.dev') }),
|
||||||
]);
|
]);
|
||||||
const faceMesh = new MediaPipeFaceMesh(models[0], models[1], models[2], config);
|
const faceMesh = new MediaPipeFaceMesh(models[0], models[1], models[2], config);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.mesh.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.iris.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
return faceMesh;
|
return faceMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,12 @@ const zoom = [0, 0]; // 0..1 meaning 0%..100%
|
||||||
const rgb = [0.2989, 0.5870, 0.1140]; // factors for red/green/blue colors when converting to grayscale
|
const rgb = [0.2989, 0.5870, 0.1140]; // factors for red/green/blue colors when converting to grayscale
|
||||||
|
|
||||||
async function load(config) {
|
async function load(config) {
|
||||||
if (!models.gender) models.gender = await tf.loadGraphModel(config.face.gender.modelPath);
|
if (!models.gender) {
|
||||||
alternative = models.gender.inputs[0].shape[3] === 1;
|
models.gender = await tf.loadGraphModel(config.face.gender.modelPath);
|
||||||
|
alternative = models.gender.inputs[0].shape[3] === 1;
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.face.gender.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
|
}
|
||||||
return models.gender;
|
return models.gender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,10 @@ async function load(config) {
|
||||||
const detector = new handdetector.HandDetector(handDetectorModel, config.inputSize, anchors.anchors);
|
const detector = new handdetector.HandDetector(handDetectorModel, config.inputSize, anchors.anchors);
|
||||||
const pipe = new pipeline.HandPipeline(detector, handPoseModel, config.inputSize);
|
const pipe = new pipeline.HandPipeline(detector, handPoseModel, config.inputSize);
|
||||||
const handpose = new HandPose(pipe);
|
const handpose = new HandPose(pipe);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.detector.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Human: load model: ${config.skeleton.modelPath.match(/\/(.*)\./)[1]}`);
|
||||||
return handpose;
|
return handpose;
|
||||||
}
|
}
|
||||||
exports.load = load;
|
exports.load = load;
|
||||||
|
|
30
src/human.js
30
src/human.js
|
@ -138,30 +138,12 @@ class Human {
|
||||||
this.models.handpose || handpose.load(this.config.hand),
|
this.models.handpose || handpose.load(this.config.hand),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
if (this.config.face.enabled && !this.models.facemesh) {
|
if (this.config.face.enabled && !this.models.facemesh) this.models.facemesh = await facemesh.load(this.config.face);
|
||||||
this.log('load model: face');
|
if (this.config.body.enabled && !this.models.posenet) this.models.posenet = await posenet.load(this.config.body);
|
||||||
this.models.facemesh = await facemesh.load(this.config.face);
|
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.body.enabled && !this.models.posenet) {
|
if (this.config.face.enabled && this.config.face.gender.enabled && !this.models.gender) this.models.gender = await gender.load(this.config);
|
||||||
this.log('load model: body');
|
if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion) this.models.emotion = await emotion.load(this.config);
|
||||||
this.models.posenet = await posenet.load(this.config.body);
|
|
||||||
}
|
|
||||||
if (this.config.hand.enabled && !this.models.handpose) {
|
|
||||||
this.log('load model: hand');
|
|
||||||
this.models.handpose = await handpose.load(this.config.hand);
|
|
||||||
}
|
|
||||||
if (this.config.face.enabled && this.config.face.age.enabled && !this.models.age) {
|
|
||||||
this.log('load model: age');
|
|
||||||
this.models.age = await age.load(this.config);
|
|
||||||
}
|
|
||||||
if (this.config.face.enabled && this.config.face.gender.enabled && !this.models.gender) {
|
|
||||||
this.log('load model: gender');
|
|
||||||
this.models.gender = await gender.load(this.config);
|
|
||||||
}
|
|
||||||
if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion) {
|
|
||||||
this.log('load model: emotion');
|
|
||||||
this.models.emotion = await emotion.load(this.config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const current = Math.trunc(now() - timeStamp);
|
const current = Math.trunc(now() - timeStamp);
|
||||||
if (current > (this.perf.load || 0)) this.perf.load = current;
|
if (current > (this.perf.load || 0)) this.perf.load = current;
|
||||||
|
|
Loading…
Reference in New Issue