@@ -16,6 +16,7 @@ Table of Contents:
16
16
* ** [ Face Detection Models] ( #models-face-detection ) **
17
17
* ** [ 68 Point Face Landmark Detection Models] ( #models-face-landmark-detection ) **
18
18
* ** [ Face Recognition Model] ( #models-face-recognition ) **
19
+ * ** [ Face Expression Recognition Model] ( #models-face-expression-recognition ) **
19
20
* ** [ Getting Started] ( #getting-started ) **
20
21
* ** [ face-api.js for the Browser] ( #getting-started-browser ) **
21
22
* ** [ face-api.js for Nodejs] ( #getting-started-nodejs ) **
@@ -61,6 +62,10 @@ Check out my face-api.js tutorials:
61
62
62
63
![ preview_face-similarity] ( https://user-images.githubusercontent.com/31125521/40316573-0a1190c0-5d1f-11e8-8797-f6deaa344523.gif )
63
64
65
+ ## Face Expression Recognition
66
+
67
+ ![ preview_face-expression-recognition] ( https://user-images.githubusercontent.com/31125521/50575270-f501d080-0dfb-11e9-9676-8f419efdade4.png )
68
+
64
69
## Face Landmark Detection
65
70
66
71
![ face_landmarks_boxes_2] ( https://user-images.githubusercontent.com/31125521/46063404-00928b00-c16d-11e8-8f29-e9c50afd2bc8.jpg )
@@ -161,6 +166,12 @@ The neural net is equivalent to the **FaceRecognizerNet** used in [face-recognit
161
166
162
167
The size of the quantized model is roughly 6.2 MB (** face_recognition_model** ).
163
168
169
+ <a name =" models-face-expression-recognition " ></a >
170
+
171
+ ## Face Expression Recognition Model
172
+
173
+ The face expression recognition model is lightweight, fast and provides reasonable accuracy. The model has a size of roughly 310kb and it employs depthwise separable convolutions and densely connected blocks. It has been trained on a variety of images from publicly available datasets as well as images scraped from the web. Note, that wearing glasses might decrease the accuracy of the prediction results.
174
+
164
175
<a name =" getting-started " ></a >
165
176
166
177
# Getting Started
@@ -228,6 +239,7 @@ await faceapi.loadSsdMobilenetv1Model('/models')
228
239
// await faceapi.loadFaceLandmarkModel('/models')
229
240
// await faceapi.loadFaceLandmarkTinyModel('/models')
230
241
// await faceapi.loadFaceRecognitionModel('/models')
242
+ // await faceapi.loadFaceExpressionModel('/models')
231
243
```
232
244
233
245
All global neural network instances are exported via faceapi.nets:
@@ -354,6 +366,42 @@ Detect the face with the highest confidence score in an image + computes 68 Poin
354
366
const result = await faceapi .detectSingleFace (input).withFaceLandmarks ().withFaceDescriptor ()
355
367
```
356
368
369
+ ### Recognizing Face Expressions
370
+
371
+ ** Face expressions recognition can be performed for detected faces as follows:**
372
+
373
+ Detect all faces in an image + recognize face expressions. Returns ** Array<[ WithFaceExpressions<WithFaceDetection<{}>>] ( #usage-utility-classes ) >** :
374
+
375
+ ``` javascript
376
+ const detectionsWithExpressions = await faceapi .detectAllFaces (input).withFaceExpressions ()
377
+ ```
378
+
379
+ Detect the face with the highest confidence score in an image + recognize the face expression for that face. Returns ** [ WithFaceExpressions<WithFaceDetection<{}>>] ( #usage-utility-classes ) | undefined** :
380
+
381
+ ``` javascript
382
+ const detectionWithExpressions = await faceapi .detectSingleFace (input).withFaceExpressions ()
383
+ ```
384
+
385
+ ### Composition of Tasks
386
+
387
+ ** Tasks can be composed as follows:**
388
+
389
+ ``` javascript
390
+ // all faces
391
+ await faceapi .detectAllFaces (input)
392
+ await faceapi .detectAllFaces (input).withFaceExpressions ()
393
+ await faceapi .detectAllFaces (input).withFaceLandmarks ()
394
+ await faceapi .detectAllFaces (input).withFaceExpressions ().withFaceLandmarks ()
395
+ await faceapi .detectAllFaces (input).withFaceExpressions ().withFaceLandmarks ().withFaceDescriptors ()
396
+
397
+ // single face
398
+ await faceapi .detectSingleFace (input)
399
+ await faceapi .detectSingleFace (input).withFaceExpressions ()
400
+ await faceapi .detectSingleFace (input).withFaceLandmarks ()
401
+ await faceapi .detectSingleFace (input).withFaceExpressions ().withFaceLandmarks ()
402
+ await faceapi .detectSingleFace (input).withFaceExpressions ().withFaceLandmarks ().withFaceDescriptor ()
403
+ ```
404
+
357
405
### Face Recognition by Matching Descriptors
358
406
359
407
To perform face recognition, one can use faceapi.FaceMatcher to compare reference face descriptors to query face descriptors.
@@ -611,6 +659,23 @@ export type WithFaceDescriptor<TSource> TSource & {
611
659
}
612
660
```
613
661
662
+ <a name =" with-face-expressions " ></a >
663
+
664
+ ### WithFaceExpressions
665
+
666
+ ``` javascript
667
+ export type FaceExpression = ' neutral' | ' happy' | ' sad' | ' angry' | ' fearful' | ' disgusted' | ' surprised'
668
+
669
+ export type FaceExpressionPrediction = {
670
+ expression : FaceExpression ,
671
+ probability : number
672
+ }
673
+
674
+ export type WithFaceExpressions < TSource > TSource & {
675
+ expressions : FaceExpressionPrediction []
676
+ }
677
+ ```
678
+
614
679
<a name =" other-useful-utility " ></a >
615
680
616
681
## Other Useful Utility
0 commit comments