DISFA adaptation.

This commit is contained in:
Tadas Baltrusaitis 2018-02-14 08:01:25 +00:00
parent 7dfb247b53
commit 4da2d185c9
46 changed files with 50 additions and 36 deletions

View file

@ -23,7 +23,7 @@ function [geom_data, valid_ids] = Read_geom_files(users, hog_data_dir)
if(i == 1) if(i == 1)
tab = readtable(geom_file); tab = readtable(geom_file);
column_names = tab.Properties.VariableNames; column_names = tab.Properties.VariableNames;
valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'valid')); valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success'));
shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_')); shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_'));
end end

View file

@ -25,7 +25,7 @@ function [geom_data, valid_ids] = Read_geom_files_dynamic(users, hog_data_dir)
if(i == 1) if(i == 1)
tab = readtable(geom_file); tab = readtable(geom_file);
column_names = tab.Properties.VariableNames; column_names = tab.Properties.VariableNames;
valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'valid')); valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success'));
shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_')); shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_'));
end end

View file

@ -1,13 +1,11 @@
function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ... function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ...
Prepare_HOG_AU_data_generic(train_users, test_users, au_train, rest_aus, hog_data_dir) Prepare_HOG_AU_data_generic(train_users, test_users, au_train, rest_aus, root, features_dir)
%% This should be a separate function? %% This should be a separate function?
input_train_label_files = cell(numel(train_users),1); input_train_label_files = cell(numel(train_users),1);
input_test_label_files = cell(numel(test_users),1); input_test_label_files = cell(numel(test_users),1);
root = [hog_data_dir, '/../'];
% This is for loading the labels % This is for loading the labels
for i=1:numel(train_users) for i=1:numel(train_users)
input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}]; input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}];
@ -19,12 +17,12 @@ for i=1:numel(test_users)
end end
% First extracting the labels % First extracting the labels
[train_geom_data] = Read_geom_files(train_users, hog_data_dir); [train_geom_data] = Read_geom_files(train_users, features_dir);
[test_geom_data] = Read_geom_files(test_users, hog_data_dir); [test_geom_data] = Read_geom_files(test_users, features_dir);
% Reading in the HOG data % Reading in the HOG data
[train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files(train_users, hog_data_dir); [train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files(train_users, features_dir);
[test_data, success_test, vid_ids_test] = Read_HOG_files(test_users, hog_data_dir); [test_data, success_test, vid_ids_test] = Read_HOG_files(test_users, features_dir);
train_data = cat(2, train_data, train_geom_data); train_data = cat(2, train_data, train_geom_data);
raw_test = cat(2, test_data, test_geom_data); raw_test = cat(2, test_data, test_geom_data);

View file

@ -1,13 +1,11 @@
function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ... function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ...
Prepare_HOG_AU_data_generic_dynamic(train_users, test_users, au_train, rest_aus, hog_data_dir) Prepare_HOG_AU_data_generic_dynamic(train_users, test_users, au_train, rest_aus, root, features_dir)
%% This should be a separate function? %% This should be a separate function?
input_train_label_files = cell(numel(train_users),1); input_train_label_files = cell(numel(train_users),1);
input_test_label_files = cell(numel(test_users),1); input_test_label_files = cell(numel(test_users),1);
root = [hog_data_dir, '/../'];
% This is for loading the labels % This is for loading the labels
for i=1:numel(train_users) for i=1:numel(train_users)
input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}]; input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}];
@ -19,12 +17,12 @@ for i=1:numel(test_users)
end end
% First extracting the labels % First extracting the labels
[train_geom_data] = Read_geom_files_dynamic(train_users, hog_data_dir); [train_geom_data] = Read_geom_files_dynamic(train_users, features_dir);
[test_geom_data] = Read_geom_files_dynamic(test_users, hog_data_dir); [test_geom_data] = Read_geom_files_dynamic(test_users, features_dir);
% Reading in the HOG data % Reading in the HOG data
[train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files_dynamic(train_users, hog_data_dir); [train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files_dynamic(train_users, features_dir);
[test_data, success_test, vid_ids_test] = Read_HOG_files_dynamic(test_users, hog_data_dir); [test_data, success_test, vid_ids_test] = Read_HOG_files_dynamic(test_users, features_dir);
train_data = cat(2, train_data, train_geom_data); train_data = cat(2, train_data, train_geom_data);
raw_test = cat(2, test_data, test_geom_data); raw_test = cat(2, test_data, test_geom_data);

View file

@ -6,14 +6,23 @@ function [geom_data] = Read_geom_files(users, hog_data_dir)
for i=1:numel(users) for i=1:numel(users)
geom_file = [hog_data_dir, '/../model_params/LeftVideo' users{i} '_comp.txt']; geom_file = [hog_data_dir, 'LeftVideo' users{i} '_comp.csv'];
res = dlmread(geom_file, ',', 1, 0); if(i == 1)
valid = logical(res(:,4)); tab = readtable(geom_file);
column_names = tab.Properties.VariableNames;
%res_rot = res(:,6:8); valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success'));
shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_'));
res = res(:,11:end); end
res = dlmread(geom_file, ',', 1, 0);
% Check the confidence of detection
valid = logical(res(:, valid_ind));
res = res(:, shape_inds);
% Do not consider global parameters
res = res(:, 7:end);
actual_locs = res * V'; actual_locs = res * V';
res = cat(2, actual_locs, res); res = cat(2, actual_locs, res);

View file

@ -6,15 +6,24 @@ function [geom_data] = Read_geom_files_dynamic(users, hog_data_dir)
for i=1:numel(users) for i=1:numel(users)
geom_file = [hog_data_dir, '/../model_params/LeftVideo' users{i} '_comp.txt']; geom_file = [hog_data_dir, 'LeftVideo' users{i} '_comp.csv'];
res = dlmread(geom_file, ',', 1, 0);
valid = logical(res(:,4));
%res_rot = res(:,6:8);
res = res(:,11:end);
if(i == 1)
tab = readtable(geom_file);
column_names = tab.Properties.VariableNames;
valid_ind = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'success'));
shape_inds = cellfun(@(x) ~isempty(x) && x==1, strfind(column_names, 'p_'));
end
res = dlmread(geom_file, ',', 1, 0);
% Check the confidence of detection
valid = logical(res(:, valid_ind));
res = res(:, shape_inds);
% Do not consider global parameters
res = res(:, 7:end);
actual_locs = res * V'; actual_locs = res * V';
res = cat(2, actual_locs, res); res = cat(2, actual_locs, res);

View file

@ -30,7 +30,7 @@ for a=1:numel(aus)
[users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); [users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1);
% need to split the rest % need to split the rest
[train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, hog_data_dir); [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, DISFA_dir, hog_data_dir);
train_labels(train_labels > 1) = 1; train_labels(train_labels > 1) = 1;
valid_labels(valid_labels > 1) = 1; valid_labels(valid_labels > 1) = 1;

View file

@ -30,7 +30,7 @@ for a=1:numel(aus)
[users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); [users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1);
% need to split the rest % need to split the rest
[train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid, au, rest_aus, hog_data_dir); [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid, au, rest_aus, DISFA_dir, hog_data_dir);
train_labels(train_labels > 1) = 1; train_labels(train_labels > 1) = 1;
valid_labels(valid_labels > 1) = 1; valid_labels(valid_labels > 1) = 1;

View file

@ -36,7 +36,7 @@ for a=1:numel(aus)
rest_aus = setdiff(all_aus, au); rest_aus = setdiff(all_aus, au);
% load the training and testing data for the current fold % load the training and testing data for the current fold
[~, ~, test_samples, test_labels, ~, ~, ~, ~, test_ids, test_success] = Prepare_HOG_AU_data_generic_dynamic({}, test_folds{t}, au, rest_aus, hog_data_dir); [~, ~, test_samples, test_labels, ~, ~, ~, ~, test_ids, test_success] = Prepare_HOG_AU_data_generic_dynamic({}, test_folds{t}, au, rest_aus, DISFA_dir, hog_data_dir);
% create the training and validation data % create the training and validation data
users_train = setdiff(users, unique(test_ids)); users_train = setdiff(users, unique(test_ids));
@ -44,7 +44,7 @@ for a=1:numel(aus)
[users_train, users_valid] = get_balanced_fold(DISFA_dir, users_train, au, 1/4, 1); [users_train, users_valid] = get_balanced_fold(DISFA_dir, users_train, au, 1/4, 1);
% need to split the rest % need to split the rest
[train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, hog_data_dir); [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, DISFA_dir, hog_data_dir);
train_samples = sparse(train_samples); train_samples = sparse(train_samples);
valid_samples = sparse(valid_samples); valid_samples = sparse(valid_samples);

View file

@ -24,7 +24,7 @@ else
fprintf('DISFA location not found (or not defined)\n'); fprintf('DISFA location not found (or not defined)\n');
end end
hog_data_dir = [DISFA_dir, '/hog_aligned_rigid/']; hog_data_dir = 'E:\datasets\face_datasets_processed\disfa/';
users = {'SN001'; users = {'SN001';
'SN002'; 'SN002';