Detalhes do pacote

test_fork_vladmandic_face-api

vladmandic142MIT0.8.7

JavaScript module for Face Detection and Face Recognition Using Tensorflow/JS

tensorflow, tf, tfjs, face

readme (leia-me)

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:

{
  "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

<script src="dist/face-api.js"><script>

IIFE script bundles TFJS and auto-registers global namespace faceapi within Window object which can be accessed directly from a <script> tag or from your JS file.

2. ESM module

Recommended for usage within Browser

2.1. Direct Import

To use ESM import directly in a Browser, you must import your script (e.g. index.js) with a type="module"

  <script src="./index.js" type="module">

and then in your index.js

  import * as faceapi from 'dist/face-api.esm.js';

or to use non-bundled version:

  import * as tf from `https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.7.0/tf.es2017.min.js`; // load tfjs directly from CDN link
  import * as faceapi from 'dist/face-api.nobundle.js';

2.2. With Bundler

Same as above, but expectation is that you've installed @vladmandic/faceapi package
and that you'll package your script using a bundler such as webpack, rollup or esbuild
in which case, you do not need to import a script as module - that depends on your bundler configuration

  import * as faceapi from '@vladmandic/face-api';

or if your bundler doesn't recognize recommended type, force usage with:

  import * as faceapi from '@vladmandic/face-api/dist/face-api.esm.js';

or to use non-bundled version

  import * as tf from `@tensorflow/tfjs`;
  import * as faceapi from '@vladmandic/face-api/dist/face-api.nobundle.js';

3. NPM module

3.1. Import CommonJS

Recommended for NodeJS projects

Install with:

  npm install @vladmandic/face-api

And then use with:

  const faceapi = require('@vladmandic/face-api');

or if you want to force CommonJS module instead of relying on recommended field:

  const faceapi = require('@vladmandic/face-api/dist/face-api.node.js');

or if you want to use a non-bundled version: Install with:

  npm install @tensorflow/tfjs
  npm install @vladmandic/face-api

And then use with:

  const tf = require('@tensorflow/tfjs');
  const faceapi = require('@vladmandic/face-api/dist/face-api.node.nobundle.js');

4. Import Sources

Recommended for complex NodeJS projects that use TFJS for other purposes and not just FaceaPI

This way you're importing FaceAPI sources directly and not a bundle, so you have to import @tensorflow/tfjs explicitly

4.1. For Browser with Bundler

4.1.1. For JavaScript projects
  import * as tf from '@tensorflow/tfjs';
  import * as faceapi from '@vladmandic/face-api/build/index.js';
4.1.2. For TypeScript projects
  import * as tf from '@tensorflow/tfjs';
  import * as faceapi from '@vladmandic/face-api/src/index.ts';

4.2. For NodeJS

4.2.1. For JavaScript projects
  const tf = require('@tensorflow/tfjs');
  const faceapi = require('@vladmandic/face-api/build/index.js');
4.1.2. For TypeScript projects
  const tf = require('@tensorflow/tfjs');
  const faceapi = require('@vladmandic/face-api/src/index.ts');

Weights

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

Build

If you want to do a full rebuild, either download npm module

npm install @vladmandic/face-api
cd node_modules/@vladmandic/face-api

or clone a git project

git clone https://github.com/vladmandic/face-api
cd face-api

Then install all dependencies and run rebuild:

npm install
npm run build

Which will compile everything in ./src into ./build and create both ESM (standard) and IIFE (minified) bundles as well as sourcemaps in ./dist

Documentation

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

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/

Note: Photos shown below are taken by me

alt text

changelog (log de mudanças)

@vladmandic/face-api

Version: 1.7.15
Description: FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS

Author: Vladimir Mandic mandic00@live.com
License: MIT
Repository: https://github.com/vladmandic/face-api

Changelog

1.7.15 2025/02/05 mandic00@live.com

origin/master 2024/09/10 mandic00@live.com

1.7.14 2024/09/10 mandic00@live.com

  • rebuild
  • merge pull request #188 from rebser/master
  • fixing leaking eventhandlers when using htmlcanvaselement
  • rebuild types
  • rebuild

1.7.13 2024/01/17 mandic00@live.com

  • merge pull request #186 from khwalkowicz/master
  • feat: enable noimplicitany

release: 1.7.12 2023/06/12 mandic00@live.com

1.7.12 2023/06/12 mandic00@live.com

1.7.11 2023/05/08 mandic00@live.com

1.7.10 2023/03/21 mandic00@live.com

  • change typedefs

1.7.9 2023/01/29 mandic00@live.com

1.7.8 2023/01/06 mandic00@live.com

1.7.7 2022/12/01 mandic00@live.com

1.7.6 2022/10/18 mandic00@live.com

  • fix face angles (yaw, pitch, & roll) accuracy (#130)

1.7.5 2022/10/09 mandic00@live.com

  • create funding.yml
  • add node-wasm demo

1.7.4 2022/09/25 mandic00@live.com

  • improve face compare performance

1.7.3 2022/08/24 mandic00@live.com

  • refresh release

1.7.2 2022/08/23 mandic00@live.com

  • document and remove optional dependencies

release: 1.7.1 2022/07/25 mandic00@live.com

1.7.1 2022/07/25 mandic00@live.com

  • refactor dependencies
  • full rebuild

1.6.11 2022/05/24 mandic00@live.com

1.6.10 2022/05/24 mandic00@live.com

1.6.9 2022/05/18 mandic00@live.com

1.6.8 2022/05/09 mandic00@live.com

  • exclude impossible detected face boxes

1.6.7 2022/04/01 mandic00@live.com

  • fixed typo error (#97)

1.6.6 2022/03/04 mandic00@live.com

1.6.5 2022/02/07 mandic00@live.com

1.6.4 2022/01/14 mandic00@live.com

  • add node with wasm build target

1.6.3 2022/01/06 mandic00@live.com

1.6.2 2022/01/01 mandic00@live.com

1.6.1 2021/12/09 mandic00@live.com

  • rebuild
  • release preview
  • switch to custom tfjs and new typedefs
  • rebuild

1.5.8 2021/11/30 mandic00@live.com

1.5.7 2021/10/28 mandic00@live.com

1.5.6 2021/10/22 mandic00@live.com

release: 1.5.5 2021/10/19 mandic00@live.com

1.5.5 2021/10/19 mandic00@live.com

  • allow backend change in demo via url params
  • add node-match demo
  • fix face matcher

1.5.4 2021/09/29 mandic00@live.com

1.5.3 2021/09/16 mandic00@live.com

  • simplify tfjs imports
  • reduce bundle size
  • enable webgl uniforms

1.5.2 2021/09/10 mandic00@live.com

  • redesign build platform

1.5.1 2021/09/08 mandic00@live.com

1.4.2 2021/08/31 mandic00@live.com

release: 1.4.1 2021/07/29 mandic00@live.com

1.4.1 2021/07/29 mandic00@live.com

release: 1.3.1 2021/06/18 mandic00@live.com

1.3.1 2021/06/08 mandic00@live.com

  • fix face expression detection (#56)
  • add buffertovideo
  • fix git conflicts
  • fix tsc error (#55)
  • force typescript 4.2 due to typedoc incompatibility with ts 4.3

1.2.5 2021/05/27 mandic00@live.com

  • add buffertovideo and fetchvideo (#54)

1.2.4 2021/05/18 mandic00@live.com

1.2.3 2021/05/04 mandic00@live.com

update for tfjs 3.6.0 2021/04/30 mandic00@live.com

1.2.2 2021/04/30 mandic00@live.com

  • add node-wasm demo
  • accept uri as input to demo node and node-canvas
  • major version full rebuild

1.2.1 2021/04/22 mandic00@live.com

  • add npmrc
  • add canvas/image based demo to decode webp

1.1.12 2021/04/13 mandic00@live.com

1.1.11 2021/04/06 mandic00@live.com

  • merge pull request #46 from mayankagarwals/demo_latencytest_fix
  • fixed bug which led to latency not being measured and wrong output on console for demo
  • add cdn links

1.1.10 2021/04/04 mandic00@live.com

  • added webhints

1.1.9 2021/04/03 mandic00@live.com

  • fix linting and tests

1.1.8 2021/04/01 mandic00@live.com

1.1.7 2021/03/31 mandic00@live.com

  • enable minify

1.1.6 2021/03/26 mandic00@live.com

1.1.5 2021/03/23 mandic00@live.com

  • add node-canvas demo
  • refactoring

1.1.4 2021/03/18 mandic00@live.com

1.1.3 2021/03/16 mandic00@live.com

  • fix for seedrandom

1.1.2 2021/03/15 mandic00@live.com

  • create templates
  • create codeql-analysis.yml

1.1.1 2021/03/14 mandic00@live.com

  • full rebuild
  • reformatted model manifests and weights
  • create api specs

1.0.2 2021/03/09 mandic00@live.com

release: 1.0.1 2021/03/09 mandic00@live.com

1.0.1 2021/03/09 mandic00@live.com

  • add badges
  • optimize for npm
  • 0.30.6
  • added typings for face angle
  • disable landmark printing
  • 0.30.5
  • enabled live demo on gitpages
  • 0.30.4
  • added face angle calculations
  • added documentation
  • package update
  • 0.30.3
  • 0.30.2
  • 0.30.1
  • 0.13.3
  • added note-cpu target
  • merge pull request #39 from xemle/feature/node-cpu
  • add node-cpu build for non supported systems of libtensorflow
  • 0.13.2
  • 0.13.1
  • 0.12.10
  • exception handling
  • 0.12.9
  • exception handling
  • 0.12.8
  • exception handling

0.12.7 2021/02/17 mandic00@live.com

  • 0.12.7
  • 0.12.6
  • 0.12.5
  • 0.12.4
  • 0.12.3
  • 0.12.2

update for tfjs 3.0.0 2021/01/29 mandic00@live.com

  • 0.12.1
  • rebuild
  • 0.11.6
  • add check for null face descriptor
  • merge pull request #34 from patrickhulce/patch-1
  • fix: return empty descriptor for zero-sized faces
  • 0.11.5
  • 0.11.4
  • 0.11.3
  • fix typo
  • enable full minification
  • 0.11.2
  • full rebuild
  • 0.11.1
  • added live webcam demo
  • 0.10.2
  • ts linting
  • version bump
  • 0.10.1
  • full re-lint and typings generation
  • rebuild

0.9.5 2020/12/19 mandic00@live.com

  • added tsc build typings

0.9.4 2020/12/15 mandic00@live.com

  • package update

0.9.3 2020/12/12 mandic00@live.com

0.9.2 2020/12/08 mandic00@live.com

  • merge pull request #19 from meeki007/patch-3
  • remove http reff
  • fixed typos

0.9.1 2020/12/02 mandic00@live.com

  • redesigned tfjs bundling and build process
  • push
  • merge pull request #17 from meeki007/patch-2
  • merge pull request #16 from meeki007/patch-1
  • added link to documentation for js.tensorflow 2.7.0
  • add comments and fix typo

0.8.9 2020/11/25 mandic00@live.com

  • removed node-fetch dependency

0.8.8 2020/11/03 mandic00@live.com

0.8.7 2020/11/03 mandic00@live.com

  • removed type from package.json and added nodejs example

0.8.6 2020/10/29 mandic00@live.com

0.8.5 2020/10/27 mandic00@live.com

0.8.4 2020/10/27 mandic00@live.com

  • fix webpack compatibility issue

0.8.3 2020/10/25 mandic00@live.com

0.8.2 2020/10/25 mandic00@live.com

  • fix for wasm compatibility

0.8.1 2020/10/15 mandic00@live.com

  • added cjs builds

0.7.4 2020/10/14 mandic00@live.com

  • added nobundle

0.7.3 2020/10/13 mandic00@live.com

0.7.2 2020/10/13 mandic00@live.com

0.7.1 2020/10/13 mandic00@live.com

  • switched to monolithic build

0.6.3 2020/10/12 mandic00@live.com

0.6.2 2020/10/11 mandic00@live.com

0.6.1 2020/10/11 mandic00@live.com

  • major update
  • tfjs 2.6.0

0.5.3 2020/09/18 cyan00@gmail.com

0.5.2 2020/09/16 cyan00@gmail.com

  • added build for node
  • upgrade to tfjs@2.4.0 and ts-node@9.0.0
  • create issue.md
  • added issue template
  • added faceapi.version object

0.5.1 2020/09/08 cyan00@gmail.com

0.4.6 2020/09/08 cyan00@gmail.com

  • added test fot @tfjs and backends loaded

0.4.5 2020/08/31 cyan00@gmail.com

  • adding build

0.4.4 2020/08/30 cyan00@gmail.com

  • change build process

0.4.3 2020/08/29 cyan00@gmail.com

  • fix node build error

0.4.2 2020/08/29 cyan00@gmail.com

0.4.1 2020/08/27 cyan00@gmail.com

0.3.9 2020/08/27 cyan00@gmail.com

  • added example

0.3.8 2020/08/26 cyan00@gmail.com

  • re-added ssd_mobilenet

0.3.7 2020/08/22 cyan00@gmail.com

0.3.6 2020/08/21 cyan00@gmail.com

0.3.5 2020/08/19 cyan00@gmail.com

0.3.4 2020/08/19 cyan00@gmail.com

  • switch to commonjs and es2018 for compatibility

0.3.3 2020/08/19 cyan00@gmail.com

0.3.2 2020/08/18 cyan00@gmail.com

0.3.1 2020/08/18 cyan00@gmail.com

  • uodated build script
  • npm publish
  • added pre-compiled build
  • added pre-bundled dist
  • removed unnecessary weights
  • initial commit