Commit b298c2a4 by vincent

add depecration warnings for allFaces and mtcnn and remove mtcnn from examples

parent feac639c
...@@ -135,8 +135,7 @@ import * as canvas from 'canvas'; ...@@ -135,8 +135,7 @@ import * as canvas from 'canvas';
import * as faceapi from 'face-api.js'; import * as faceapi from 'face-api.js';
// patch nodejs environment, we need to provide an implementation of // patch nodejs environment, we need to provide an implementation of
// HTMLCanvasElement and HTMLImageElement, additionally an implementation // HTMLCanvasElement and HTMLImageElement
// of ImageData is required, in case you want to use the MTCNN
const { Canvas, Image, ImageData } = canvas const { Canvas, Image, ImageData } = canvas
faceapi.env.monkeyPatch({ Canvas, Image, ImageData }) faceapi.env.monkeyPatch({ Canvas, Image, ImageData })
``` ```
...@@ -160,7 +159,6 @@ console.log(faceapi.nets) ...@@ -160,7 +159,6 @@ console.log(faceapi.nets)
// faceRecognitionNet // faceRecognitionNet
// ssdMobilenetv1 // ssdMobilenetv1
// tinyFaceDetector // tinyFaceDetector
// mtcnn
// tinyYolov2 // tinyYolov2
``` ```
...@@ -246,7 +244,6 @@ By default **detectAllFaces** and **detectSingleFace** utilize the SSD Mobilenet ...@@ -246,7 +244,6 @@ By default **detectAllFaces** and **detectSingleFace** utilize the SSD Mobilenet
``` javascript ``` javascript
const detections1 = await faceapi.detectAllFaces(input, new faceapi.SsdMobilenetv1Options()) const detections1 = await faceapi.detectAllFaces(input, new faceapi.SsdMobilenetv1Options())
const detections2 = await faceapi.detectAllFaces(input, new faceapi.TinyFaceDetectorOptions()) const detections2 = await faceapi.detectAllFaces(input, new faceapi.TinyFaceDetectorOptions())
const detections3 = await faceapi.detectAllFaces(input, new faceapi.MtcnnOptions())
``` ```
You can tune the options of each face detector as shown [here](#getting-started-face-detection-options). You can tune the options of each face detector as shown [here](#getting-started-face-detection-options).
...@@ -592,40 +589,6 @@ export interface ITinyFaceDetectorOptions { ...@@ -592,40 +589,6 @@ export interface ITinyFaceDetectorOptions {
const options = new faceapi.TinyFaceDetectorOptions({ inputSize: 320 }) const options = new faceapi.TinyFaceDetectorOptions({ inputSize: 320 })
``` ```
### MtcnnOptions
``` javascript
export interface IMtcnnOptions {
// minimum face size to expect, the higher the faster processing will be,
// but smaller faces won't be detected
// default: 20
minFaceSize?: number
// the score threshold values used to filter the bounding
// boxes of stage 1, 2 and 3
// default: [0.6, 0.7, 0.7]
scoreThresholds?: number[]
// scale factor used to calculate the scale steps of the image
// pyramid used in stage 1
// default: 0.709
scaleFactor?: number
// number of scaled versions of the input image passed through the CNN
// of the first stage, lower numbers will result in lower inference time,
// but will also be less accurate
// default: 10
maxNumScales?: number
// instead of specifying scaleFactor and maxNumScales you can also
// set the scaleSteps manually
scaleSteps?: number[]
}
// example
const options = new faceapi.MtcnnOptions({ minFaceSize: 100, scaleFactor: 0.8 })
```
<a name="getting-started-utility-classes"></a> <a name="getting-started-utility-classes"></a>
## Utility Classes ## Utility Classes
...@@ -726,7 +689,6 @@ Instead of using the high level API, you can directly use the forward methods of ...@@ -726,7 +689,6 @@ Instead of using the high level API, you can directly use the forward methods of
``` javascript ``` javascript
const detections1 = await faceapi.ssdMobilenetv1(input, options) const detections1 = await faceapi.ssdMobilenetv1(input, options)
const detections2 = await faceapi.tinyFaceDetector(input, options) const detections2 = await faceapi.tinyFaceDetector(input, options)
const detections3 = await faceapi.mtcnn(input, options)
const landmarks1 = await faceapi.detectFaceLandmarks(faceImage) const landmarks1 = await faceapi.detectFaceLandmarks(faceImage)
const landmarks2 = await faceapi.detectFaceLandmarksTiny(faceImage) const landmarks2 = await faceapi.detectFaceLandmarksTiny(faceImage)
const descriptor = await faceapi.computeFaceDescriptor(alignedFaceImage) const descriptor = await faceapi.computeFaceDescriptor(alignedFaceImage)
...@@ -839,14 +801,6 @@ The face detector has been trained on a custom dataset of ~14K images labeled wi ...@@ -839,14 +801,6 @@ The face detector has been trained on a custom dataset of ~14K images labeled wi
This model is basically an even tinier version of Tiny Yolo V2, replacing the regular convolutions of Yolo with depthwise separable convolutions. Yolo is fully convolutional, thus can easily adapt to different input image sizes to trade off accuracy for performance (inference time). This model is basically an even tinier version of Tiny Yolo V2, replacing the regular convolutions of Yolo with depthwise separable convolutions. Yolo is fully convolutional, thus can easily adapt to different input image sizes to trade off accuracy for performance (inference time).
### MTCNN
**Note, this model is mostly kept in this repo for experimental reasons. In general the other face detectors should perform better, but of course you are free to play around with MTCNN.**
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. By tuning the input parameters, MTCNN should be able to detect a wide range of face bounding box sizes. MTCNN is a 3 stage cascaded CNN, which simultaneously returns 5 face landmark points along with the bounding boxes and scores for each face. Additionally the model size is only 2MB.
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.
<a name="models-face-landmark-detection"></a> <a name="models-face-landmark-detection"></a>
## 68 Point Face Landmark Detection Models ## 68 Point Face Landmark Detection Models
......
const SSD_MOBILENETV1 = 'ssd_mobilenetv1' const SSD_MOBILENETV1 = 'ssd_mobilenetv1'
const TINY_FACE_DETECTOR = 'tiny_face_detector' const TINY_FACE_DETECTOR = 'tiny_face_detector'
const MTCNN = 'mtcnn'
let selectedFaceDetector = SSD_MOBILENETV1 let selectedFaceDetector = SSD_MOBILENETV1
...@@ -12,17 +11,10 @@ let minConfidence = 0.5 ...@@ -12,17 +11,10 @@ let minConfidence = 0.5
let inputSize = 512 let inputSize = 512
let scoreThreshold = 0.5 let scoreThreshold = 0.5
//mtcnn options
let minFaceSize = 20
function getFaceDetectorOptions() { function getFaceDetectorOptions() {
return selectedFaceDetector === SSD_MOBILENETV1 return selectedFaceDetector === SSD_MOBILENETV1
? new faceapi.SsdMobilenetv1Options({ minConfidence }) ? new faceapi.SsdMobilenetv1Options({ minConfidence })
: ( : new faceapi.TinyFaceDetectorOptions({ inputSize, scoreThreshold })
selectedFaceDetector === TINY_FACE_DETECTOR
? new faceapi.TinyFaceDetectorOptions({ inputSize, scoreThreshold })
: new faceapi.MtcnnOptions({ minFaceSize })
)
} }
function onIncreaseMinConfidence() { function onIncreaseMinConfidence() {
...@@ -79,9 +71,6 @@ function getCurrentFaceDetectionNet() { ...@@ -79,9 +71,6 @@ function getCurrentFaceDetectionNet() {
if (selectedFaceDetector === TINY_FACE_DETECTOR) { if (selectedFaceDetector === TINY_FACE_DETECTOR) {
return faceapi.nets.tinyFaceDetector return faceapi.nets.tinyFaceDetector
} }
if (selectedFaceDetector === MTCNN) {
return faceapi.nets.mtcnn
}
} }
function isFaceDetectionModelLoaded() { function isFaceDetectionModelLoaded() {
...@@ -89,7 +78,7 @@ function isFaceDetectionModelLoaded() { ...@@ -89,7 +78,7 @@ function isFaceDetectionModelLoaded() {
} }
async function changeFaceDetector(detector) { async function changeFaceDetector(detector) {
['#ssd_mobilenetv1_controls', '#tiny_face_detector_controls', '#mtcnn_controls'] ['#ssd_mobilenetv1_controls', '#tiny_face_detector_controls']
.forEach(id => $(id).hide()) .forEach(id => $(id).hide())
selectedFaceDetector = detector selectedFaceDetector = detector
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -111,29 +110,6 @@ ...@@ -111,29 +110,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -112,29 +111,6 @@ ...@@ -112,29 +111,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -111,29 +110,6 @@ ...@@ -111,29 +110,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -111,29 +110,6 @@ ...@@ -111,29 +110,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -107,29 +106,6 @@ ...@@ -107,29 +106,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</div> </div>
<script> <script>
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -118,29 +117,6 @@ ...@@ -118,29 +117,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -147,29 +146,6 @@ ...@@ -147,29 +146,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</div> </div>
</body> </body>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -114,29 +113,6 @@ ...@@ -114,29 +113,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -114,29 +113,6 @@ ...@@ -114,29 +113,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -107,29 +106,6 @@ ...@@ -107,29 +106,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -114,29 +113,6 @@ ...@@ -114,29 +113,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<select id="selectFaceDetector"> <select id="selectFaceDetector">
<option value="ssd_mobilenetv1">SSD Mobilenet V1</option> <option value="ssd_mobilenetv1">SSD Mobilenet V1</option>
<option value="tiny_face_detector">Tiny Face Detector</option> <option value="tiny_face_detector">Tiny Face Detector</option>
<option value="mtcnn">MTCNN</option>
</select> </select>
<label>Select Face Detector</label> <label>Select Face Detector</label>
</div> </div>
...@@ -114,29 +113,6 @@ ...@@ -114,29 +113,6 @@
</span> </span>
<!-- tiny_face_detector_controls --> <!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span id="mtcnn_controls">
<div class="row side-by-side">
<div class="row">
<label for="minFaceSize">Minimum Face Size:</label>
<input disabled value="20" id="minFaceSize" type="text" class="bold">
</div>
<button
class="waves-effect waves-light btn"
onclick="onDecreaseMinFaceSize()"
>
<i class="material-icons left">-</i>
</button>
<button
class="waves-effect waves-light btn"
onclick="onIncreaseMinFaceSize()"
>
<i class="material-icons left">+</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body> </body>
<script> <script>
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
// not required, but will speed up things drastically (python required) // not required, but will speed up things drastically (python required)
import '@tensorflow/tfjs-node'; import '@tensorflow/tfjs-node';
import * as faceapi from 'face-api.js';
// implements nodejs wrappers for HTMLCanvasElement, HTMLImageElement, ImageData // implements nodejs wrappers for HTMLCanvasElement, HTMLImageElement, ImageData
const canvas = require('canvas') const canvas = require('canvas')
import * as faceapi from 'face-api.js';
// patch nodejs environment, we need to provide an implementation of // patch nodejs environment, we need to provide an implementation of
// HTMLCanvasElement and HTMLImageElement, additionally an implementation // HTMLCanvasElement and HTMLImageElement
// of ImageData is required, in case you want to use the MTCNN
const { Canvas, Image, ImageData } = canvas const { Canvas, Image, ImageData } = canvas
faceapi.env.monkeyPatch({ Canvas, Image, ImageData }) faceapi.env.monkeyPatch({ Canvas, Image, ImageData })
......
...@@ -2,7 +2,6 @@ import * as faceapi from 'face-api.js'; ...@@ -2,7 +2,6 @@ import * as faceapi from 'face-api.js';
export const faceDetectionNet = faceapi.nets.ssdMobilenetv1 export const faceDetectionNet = faceapi.nets.ssdMobilenetv1
// export const faceDetectionNet = tinyFaceDetector // export const faceDetectionNet = tinyFaceDetector
// export const faceDetectionNet = mtcnn
// SsdMobilenetv1Options // SsdMobilenetv1Options
const minConfidence = 0.5 const minConfidence = 0.5
...@@ -11,17 +10,10 @@ const minConfidence = 0.5 ...@@ -11,17 +10,10 @@ const minConfidence = 0.5
const inputSize = 408 const inputSize = 408
const scoreThreshold = 0.5 const scoreThreshold = 0.5
// MtcnnOptions
const minFaceSize = 50
const scaleFactor = 0.8
function getFaceDetectorOptions(net: faceapi.NeuralNetwork<any>) { function getFaceDetectorOptions(net: faceapi.NeuralNetwork<any>) {
return net === faceapi.nets.ssdMobilenetv1 return net === faceapi.nets.ssdMobilenetv1
? new faceapi.SsdMobilenetv1Options({ minConfidence }) ? new faceapi.SsdMobilenetv1Options({ minConfidence })
: (net === faceapi.nets.tinyFaceDetector : new faceapi.TinyFaceDetectorOptions({ inputSize, scoreThreshold })
? new faceapi.TinyFaceDetectorOptions({ inputSize, scoreThreshold })
: new faceapi.MtcnnOptions({ minFaceSize, scaleFactor })
)
} }
export const faceDetectionOptions = getFaceDetectorOptions(faceDetectionNet) export const faceDetectionOptions = getFaceDetectorOptions(faceDetectionNet)
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ let spec_files = ['**/*.test.ts'] ...@@ -2,7 +2,7 @@ let spec_files = ['**/*.test.ts']
// exclude browser tests // exclude browser tests
spec_files = spec_files.concat(['!**/*.browser.test.ts']) spec_files = spec_files.concat(['!**/*.browser.test.ts'])
spec_files = spec_files.concat(['!test/tests.legacy/*']) spec_files = spec_files.concat(['!**/tests-legacy/**/*.ts'])
module.exports = { module.exports = {
spec_dir: 'test', spec_dir: 'test',
......
...@@ -11,6 +11,7 @@ export async function allFacesSsdMobilenetv1( ...@@ -11,6 +11,7 @@ export async function allFacesSsdMobilenetv1(
input: TNetInput, input: TNetInput,
minConfidence?: number minConfidence?: number
): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> { ): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> {
console.warn('allFacesSsdMobilenetv1 is deprecated and will be removed soon, use the high level api instead')
return await detectAllFaces(input, new SsdMobilenetv1Options(minConfidence ? { minConfidence } : {})) return await detectAllFaces(input, new SsdMobilenetv1Options(minConfidence ? { minConfidence } : {}))
.withFaceLandmarks() .withFaceLandmarks()
.withFaceDescriptors() .withFaceDescriptors()
...@@ -20,6 +21,7 @@ export async function allFacesTinyYolov2( ...@@ -20,6 +21,7 @@ export async function allFacesTinyYolov2(
input: TNetInput, input: TNetInput,
forwardParams: ITinyYolov2Options = {} forwardParams: ITinyYolov2Options = {}
): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> { ): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> {
console.warn('allFacesTinyYolov2 is deprecated and will be removed soon, use the high level api instead')
return await detectAllFaces(input, new TinyYolov2Options(forwardParams)) return await detectAllFaces(input, new TinyYolov2Options(forwardParams))
.withFaceLandmarks() .withFaceLandmarks()
.withFaceDescriptors() .withFaceDescriptors()
...@@ -29,6 +31,7 @@ export async function allFacesMtcnn( ...@@ -29,6 +31,7 @@ export async function allFacesMtcnn(
input: TNetInput, input: TNetInput,
forwardParams: IMtcnnOptions = {} forwardParams: IMtcnnOptions = {}
): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> { ): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]> {
console.warn('allFacesMtcnn is deprecated and will be removed soon, use the high level api instead')
return await detectAllFaces(input, new MtcnnOptions(forwardParams)) return await detectAllFaces(input, new MtcnnOptions(forwardParams))
.withFaceLandmarks() .withFaceLandmarks()
.withFaceDescriptors() .withFaceDescriptors()
......
...@@ -24,6 +24,16 @@ export class Mtcnn extends NeuralNetwork<NetParams> { ...@@ -24,6 +24,16 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
super('Mtcnn') super('Mtcnn')
} }
public async load(weightsOrUrl: Float32Array | string | undefined): Promise<void> {
console.warn('mtcnn is deprecated and will be removed soon')
return super.load(weightsOrUrl)
}
public async loadFromDisk(filePath: string | undefined) {
console.warn('mtcnn is deprecated and will be removed soon')
return super.loadFromDisk(filePath)
}
public async forwardInput( public async forwardInput(
input: NetInput, input: NetInput,
forwardParams: IMtcnnOptions = {} forwardParams: IMtcnnOptions = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment