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

38 lines
1.4 KiB
Matlab

function [ out_prob, out_correction, out_lmarks ] = ONet( im_data, ONet_mlab )
%PNET Summary of this function goes here
% Detailed explanation goes here
% The convolutional and pooling layers
out = convolution(im_data, ONet_mlab.weights_conv1, ONet_mlab.biases_conv1);
out = PReLU(out, ONet_mlab.prelu_weights_1);
out = max_pooling2(out, 3, 2);
out = convolution(out, ONet_mlab.weights_conv2, ONet_mlab.biases_conv2);
out = PReLU(out, ONet_mlab.prelu_weights_2);
out = max_pooling2(out, 3, 2);
out = convolution(out, ONet_mlab.weights_conv3, ONet_mlab.biases_conv3);
out = PReLU(out, ONet_mlab.prelu_weights_3);
out = max_pooling2(out, 2, 2);
out = convolution(out, ONet_mlab.weights_conv4, ONet_mlab.biases_conv4);
out = PReLU(out, ONet_mlab.prelu_weights_4);
% The fully connected layers
out_fc_1 = zeros(size(out,1)*size(out,2) * size(out,3), size(out,4));
out_fc_1(:) = out(:);
out_fc_1 = out_fc_1' * ONet_mlab.w_fc1 + ONet_mlab.b_fc1';
out_fc_1 = PReLU(out_fc_1, ONet_mlab.prelu_fc1);
out_fc2 = out_fc_1 * ONet_mlab.w_fc2 + ONet_mlab.b_fc2';
out_fc2 = out_fc2';
% Probability of each proposal
out_prob = 1./(1+exp(out_fc2(1,:)-out_fc2(2,:)));
% The correction of each detection
out_correction = out_fc2(3:6,:);
% The actual detected landmarks
out_lmarks = out_fc2(7:end,:);
end