Last active
December 3, 2020 22:17
-
-
Save framp/ac13e105f0d1a4209b12047781321a7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
nvm use 14 | |
cp -R ../face-api-js-master/weights . | |
echo {} > package.json | |
npm i --save @tensorflow/tfjs@2.6.0 @tensorflow/tfjs-node@2.6.0 canvas face-api.js | |
Doesn't work with tfjs-node@2.7.0 | |
package.json: | |
{ | |
"dependencies": { | |
"@tensorflow/tfjs": "^2.6.0", | |
"@tensorflow/tfjs-node": "^2.6.0", | |
"canvas": "^2.6.1", | |
"face-api.js": "^0.22.2", | |
"node-fetch": "^2.6.1" | |
} | |
} | |
node face-api-test.js test.jpg | |
*/ | |
require("@tensorflow/tfjs-node"); | |
const canvas = require("canvas"); | |
const faceapi = require("face-api.js"); | |
const { Canvas, Image, ImageData } = canvas; | |
faceapi.env.monkeyPatch({ | |
Canvas, | |
Image, | |
ImageData, | |
}); | |
(async () => { | |
await faceapi.nets.tinyFaceDetector.loadFromDisk("./weights"); | |
const input = await canvas.loadImage(process.argv[2]); | |
console.log( | |
"TinyFace", | |
await faceapi.detectSingleFace(input, new faceapi.TinyFaceDetectorOptions()) | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment