# FaceAPI ## Note This is updated **face-api.js** with latest available TensorFlow/JS as the original face-api.js is not compatible with **tfjs 2.0+**. Forked from **face-api.js** version **0.22.2** released on March 22nd, 2020 - - ## Differences - Removed tests, docs, examples - Updated all package dependencies - Compatible with TensorFlow/JS 2.0+ - Updated type casting for TypeScript type checking - Removed unnecesary package dependencies (karma, jasmine, etc.) - Typescript build process now targets ES2018 and instead of dual ES5/ES6 - Browser bundle process uses ESBuild instead of Rollup - New TensorFlow/JS dependencies since backends were removed from @tensorflow/tfjs-core - Updated mobileNetv1 model due to batchNorm() dependency - Fully tree shakable when imported as an ESM module - Added `version` class that returns JSON object with version of FaceAPI as well as linked TFJS - Added calls for `setPlatform` to automatically prepare TFJS in browser - 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 There are several ways to use Face-API: **Important**: This version of Face-Api does NOT pre-package `TFJS` to allow for faster downloads (it's much smaller) as well as to allow user to choose version of TFJS to use (it's compatible with any `TFJS 2.0+`). ### 1. IIFE script *Size: 936KB minified* This is simplest way for usage within Browser Simply download `dist/face-api.js`, include it in your `HTML` file & it's ready to use. ```html ``` IIFE script auto-registers global namespace `faceapi` within Window object. And if you want to access `TensorFlow/JS` classes directly, they are exported as `faceapi.tf` ### 2. ESM module *Size: 164KB non-minified* If you're using bundler *(such as rollup, webpack, esbuild)* to package your client application, you can import ESM version of FaceAPI which supports full tree shaking Note that this version does NOT pre-package `TFJS`, so you'll need to include it before you import `FaceAPI` You can use any version of `TFJS` 2.0+ ```js import * as tf from 'https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js'; // load directly from CDN import * as faceapi from 'dist/face-api.esm.js'; ``` *Experimental*: You could use same syntax within your main `JS` file if it's imported with `