update node demo

pull/134/head
Vladimir Mandic 2021-04-19 11:17:55 -04:00
parent cbc7ff9276
commit db40c5b727
1 changed files with 6 additions and 0 deletions

View File

@ -60,18 +60,24 @@ async function detect(input) {
} else {
buffer = fs.readFileSync(input);
}
// decode image using tfjs-node so we don't need external depenencies
const decoded = human.tf.node.decodeImage(buffer);
const casted = decoded.toFloat();
const image = casted.expandDims(0);
decoded.dispose();
casted.dispose();
// image shape contains image dimensions and depth
log.state('Processing:', image.shape);
// run actual detection
const result = await human.detect(image, myConfig);
// no need to print results as they are printed to console during detection from within the library due to human.config.debug set
// dispose image tensor as we no longer need it
image.dispose();
// print data to console
log.data('Results:');
for (let i = 0; i < result.face.length; i++) {