ml5.js
has created an API to face-api.js
that allows you to access face and face landmark detection.
The ml5.js
implementation of face-api does not support expressions, age or gender estimation.
Quickstart :
const detectionOptions = {
withLandmarks: true,
withDescriptors: false,
};
// Initialize the magicFeature
const faceapi = ml5.faceApi(detectionOptions, modelLoaded);
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
// Make some sparkles
faceapi.detect(myImage, (err, results) => {
console.log(results);
});
}
Usage :
Initialize :
const faceapi = ml5.faceApi(videoOrOptionsOrCallback, optionsOrCallback?, callback?);
Parameters :
* videoOrOptionsOrCallback : REQUIRED. Notice there is no question mark in front of the input.
* optionsOrCallback : OPTIONAL. Notice the ? indicates an optional parameter.
* callback : OPTIONAL. A description of some kind of object with some properties. Notice the ? indicates an optional parameter.
{
withLandmarks: true,
withDescriptors: true,
minConfidence: 0.5,
MODEL_URLS: {
Mobilenetv1Model: 'https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/ssd_mobilenetv1_model-weights_manifest.json',
FaceLandmarkModel: 'https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_landmark_68_model-weights_manifest.json',
FaceLandmark68TinyNet: 'https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_landmark_68_tiny_model-weights_manifest.json',
FaceRecognitionModel: 'https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_recognition_model-weights_manifest.json',
},
};