FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS
 
 
 
Go to file
Vladimir Mandic b360bc0a84 0.4.5 2020-08-31 09:12:09 -04:00
build adding build 2020-08-31 09:12:04 -04:00
dist change build process 2020-08-30 18:45:06 -04:00
example updated 2020-08-27 09:24:54 -04:00
model update 2020-08-27 09:17:39 -04:00
src fix node build error 2020-08-29 14:56:29 -04:00
.gitignore adding build 2020-08-31 09:12:04 -04:00
LICENSE initial commit 2020-08-18 07:54:53 -04:00
README.md adding build 2020-08-31 09:12:04 -04:00
package-lock.json 0.4.5 2020-08-31 09:12:09 -04:00
package.json 0.4.5 2020-08-31 09:12:09 -04:00
tsconfig.json updated built to use tfjs instead of tfjs-core 2020-08-21 09:01:04 -04:00

README.md

FaceAPI

Note

This is updated face-api.js with latest available tensorflow/js as original face-api.js is not compatible with tfjs 2.0+.
If original repository is updated, this one will become obsolete.

Forked from face-api.js version 0.22.2 released on March 22nd, 2020

Differences

  • Removed tests, docs, examples
  • Updated all package dependencies
  • Modified to make compatible with TensorFlow/JS 2.0+
  • Trivial code changes for updated TypeScript type checking
  • Removed unnecesary package dependencies (karma, jasmine, etc.)
  • Updated Typescript build process to target ES2018 instead of dual ES5/ES6
  • Changed browser bundle process to use ESBuild instead of Rollup
  • Updated TFJS dependencies since backends were removed from @tensorflow/tfjs-core
  • Updated mobileNetv1 model due to batchNorm() dependency
  • Removed following models as they are either obsolete or non-functional with tfjs 2.0+
    • mtcnn: Mostly obsolete
    • tinyYolov2: Non-functional since weights are missing

Which means valid models are tinyFaceDetector and mobileNetv1
Due to reduced code and changed build process, resulting bundle is about >5x smaller than the original!

Installation

Imporant!: This version of face-api does not embedd full version of tfjs to enable dynamic loading of different versions of tfjs as well as to enable reusability of tfjs for different purposes. Load tfjs explicitly before loading face-api.

For example as a script:

  <script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.3.0/tf.es2017.js"></script>
  <script src="/dist/face-api.js"></script> <!-- full version / 960KB -->
  <script src="/dist/face-api.min.js"></script> <!-- minified version / 320KB -->

or as a module using require:

  # npm install @tensorflow/tfjs @vladmandic/face-api
  
  const tf = require('@tensorflow/tfjs');
  const faceapi = require('@vladmandic/face-api');

or as a module using import:
(NodeJS requires "type": "module" inside package.json to support import statements)

import tf from '@tensorflow/tfjs';
import faceapi from '@vladmandic/face-api';

Weights

Pretrained models and their weights are includes in ./model.

Build

Included in ./dist are:

  • face-api.cjs: CJS format, used by NodeJS import/require (default for node and browser require/import)
  • face-api.ejs: ESM format, used by Browser
  • face-api.js: IIFE format, used by Browser (default for browser script)
  • face-api.min.js: Minified IIFE format, used by Browser

If you want to rebuild use:

npm run build

Which will compile everything in ./src into ./build and create both standard and minified bundles as well as a sourcemap in ./dist

Documentation

For documentation refer to original project at https://github.com/justadudewhohacks/face-api.js

Example

Single new example that uses both models as well as all of the extensions is included in /example/index.html
Example can be accessed directly using Git pages using URL: https://vladmandic.github.io/face-api/example/

alt text