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 { } else {
buffer = fs.readFileSync(input); buffer = fs.readFileSync(input);
} }
// decode image using tfjs-node so we don't need external depenencies
const decoded = human.tf.node.decodeImage(buffer); const decoded = human.tf.node.decodeImage(buffer);
const casted = decoded.toFloat(); const casted = decoded.toFloat();
const image = casted.expandDims(0); const image = casted.expandDims(0);
decoded.dispose(); decoded.dispose();
casted.dispose(); casted.dispose();
// image shape contains image dimensions and depth // image shape contains image dimensions and depth
log.state('Processing:', image.shape); log.state('Processing:', image.shape);
// run actual detection // run actual detection
const result = await human.detect(image, myConfig); 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 // 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 // dispose image tensor as we no longer need it
image.dispose(); image.dispose();
// print data to console // print data to console
log.data('Results:'); log.data('Results:');
for (let i = 0; i < result.face.length; i++) { for (let i = 0; i < result.face.length; i++) {