# 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 - - Currently based on **`TensorFlow/JS` 2.7.0** If you want to access `TFJS` classes and methods directly, they are exported as `faceapi.tf` ### Why? Because I needed FaceAPI that does not cause version conflict with newer TFJS 2.0 that I use accross my projects And since original FaceAPI was open-source, I've released this version as well Unfortunately, changes ended up being too large for a simple pull request on original FaceaPI and it ended up being a full-fledged version on its own ### Differences - Compatible with `TensorFlow/JS 2.0+` - Compatible with `WebGL`, `CPU` and `WASM` TFJS backends - Updated all type castings for TypeScript type checking to `TypeScript 4.1` - Switched bundling from `UMD` to `ESM` + `CommonJS` This does require separate process for usage in NodeJS vs Browser, but resulting code is much lighter Fully tree shakable when imported as an `ESM` module Browser bundle process uses `ESBuild` instead of `Rollup` - Typescript build process now targets `ES2018` and instead of dual ES5/ES6 Resulting code is clean ES2018 JavaScript without polyfills - Removed old tests, docs, examples - Removed old package dependencies (`karma`, `jasmine`, `babel`, etc.) - Updated all package dependencies - Updated TensorFlow/JS dependencies since backends were removed from `@tensorflow/tfjs-core` - Updated mobileNetv1 model due to `batchNorm()` dependency - Added `version` class that returns JSON object with version of FaceAPI as well as linked TFJS - Removed `mtcnn` and `tinyYolov2` models as they were non-functional in latest public version of `Face-API` *If there is a demand, I can re-implement them back.* Which means valid models are **tinyFaceDetector** and **mobileNetv1** ## Installation Face-API ships with several pre-build versions of the library: - `dist/face-api.js`: IIFE format for client-side Browser execution - `dist/face-api.esm.js`: ESM format for client-side Browser execution with TFJS pre-bundled - `dist/face-api.esm.nobundle.js`: ESM format for client-side Browser execution without TFJS and not minified - `dist/face-api.node.js`: CommonJS format for server-side NodeJS execution with TFJS pre-bundled - `dist/face-api.node.nobundle.js`: CommonJS format for server-side NodeJS execution without TFJS and not minified Defaults are: ```json { "main": "dist/face-api.cjs", "module": "dist/face-api.esm.js", "browser": "dist/face-api.esm.js", } ``` Reason for additional `nobundle` version is if you want to include a specific version of TFJS and not rely on pre-packaged one `FaceAPI` is compatible with TFJS 2.0+ Bundled versions are ~1.1MB minified and non-bundled versions are ~169KB non-minified All versions include `sourcemap` There are several ways to use Face-API: ### 1. IIFE script *Recommened for quick tests and backward compatibility with older Browsers that do not support ESM such as IE* 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