diff --git a/src/age/age.js b/src/age/age.js index 1e456c31..7a4fbb44 100644 --- a/src/age/age.js +++ b/src/age/age.js @@ -9,7 +9,11 @@ let frame = Number.MAX_SAFE_INTEGER; const zoom = [0, 0]; // 0..1 meaning 0%..100% 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; } diff --git a/src/emotion/emotion.js b/src/emotion/emotion.js index c723cbd1..b7ed811d 100644 --- a/src/emotion/emotion.js +++ b/src/emotion/emotion.js @@ -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 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; } diff --git a/src/gender/gender.js b/src/gender/gender.js index 5524d18a..00ff3c69 100644 --- a/src/gender/gender.js +++ b/src/gender/gender.js @@ -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 async function load(config) { - if (!models.gender) models.gender = await tf.loadGraphModel(config.face.gender.modelPath); - alternative = models.gender.inputs[0].shape[3] === 1; + if (!models.gender) { + 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; } diff --git a/src/hand/handpose.js b/src/hand/handpose.js index 9348f626..005c2b87 100644 --- a/src/hand/handpose.js +++ b/src/hand/handpose.js @@ -75,6 +75,10 @@ async function load(config) { const detector = new handdetector.HandDetector(handDetectorModel, config.inputSize, anchors.anchors); const pipe = new pipeline.HandPipeline(detector, handPoseModel, config.inputSize); 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; } exports.load = load; diff --git a/src/human.js b/src/human.js index 69406544..a1e3f122 100644 --- a/src/human.js +++ b/src/human.js @@ -138,30 +138,12 @@ class Human { this.models.handpose || handpose.load(this.config.hand), ]); } else { - if (this.config.face.enabled && !this.models.facemesh) { - this.log('load model: face'); - this.models.facemesh = await facemesh.load(this.config.face); - } - if (this.config.body.enabled && !this.models.posenet) { - this.log('load model: body'); - 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); - } + if (this.config.face.enabled && !this.models.facemesh) this.models.facemesh = await facemesh.load(this.config.face); + if (this.config.body.enabled && !this.models.posenet) this.models.posenet = await posenet.load(this.config.body); + 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.face.enabled && this.config.face.gender.enabled && !this.models.gender) this.models.gender = await gender.load(this.config); + if (this.config.face.enabled && this.config.face.emotion.enabled && !this.models.emotion) this.models.emotion = await emotion.load(this.config); } const current = Math.trunc(now() - timeStamp); if (current > (this.perf.load || 0)) this.perf.load = current;