diff --git a/matlab_version/demo/setup_mconvnet.m b/matlab_version/demo/setup_mconvnet.m new file mode 100644 index 00000000..f4837f11 --- /dev/null +++ b/matlab_version/demo/setup_mconvnet.m @@ -0,0 +1,28 @@ +function setup(varargin) + +try + run D:\soft\matconvnet-master\matconvnet-master\matlab/vl_setupnn ; + addpath D:\soft\matconvnet-master\matconvnet-master\examples ; + + opts.useGpu = false ; + opts.verbose = false ; + opts = vl_argparse(opts, varargin) ; + + try + vl_nnconv(single(1),single(1),[]) ; + catch + warning('VL_NNCONV() does not seem to be compiled. Trying to compile it now.') ; + vl_compilenn('enableGpu', opts.useGpu, 'verbose', opts.verbose) ; + end + + if opts.useGpu + try + vl_nnconv(gpuArray(single(1)),gpuArray(single(1)),[]) ; + catch + vl_compilenn('enableGpu', opts.useGpu, 'verbose', opts.verbose) ; + warning('GPU support does not seem to be compiled in MatConvNet. Trying to compile it now') ; + end + end +catch + fprintf('Could not setup MatConvNet, face detection will be slower, install the library and set the right location for it in setup_mconvnet.m\n'); +end \ No newline at end of file diff --git a/matlab_version/face_detection/mtcnn/detect_face_mtcnn.m b/matlab_version/face_detection/mtcnn/detect_face_mtcnn.m index 137f64b6..aa69923c 100644 --- a/matlab_version/face_detection/mtcnn/detect_face_mtcnn.m +++ b/matlab_version/face_detection/mtcnn/detect_face_mtcnn.m @@ -1,7 +1,7 @@ function [total_bboxes, lmarks, confidence] = detect_face_mtcnn(img, min_face_size) % Check if MatConvNet is installed -if(~exist('vl_nnconv', 'file') == 3) +if(exist('vl_nnconv', 'file') ~= 3) fprintf('Warning MatConvNet is not installed or not setup, face detection will be quite slow\n'); end diff --git a/matlab_version/face_detection/mtcnn/readme.txt b/matlab_version/face_detection/mtcnn/readme.txt new file mode 100644 index 00000000..616f1171 --- /dev/null +++ b/matlab_version/face_detection/mtcnn/readme.txt @@ -0,0 +1,6 @@ +My re-implementation of MTCNN face detector (https://github.com/kpzhang93/MTCNN_face_detection_alignment) using Matlab and MatcConvNet. + +It uses MatConvNet to speed up face detection, and is able to use GPU support. Alternatively, if MatConvNet is not installed the approach will use Matlab native functions for processing (much slower). + +MatConvNet version used: +- MatConvNet from http://www.vlfeat.org/matconvnet/ (tested with version 1.0-beta24), and install following the instructions