mirror of https://github.com/vladmandic/human
update node demo
parent
cbc7ff9276
commit
db40c5b727
|
@ -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++) {
|
||||||
|
|
Loading…
Reference in New Issue