Add real-time face detection to a webcam video stream and draw bounding boxes on a canvas overlay in the browser.
Build a photo gallery app that automatically groups pictures by recognized person using face descriptors.
Create a browser experiment that detects facial expressions and triggers animations in response to smiles.
Model weight files must be self-hosted and loaded before inference, Node.js use also requires the node-canvas package.
face-api.js is a JavaScript library for doing face detection and face recognition right inside a web browser or a Node.js program. It is built on top of tensorflow.js, the JavaScript version of the TensorFlow machine-learning toolkit, so all the math runs in the browser or in Node using a native TensorFlow binding. There is no server call needed once the model files are loaded, which makes it handy for privacy-sensitive or offline use. The library bundles several pretrained neural networks and exposes them through a high-level API. You feed it an image, video, or canvas element, and it can find faces in the frame, mark 68 landmark points on each face, compute a numeric descriptor used to recognize who a face belongs to, classify the facial expression, and estimate age and gender. Internally it ships multiple detector options including an SSD MobileNet v1 model, a Tiny Face Detector, and a tiny YOLO v2, plus separate networks for landmarks, recognition, expressions, and age and gender. To use them you copy the model manifest and weight shard files into your project, then call loadFromUri or loadFromDisk to pull them into memory, and then call helpers like detectAllFaces on an input. You would reach for this when adding face-aware features to a web or Node app, a webcam demo that draws boxes around faces, a photo gallery that groups pictures by person, or an interactive toy that reacts to smiles. The repository is written in TypeScript and compiles to a browser bundle in dist as well as an npm package. Node usage is supported by polyfilling browser image and canvas APIs, the README suggests the node-canvas package and recommends @tensorflow/tfjs-node for speed.
← justadudewhohacks on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.