2016-04-28 21:40:36 +02:00
|
|
|
clear
|
2017-01-04 23:32:38 +01:00
|
|
|
|
|
|
|
if(isunix)
|
|
|
|
executable = '"../../build/bin/FeatureExtraction"';
|
|
|
|
else
|
|
|
|
executable = '"../../x64/Release/FeatureExtraction.exe"';
|
|
|
|
end
|
|
|
|
|
|
|
|
if(exist('D:/Datasets/DISFA/Videos_LeftCamera/', 'file'))
|
|
|
|
DISFA_dir = 'D:/Datasets/DISFA/Videos_LeftCamera/';
|
2017-09-11 09:03:29 +02:00
|
|
|
elseif(exist('E:/Datasets/DISFA/Videos_LeftCamera/', 'file'))
|
|
|
|
DISFA_dir = 'E:/Datasets/DISFA/Videos_LeftCamera/';
|
2017-01-04 23:32:38 +01:00
|
|
|
else
|
|
|
|
DISFA_dir = '/multicomp/datasets/face_datasets/DISFA/Videos_LeftCamera/';
|
|
|
|
end
|
|
|
|
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
videos = dir([DISFA_dir, '*.avi']);
|
|
|
|
|
2016-07-22 15:35:50 +02:00
|
|
|
output = 'out_DISFA/';
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
%%
|
|
|
|
% Do it in parrallel for speed (replace the parfor with for if no parallel
|
|
|
|
% toolbox is available)
|
2017-12-10 11:55:34 +01:00
|
|
|
parfor v = 1:numel(videos)
|
|
|
|
|
|
|
|
vid_file = [DISFA_dir, videos(v).name];
|
|
|
|
|
|
|
|
command = sprintf('%s -f "%s" -out_dir "%s" -aus ', executable, vid_file, output);
|
|
|
|
|
|
|
|
if(isunix)
|
|
|
|
unix(command, '-echo');
|
|
|
|
else
|
|
|
|
dos(command);
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
%% Now evaluate the predictions
|
|
|
|
|
|
|
|
% Note that DISFA was used in training, this is not meant for experimental
|
|
|
|
% results but rather to show how to do AU prediction and how to interpret
|
|
|
|
% the results
|
2017-01-04 23:32:38 +01:00
|
|
|
Label_dir = [DISFA_dir, '/../ActionUnit_Labels/'];
|
2016-07-22 15:35:50 +02:00
|
|
|
prediction_dir = 'out_DISFA/';
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
label_folders = dir([Label_dir, 'SN*']);
|
|
|
|
|
|
|
|
AUs_disfa = [1,2,4,5,6,9,12,15,17,20,25,26];
|
|
|
|
labels_all = [];
|
|
|
|
label_ids = [];
|
|
|
|
for i=1:numel(label_folders)
|
|
|
|
|
|
|
|
labels = [];
|
|
|
|
for au = AUs_disfa
|
|
|
|
in_file = sprintf('%s/%s/%s_au%d.txt', Label_dir, label_folders(i).name, label_folders(i).name, au);
|
|
|
|
A = dlmread(in_file, ',');
|
|
|
|
labels = cat(2, labels, A(:,2));
|
|
|
|
end
|
|
|
|
|
|
|
|
labels_all = cat(1, labels_all, labels);
|
|
|
|
user_id = str2num(label_folders(i).name(3:end));
|
|
|
|
label_ids = cat(1, label_ids, repmat(user_id, size(labels,1),1));
|
|
|
|
end
|
|
|
|
|
2017-12-08 18:22:30 +01:00
|
|
|
preds_files = dir([prediction_dir, '*SN*.csv']);
|
2016-04-28 21:40:36 +02:00
|
|
|
|
|
|
|
tab = readtable([prediction_dir, preds_files(1).name]);
|
|
|
|
column_names = tab.Properties.VariableNames;
|
|
|
|
aus_pred_int = [];
|
2017-12-08 18:22:30 +01:00
|
|
|
au_inds_in_file = [];
|
|
|
|
for c=1:numel(column_names)
|
2016-04-28 21:40:36 +02:00
|
|
|
if(strfind(column_names{c}, '_r') > 0)
|
|
|
|
aus_pred_int = cat(1, aus_pred_int, int32(str2num(column_names{c}(3:end-2))));
|
2017-12-08 18:22:30 +01:00
|
|
|
au_inds_in_file = cat(1, au_inds_in_file, c);
|
2016-04-28 21:40:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
inds_au = zeros(numel(AUs_disfa),1);
|
|
|
|
|
|
|
|
for ind=1:numel(AUs_disfa)
|
2017-12-08 18:22:30 +01:00
|
|
|
inds_au(ind) = au_inds_in_file(aus_pred_int==AUs_disfa(ind));
|
2016-04-28 21:40:36 +02:00
|
|
|
end
|
|
|
|
preds_all = zeros(size(labels_all,1), numel(AUs_disfa));
|
|
|
|
|
|
|
|
for i=1:numel(preds_files)
|
|
|
|
|
|
|
|
preds = dlmread([prediction_dir, preds_files(i).name], ',', 1, 0);
|
2017-12-08 18:22:30 +01:00
|
|
|
%preds = preds(:,5:5+numel(aus_pred_int)-1);
|
2016-04-28 21:40:36 +02:00
|
|
|
|
2017-12-08 18:22:30 +01:00
|
|
|
user_id = str2num(preds_files(i).name(end - 11:end-9));
|
2016-04-28 21:40:36 +02:00
|
|
|
rel_ids = label_ids == user_id;
|
|
|
|
preds_all(rel_ids,:) = preds(:,inds_au);
|
|
|
|
end
|
|
|
|
|
|
|
|
%% now do the actual evaluation that the collection has been done
|
2016-07-22 15:35:50 +02:00
|
|
|
f = fopen('results/DISFA_valid_res.txt', 'w');
|
2016-04-28 21:40:36 +02:00
|
|
|
au_res = zeros(1, numel(AUs_disfa));
|
|
|
|
for au = 1:numel(AUs_disfa)
|
|
|
|
[ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_au_prediction_results( preds_all(:,au), labels_all(:,au));
|
2016-07-22 15:35:50 +02:00
|
|
|
fprintf(f, 'AU%d results - corr %.3f, rms %.3f, ccc - %.3f\n', AUs_disfa(au), corrs, rms, ccc);
|
2016-04-28 21:40:36 +02:00
|
|
|
au_res(au) = ccc;
|
|
|
|
end
|
|
|
|
fclose(f);
|