Face-api.js_ is a JavaScript API for face detection and face recognition in the browser and Node.js with _TensorFlow.js

Sometimes, we have to implement face recognition or face landmark. With face-api.js, we can do this with just a few lines of code.

In the face-api.js repository, we can find examples for both browser and Node.js environments. They look simple enough for us. Let’s see what you can do with them.

In this story, we will try to implement a complete example that uses face-api.js and face landmark model to “Glassify” faces in an image.

Face Landmark With face-api.js

Initial TypeScript:

$ mkdir ts-faceapi-glassify
$ code ts-faceapi-glassify ## Open directory with vscode

$ npm init -y
$ npm install typescript -D
$ npx tsc --init

TypeScript configuration file: tsconfig.json

{
  "compilerOptions": {
    "target": "ES2018",
    "lib": [
      "DOM"
    ],
    "outDir": "./dist",
    "module": "CommonJS",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "./src"
  ],
  "exclude": [
    "node_modules",
    ".git",
    "dist"
  ]
}

#javascript #typescript #coding #programming

How to Create “Glassify” Faces API with Face-api.js
1.80 GEEK