update
parent
d5b0c77e51
commit
b0098e8f17
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -559,7 +559,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytes": 1175,
|
||||
"bytes": 1296,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/env/index.ts",
|
||||
|
@ -634,7 +634,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytes": 1808,
|
||||
"bytes": 1804,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/classes/FaceDetection.ts",
|
||||
|
@ -1292,7 +1292,7 @@
|
|||
]
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 1841,
|
||||
"bytes": 1870,
|
||||
"imports": []
|
||||
},
|
||||
"src/xception/extractParams.ts": {
|
||||
|
@ -2591,7 +2591,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 309815
|
||||
"bytes": 310015
|
||||
},
|
||||
"dist/face-api.esm-nobundle.js": {
|
||||
"imports": [],
|
||||
|
@ -2806,7 +2806,7 @@
|
|||
"bytesInOutput": 94
|
||||
},
|
||||
"src/env/createBrowserEnv.ts": {
|
||||
"bytesInOutput": 453
|
||||
"bytesInOutput": 445
|
||||
},
|
||||
"src/env/createFileSystem.ts": {
|
||||
"bytesInOutput": 247
|
||||
|
@ -2866,13 +2866,13 @@
|
|||
"bytesInOutput": 2214
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytesInOutput": 381
|
||||
"bytesInOutput": 442
|
||||
},
|
||||
"src/dom/toNetInput.ts": {
|
||||
"bytesInOutput": 773
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytesInOutput": 489
|
||||
"bytesInOutput": 485
|
||||
},
|
||||
"src/dom/extractFaceTensors.ts": {
|
||||
"bytesInOutput": 442
|
||||
|
@ -3187,7 +3187,7 @@
|
|||
"bytesInOutput": 443
|
||||
}
|
||||
},
|
||||
"bytes": 82178
|
||||
"bytes": 82227
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"inputs": {
|
||||
"dist/tfjs.esm.js": {
|
||||
"bytes": 1055784,
|
||||
"bytes": 1055692,
|
||||
"imports": []
|
||||
},
|
||||
"src/draw/drawContour.ts": {
|
||||
|
@ -559,7 +559,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytes": 1175,
|
||||
"bytes": 1296,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/env/index.ts",
|
||||
|
@ -634,7 +634,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytes": 1808,
|
||||
"bytes": 1804,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/classes/FaceDetection.ts",
|
||||
|
@ -1292,7 +1292,7 @@
|
|||
]
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 1841,
|
||||
"bytes": 1870,
|
||||
"imports": []
|
||||
},
|
||||
"src/xception/extractParams.ts": {
|
||||
|
@ -2591,7 +2591,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 1447774
|
||||
"bytes": 1447909
|
||||
},
|
||||
"dist/face-api.esm.js": {
|
||||
"imports": [],
|
||||
|
@ -2722,7 +2722,7 @@
|
|||
"bytesInOutput": 181
|
||||
},
|
||||
"dist/tfjs.esm.js": {
|
||||
"bytesInOutput": 1047212
|
||||
"bytesInOutput": 1047120
|
||||
},
|
||||
"src/draw/index.ts": {
|
||||
"bytesInOutput": 280
|
||||
|
@ -2803,7 +2803,7 @@
|
|||
"bytesInOutput": 95
|
||||
},
|
||||
"src/env/createBrowserEnv.ts": {
|
||||
"bytesInOutput": 453
|
||||
"bytesInOutput": 445
|
||||
},
|
||||
"src/env/createFileSystem.ts": {
|
||||
"bytesInOutput": 247
|
||||
|
@ -2857,7 +2857,7 @@
|
|||
"bytesInOutput": 111
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytesInOutput": 383
|
||||
"bytesInOutput": 444
|
||||
},
|
||||
"src/dom/NetInput.ts": {
|
||||
"bytesInOutput": 2173
|
||||
|
@ -2866,7 +2866,7 @@
|
|||
"bytesInOutput": 776
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytesInOutput": 494
|
||||
"bytesInOutput": 490
|
||||
},
|
||||
"src/dom/extractFaceTensors.ts": {
|
||||
"bytesInOutput": 418
|
||||
|
@ -3187,7 +3187,7 @@
|
|||
"bytesInOutput": 446
|
||||
}
|
||||
},
|
||||
"bytes": 1134640
|
||||
"bytes": 1134597
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"inputs": {
|
||||
"dist/tfjs.esm.js": {
|
||||
"bytes": 1055784,
|
||||
"bytes": 1055692,
|
||||
"imports": []
|
||||
},
|
||||
"src/draw/drawContour.ts": {
|
||||
|
@ -559,7 +559,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytes": 1175,
|
||||
"bytes": 1296,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/env/index.ts",
|
||||
|
@ -634,7 +634,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytes": 1808,
|
||||
"bytes": 1804,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/classes/FaceDetection.ts",
|
||||
|
@ -1292,7 +1292,7 @@
|
|||
]
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 1841,
|
||||
"bytes": 1870,
|
||||
"imports": []
|
||||
},
|
||||
"src/xception/extractParams.ts": {
|
||||
|
@ -2591,7 +2591,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 1447781
|
||||
"bytes": 1447916
|
||||
},
|
||||
"dist/face-api.js": {
|
||||
"imports": [],
|
||||
|
@ -2604,7 +2604,7 @@
|
|||
"bytesInOutput": 3011
|
||||
},
|
||||
"dist/tfjs.esm.js": {
|
||||
"bytesInOutput": 1047274
|
||||
"bytesInOutput": 1047182
|
||||
},
|
||||
"src/draw/index.ts": {
|
||||
"bytesInOutput": 280
|
||||
|
@ -2685,7 +2685,7 @@
|
|||
"bytesInOutput": 95
|
||||
},
|
||||
"src/env/createBrowserEnv.ts": {
|
||||
"bytesInOutput": 453
|
||||
"bytesInOutput": 445
|
||||
},
|
||||
"src/env/createFileSystem.ts": {
|
||||
"bytesInOutput": 247
|
||||
|
@ -2739,7 +2739,7 @@
|
|||
"bytesInOutput": 111
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytesInOutput": 383
|
||||
"bytesInOutput": 444
|
||||
},
|
||||
"src/dom/NetInput.ts": {
|
||||
"bytesInOutput": 2173
|
||||
|
@ -2748,7 +2748,7 @@
|
|||
"bytesInOutput": 776
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytesInOutput": 494
|
||||
"bytesInOutput": 490
|
||||
},
|
||||
"src/dom/extractFaceTensors.ts": {
|
||||
"bytesInOutput": 418
|
||||
|
@ -3066,7 +3066,7 @@
|
|||
"bytesInOutput": 446
|
||||
}
|
||||
},
|
||||
"bytes": 1134803
|
||||
"bytes": 1134760
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -559,7 +559,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytes": 1175,
|
||||
"bytes": 1296,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/env/index.ts",
|
||||
|
@ -634,7 +634,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytes": 1808,
|
||||
"bytes": 1804,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/classes/FaceDetection.ts",
|
||||
|
@ -1292,7 +1292,7 @@
|
|||
]
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 1841,
|
||||
"bytes": 1870,
|
||||
"imports": []
|
||||
},
|
||||
"src/xception/extractParams.ts": {
|
||||
|
@ -2591,7 +2591,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 309700
|
||||
"bytes": 309900
|
||||
},
|
||||
"dist/face-api.node-gpu.js": {
|
||||
"imports": [],
|
||||
|
@ -2685,7 +2685,7 @@
|
|||
"bytesInOutput": 94
|
||||
},
|
||||
"src/env/createBrowserEnv.ts": {
|
||||
"bytesInOutput": 453
|
||||
"bytesInOutput": 445
|
||||
},
|
||||
"src/env/createFileSystem.ts": {
|
||||
"bytesInOutput": 247
|
||||
|
@ -2745,13 +2745,13 @@
|
|||
"bytesInOutput": 2214
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytesInOutput": 381
|
||||
"bytesInOutput": 442
|
||||
},
|
||||
"src/dom/toNetInput.ts": {
|
||||
"bytesInOutput": 773
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytesInOutput": 489
|
||||
"bytesInOutput": 485
|
||||
},
|
||||
"src/dom/extractFaceTensors.ts": {
|
||||
"bytesInOutput": 442
|
||||
|
@ -3066,7 +3066,7 @@
|
|||
"bytesInOutput": 443
|
||||
}
|
||||
},
|
||||
"bytes": 82721
|
||||
"bytes": 82770
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -559,7 +559,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytes": 1175,
|
||||
"bytes": 1296,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/env/index.ts",
|
||||
|
@ -634,7 +634,7 @@
|
|||
]
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytes": 1808,
|
||||
"bytes": 1804,
|
||||
"imports": [
|
||||
{
|
||||
"path": "src/classes/FaceDetection.ts",
|
||||
|
@ -1292,7 +1292,7 @@
|
|||
]
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 1841,
|
||||
"bytes": 1870,
|
||||
"imports": []
|
||||
},
|
||||
"src/xception/extractParams.ts": {
|
||||
|
@ -2591,7 +2591,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 309692
|
||||
"bytes": 309892
|
||||
},
|
||||
"dist/face-api.node.js": {
|
||||
"imports": [],
|
||||
|
@ -2685,7 +2685,7 @@
|
|||
"bytesInOutput": 94
|
||||
},
|
||||
"src/env/createBrowserEnv.ts": {
|
||||
"bytesInOutput": 453
|
||||
"bytesInOutput": 445
|
||||
},
|
||||
"src/env/createFileSystem.ts": {
|
||||
"bytesInOutput": 247
|
||||
|
@ -2745,13 +2745,13 @@
|
|||
"bytesInOutput": 2214
|
||||
},
|
||||
"src/dom/imageToSquare.ts": {
|
||||
"bytesInOutput": 381
|
||||
"bytesInOutput": 442
|
||||
},
|
||||
"src/dom/toNetInput.ts": {
|
||||
"bytesInOutput": 773
|
||||
},
|
||||
"src/dom/extractFaces.ts": {
|
||||
"bytesInOutput": 489
|
||||
"bytesInOutput": 485
|
||||
},
|
||||
"src/dom/extractFaceTensors.ts": {
|
||||
"bytesInOutput": 442
|
||||
|
@ -3066,7 +3066,7 @@
|
|||
"bytesInOutput": 443
|
||||
}
|
||||
},
|
||||
"bytes": 82713
|
||||
"bytes": 82762
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -25364,7 +25364,7 @@
|
|||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {},
|
||||
"bytes": 1129507
|
||||
"bytes": 1129446
|
||||
},
|
||||
"dist/tfjs.esm.js": {
|
||||
"imports": [],
|
||||
|
@ -27550,7 +27550,7 @@
|
|||
"bytesInOutput": 96
|
||||
},
|
||||
"node_modules/@tensorflow/tfjs-layers/dist/errors.js": {
|
||||
"bytesInOutput": 542
|
||||
"bytesInOutput": 452
|
||||
},
|
||||
"node_modules/@tensorflow/tfjs-layers/dist/utils/generic_utils.js": {
|
||||
"bytesInOutput": 3474
|
||||
|
@ -29479,7 +29479,7 @@
|
|||
"bytesInOutput": 14
|
||||
},
|
||||
"node_modules/@tensorflow/tfjs-backend-wasm/dist/kernels/ScatterNd.js": {
|
||||
"bytesInOutput": 616
|
||||
"bytesInOutput": 614
|
||||
},
|
||||
"node_modules/@tensorflow/tfjs-backend-wasm/dist/kernels/Select.js": {
|
||||
"bytesInOutput": 509
|
||||
|
@ -29557,7 +29557,7 @@
|
|||
"bytesInOutput": 0
|
||||
}
|
||||
},
|
||||
"bytes": 1055784
|
||||
"bytes": 1055692
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as faceapi from '../dist/face-api.esm.js';
|
|||
// configuration options
|
||||
const modelPath = 'https://vladmandic.github.io/face-api/model/'; // path to model folder that will be loaded using http
|
||||
// const modelPath = '../model/'; // path to model folder that will be loaded using http
|
||||
const imgSize = 512; // maximum image size in pixels
|
||||
const imgSize = 720; // maximum image size in pixels
|
||||
const minScore = 0.1; // minimum score
|
||||
const maxResults = 10; // maximum number of results to return
|
||||
const samples = ['sample (1).jpg', 'sample (2).jpg', 'sample (3).jpg', 'sample (4).jpg', 'sample (5).jpg', 'sample (6).jpg']; // sample images to be loaded using http
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-nocheck
|
||||
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const path = require('path');
|
||||
const log = require('@vladmandic/pilogger');
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
||||
|
@ -11,6 +12,7 @@ const modelPathRoot = '../model';
|
|||
const imgPathRoot = './example'; // modify to include your sample images
|
||||
const minScore = 0.1;
|
||||
const maxResults = 5;
|
||||
let optionsSSDMobileNet;
|
||||
|
||||
async function image(img) {
|
||||
const buffer = fs.readFileSync(img);
|
||||
|
@ -22,10 +24,19 @@ async function image(img) {
|
|||
return result;
|
||||
}
|
||||
|
||||
async function detect(tensor) {
|
||||
const result = await faceapi
|
||||
.detectAllFaces(tensor, optionsSSDMobileNet)
|
||||
.withFaceLandmarks()
|
||||
.withFaceExpressions()
|
||||
.withFaceDescriptors()
|
||||
.withAgeAndGender();
|
||||
return result;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
log.header();
|
||||
log.info('FaceAPI single-process test');
|
||||
const t0 = process.hrtime.bigint();
|
||||
|
||||
await faceapi.tf.setBackend('tensorflow');
|
||||
await faceapi.tf.enableProdMode();
|
||||
|
@ -41,23 +52,32 @@ async function main() {
|
|||
await faceapi.nets.faceLandmark68Net.loadFromDisk(modelPath);
|
||||
await faceapi.nets.faceRecognitionNet.loadFromDisk(modelPath);
|
||||
await faceapi.nets.faceExpressionNet.loadFromDisk(modelPath);
|
||||
const optionsSSDMobileNet = new faceapi.SsdMobilenetv1Options({ minConfidence: minScore, maxResults });
|
||||
optionsSSDMobileNet = new faceapi.SsdMobilenetv1Options({ minConfidence: minScore, maxResults });
|
||||
|
||||
if (process.argv.length !== 3) {
|
||||
const t0 = process.hrtime.bigint();
|
||||
const dir = fs.readdirSync(imgPathRoot);
|
||||
for (const img of dir) {
|
||||
if (!img.toLocaleLowerCase().endsWith('.jpg')) continue;
|
||||
const tensor = await image(path.join(imgPathRoot, img));
|
||||
const result = await faceapi
|
||||
.detectAllFaces(tensor, optionsSSDMobileNet)
|
||||
.withFaceLandmarks()
|
||||
.withFaceExpressions()
|
||||
.withFaceDescriptors()
|
||||
.withAgeAndGender();
|
||||
const result = await detect(tensor);
|
||||
log.data('Image:', img, 'Detected faces:', result.length);
|
||||
tensor.dispose();
|
||||
}
|
||||
const t1 = process.hrtime.bigint();
|
||||
log.info('Processed', dir.length, 'images in', Math.trunc(parseInt(t1 - t0) / 1000 / 1000), 'ms');
|
||||
} else {
|
||||
const param = process.argv[2];
|
||||
if (fs.existsSync(param)) {
|
||||
const tensor = await image(param);
|
||||
const result = await detect(tensor);
|
||||
log.data('Image:', param, 'Detected faces:', result.length);
|
||||
for (const i of result) {
|
||||
log.data('Gender:', i.genderProbability, i.gender, 'Age:', i.age);
|
||||
}
|
||||
tensor.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
|
@ -38,18 +38,18 @@
|
|||
},
|
||||
"homepage": "https://github.com/vladmandic/face-api#readme",
|
||||
"dependencies": {
|
||||
"@tensorflow/tfjs-node": "^3.1.0",
|
||||
"@tensorflow/tfjs-node-gpu": "^3.1.0",
|
||||
"@vladmandic/pilogger": "^0.2.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tensorflow/tfjs": "^3.1.0",
|
||||
"@tensorflow/tfjs-backend-wasm": "^3.1.0",
|
||||
"@tensorflow/tfjs-node": "^3.1.0",
|
||||
"@tensorflow/tfjs-node-gpu": "^3.1.0",
|
||||
"@types/node": "^14.14.28",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
||||
"@typescript-eslint/parser": "^4.15.1",
|
||||
"@types/node": "^14.14.31",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.2-alpha.5",
|
||||
"@typescript-eslint/parser": "^4.15.2-alpha.5",
|
||||
"chokidar": "^3.5.1",
|
||||
"esbuild": "^0.8.46",
|
||||
"esbuild": "^0.8.49",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
@ -58,6 +58,6 @@
|
|||
"eslint-plugin-promise": "^4.3.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"tslib": "^2.1.0",
|
||||
"typescript": "^4.1.5"
|
||||
"typescript": "^4.3.0-dev.20210220"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue