Skip to content

Commit 2ce9519

Browse files
added tiny yolov2 usage and description to readme
1 parent 5c0d69a commit 2ce9519

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,28 @@ Check out my face-api.js tutorials:
99
* **[face-api.js — JavaScript API for Face Recognition in the Browser with tensorflow.js](https://itnext.io/face-api-js-javascript-api-for-face-recognition-in-the-browser-with-tensorflow-js-bcc2a6c4cf07)**
1010
* **[Realtime JavaScript Face Tracking and Face Recognition using face-api.js’ MTCNN Face Detector](https://itnext.io/realtime-javascript-face-tracking-and-face-recognition-using-face-api-js-mtcnn-face-detector-d924dd8b5740)**
1111

12+
**Check out the live demos [here](https://justadudewhohacks.github.io/face-api.js/)!**
13+
1214
Table of Contents:
1315

1416
* **[Running the Examples](#running-the-examples)**
1517
* **[About the Package](#about-the-package)**
1618
* **[Face Detection - SSD Mobilenet v1](#about-face-detection-ssd)**
19+
* **[Face Detection - Tiny Yolo v2](#about-face-detection-yolo)**
1720
* **[Face Detection & 5 Point Face Landmarks - MTCNN](#about-face-detection-mtcnn)**
1821
* **[Face Recognition](#about-face-recognition)**
1922
* **[68 Point Face Landmark Detection](#about-face-landmark-detection)**
2023
* **[Usage](#usage)**
2124
* **[Loading the Models](#usage-load-models)**
2225
* **[Face Detection - SSD Mobilenet v1](#usage-face-detection-ssd)**
26+
* **[Face Detection - Tiny Yolo v2](#usage-face-detection-yolo)**
2327
* **[Face Detection & 5 Point Face Landmarks - MTCNN](#usage-face-detection-mtcnn)**
2428
* **[Face Recognition](#usage-face-recognition)**
2529
* **[68 Point Face Landmark Detection](#usage-face-landmark-detection)**
2630
* **[Full Face Detection and Recognition Pipeline](#usage-full-face-detection-and-recognition-pipeline)**
2731

2832
## Examples
2933

30-
### **Check out the live demos [here](https://justadudewhohacks.github.io/face-api.js/)!**
31-
3234
### Face Recognition
3335

3436
![preview_face-detection-and-recognition](https://user-images.githubusercontent.com/31125521/41526995-1a90e4e6-72e6-11e8-96d4-8b2ccdee5f79.gif)
@@ -83,11 +85,19 @@ For face detection, this project implements a SSD (Single Shot Multibox Detector
8385

8486
The face detection model has been trained on the [WIDERFACE dataset](http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/) and the weights are provided by [yeephycho](https://github.com/yeephycho) in [this](https://github.com/yeephycho/tensorflow-face-detection) repo.
8587

88+
<a name="about-face-detection-yolo"></a>
89+
90+
### Face Detection - Tiny Yolo v2
91+
92+
The Tiny Yolo v2 based face detector can easily adapt to different input image sizes, thus can be used as an alternative to SSD Mobilenet v1 to trade off accuracy for performance (inference time). In general the model is not as accurate as SSD Mobilenet v1 but can achieve faster inference for lower image sizes.
93+
94+
The Tiny Yolo v2 implementation is still experimental, meaning there is room for optimization (future work). The trained model weights are provided in the [azFace](https://github.com/azmathmoosa/azFace) project.
95+
8696
<a name="about-face-detection-mtcnn"></a>
8797

8898
### Face Detection & 5 Point Face Landmarks - MTCNN
8999

90-
MTCNN (Multi-task Cascaded Convolutional Neural Networks) represents an alternative to SSD Mobilenet v1, which offers much more room for configuration and is able to achieve much lower processing times. MTCNN is a 3 stage cascaded CNN, which simultanously returns 5 face landmark points along with the bounding boxes and scores for each face. By limiting the minimum size of faces expected in an image, MTCNN allows you to process frames from your webcam in realtime. Additionally with 2MB, the size of the weights file is only a third of the size of the quantized SSD Mobilenet v1 model (~6MB).
100+
MTCNN (Multi-task Cascaded Convolutional Neural Networks) represents an alternative face detector to SSD Mobilenet v1 and Tiny Yolo v2, which offers much more room for configuration and is able to achieve much lower processing times. MTCNN is a 3 stage cascaded CNN, which simultanously returns 5 face landmark points along with the bounding boxes and scores for each face. By limiting the minimum size of faces expected in an image, MTCNN allows you to process frames from your webcam in realtime. Additionally with 2MB, the size of the weights file is only a third of the size of the quantized SSD Mobilenet v1 model (~6MB).
91101

92102
MTCNN has been presented in the paper [Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks](https://kpzhang93.github.io/MTCNN_face_detection_alignment/paper/spl.pdf) by Zhang et al. and the model weights are provided in the official [repo](https://github.com/kpzhang93/MTCNN_face_detection_alignment) of the MTCNN implementation.
93103

@@ -137,6 +147,7 @@ await faceapi.loadFaceDetectionModel('/models')
137147
// await faceapi.loadFaceLandmarkModel('/models')
138148
// await faceapi.loadFaceRecognitionModel('/models')
139149
// await faceapi.loadMtcnnModel('/models')
150+
// await faceapi.loadTinyYolov2Model('/models')
140151
```
141152

142153
As an alternative, you can also create instance of the neural nets:
@@ -147,11 +158,13 @@ const net = new faceapi.FaceDetectionNet()
147158
// const net = new faceapi.FaceLandmarkNet()
148159
// const net = new faceapi.FaceRecognitionNet()
149160
// const net = new faceapi.Mtcnn()
161+
// const net = new faceapi.TinyYolov2()
150162

151163
await net.load('/models/face_detection_model-weights_manifest.json')
152164
// await net.load('/models/face_landmark_68_model-weights_manifest.json')
153165
// await net.load('/models/face_recognition_model-weights_manifest.json')
154166
// await net.load('/models/mtcnn_model-weights_manifest.json')
167+
// await net.load('/models/tiny_yolov2_model-weights_manifest.json')
155168

156169
// or simply load all models
157170
await net.load('/models')
@@ -204,6 +217,24 @@ You can also obtain the tensors of the unfiltered bounding boxes and scores for
204217
const { boxes, scores } = await net.forward('myImg')
205218
```
206219

220+
<a name="usage-face-detection-yolo"></a>
221+
222+
### Face Detection - Tiny Yolo v2
223+
224+
Detect faces and get the bounding boxes and scores:
225+
226+
``` javascript
227+
// defaults parameters shown:
228+
const forwardParams = {
229+
scoreThreshold: 0.5,
230+
// any number or one of the predifened sizes:
231+
// 'xs' (224 x 224) | 'sm' (320 x 320) | 'md' (416 x 416) | 'lg' (608 x 608)
232+
inputSize: 'md'
233+
}
234+
235+
const detections = await faceapi.tinyYolov2(document.getElementById('myImg'), forwardParams)
236+
```
237+
207238
<a name="usage-face-detection-mtcnn"></a>
208239

209240
### Face Detection & 5 Point Face Landmarks - MTCNN

0 commit comments

Comments
 (0)