human/src/node.js

61 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-10-18 18:12:09 +02:00
const console = require('console');
2021-02-24 15:57:33 +01:00
const process = require('process');
// const URL = require('url');
2020-10-18 18:12:09 +02:00
const tf = require('@tensorflow/tfjs-node');
2021-02-08 17:39:09 +01:00
const Human = require('../dist/human.node').default; // this resolves to project root which is '@vladmandic/human'
2020-10-18 18:12:09 +02:00
const logger = new console.Console({
stdout: process.stdout,
stderr: process.stderr,
ignoreErrors: true,
2020-12-23 19:55:22 +01:00
// groupIndentation: 2,
2020-10-18 18:12:09 +02:00
inspectOptions: {
showHidden: true,
depth: 5,
colors: true,
showProxy: true,
maxArrayLength: 1024,
maxStringLength: 10240,
breakLength: 300,
compact: 64,
sorted: false,
getters: true,
},
});
const config = {
backend: 'tensorflow',
videoOptimized: false,
face: {
2020-12-23 19:55:22 +01:00
detector: { modelPath: 'file://models/blazeface-back.json' },
mesh: { modelPath: 'file://models/facemesh.json' },
iris: { modelPath: 'file://models/iris.json' },
age: { modelPath: 'file://models/age-ssrnet-imdb.json' },
2021-02-24 15:57:33 +01:00
gender: { modelPath: 'file://models/gender.json' },
2020-12-23 19:55:22 +01:00
emotion: { modelPath: 'file://models/emotion-large.json' },
2021-02-24 15:57:33 +01:00
embedding: { modelPath: 'file://models/mobilefacenet.json' },
},
2020-12-23 19:55:22 +01:00
body: { modelPath: 'file://models/posenet.json' },
hand: {
2020-12-23 19:55:22 +01:00
detector: { modelPath: 'file://models/handdetect.json' },
skeleton: { modelPath: 'file://models/handskeleton.json' },
},
};
2020-10-18 18:12:09 +02:00
async function main() {
await tf.ready();
2021-02-24 15:57:33 +01:00
const human = new Human(config);
2020-10-18 18:12:09 +02:00
logger.info('Human:', human.version);
2021-02-24 15:57:33 +01:00
logger.info('Current folder:', process.env.PWD);
logger.info('Active Configuration', human.config);
2020-10-18 18:12:09 +02:00
logger.info('TFJS Version:', tf.version_core, 'Backend:', tf.getBackend());
logger.info('TFJS Flags:', tf.env().features);
logger.info('Loading models:');
await human.load(config);
for (const model of Object.keys(human.models)) logger.info(' Loaded:', model);
logger.info('Memory state:', human.tf.engine().memory());
logger.info('Test Complete');
2020-10-18 18:12:09 +02:00
}
main();