Files
OpenFace/matlab_version/face_detection/mtcnn/PNet.m

27 lines
1.0 KiB
Matlab

function [ out_prob, out_correction ] = PNet( im_data, PNet_mlab )
%PNET Summary of this function goes here
% Detailed explanation goes here
% Pass through the first convolution layer
out = convolution(im_data, PNet_mlab.weights_conv1, PNet_mlab.biases_conv1);
out = PReLU(out, PNet_mlab.prelu_weights_1);
out = max_pooling2(out, 2, 2);
out = convolution(out, PNet_mlab.weights_conv2, PNet_mlab.biases_conv2);
out = PReLU(out, PNet_mlab.prelu_weights_2);
out = convolution(out, PNet_mlab.weights_conv3, PNet_mlab.biases_conv3);
out = PReLU(out, PNet_mlab.prelu_weights_3);
% The fully connected layer
out_fc = zeros(size(out,1)*size(out,2), size(out,3));
out_fc(:) = out(:);
out_fc = out_fc * PNet_mlab.w + PNet_mlab.b';
out = reshape(out_fc, size(out,1), size(out,2), size(out_fc,2));
% The alignment probabilities (face heat map)
out_prob = 1./(1+exp(out(:,:,1)-out(:,:,2)));
% The correction of the detection
out_correction = out(:,:,3:end);
end