More simplification of scripts, have a good template for fitting scripts now.

This commit is contained in:
Tadas Baltrusaitis
2017-05-05 17:07:28 -04:00
parent a9a6e7f0f1
commit 427c4183cb
12 changed files with 31 additions and 109 deletions

View File

@@ -2,16 +2,16 @@ clear
load('results/results_wild_clnf_general.mat');
[clnf_error, ~,~,frontal_ids] = compute_error_small( experiments.labels, experiments.shapes-1.0);
[clnf_error, ~,~,frontal_ids] = compute_error_small( experiment.labels, experiment.shapes-1.0);
clnf_error_frontal = clnf_error(frontal_ids);
clnf_error_profile = clnf_error(~frontal_ids);
load('results/results_ceclm_general.mat');
[ceclm_error,~,~,frontal_ids] = compute_error_small( experiments.labels, experiments.shapes-1.0);
[ceclm_error,~,~,frontal_ids] = compute_error_small( experiment.labels, experiment.shapes-1.0);
ceclm_error_frontal = ceclm_error(frontal_ids);
ceclm_error_profile = ceclm_error(~frontal_ids);
labels = experiments.labels;
labels = experiment.labels;
load('results/CFAN_JANUS.mat');

View File

@@ -2,13 +2,13 @@ clear
load('results/results_wild_clnf_general.mat');
[clnf_error, ~,~,frontal_ids] = compute_error( experiments.labels, experiments.shapes-1.0);
[clnf_error, ~,~,frontal_ids] = compute_error( experiment.labels, experiment.shapes-1.0);
clnf_error_frontal = clnf_error(frontal_ids);
clnf_error_profile = clnf_error(~frontal_ids);
load('results/results_ceclm_general.mat');
[ceclm_error,~,~,frontal_ids] = compute_error( experiments.labels, experiments.shapes-1.0);
[ceclm_error,~,~,frontal_ids] = compute_error( experiment.labels, experiment.shapes-1.0);
ceclm_error_frontal = ceclm_error(frontal_ids);
ceclm_error_profile = ceclm_error(~frontal_ids);
@@ -32,7 +32,7 @@ for i = 1:size(shapes, 3)
shapes(:,2,i) = estimatedPose(i,69:end);
end
[cfss_error,~,~,frontal_ids] = compute_error( experiments.labels, shapes-1.0);
[cfss_error,~,~,frontal_ids] = compute_error( experiment.labels, shapes-1.0);
cfss_error_frontal = cfss_error(frontal_ids);
cfss_error_profile = cfss_error(~frontal_ids);
@@ -46,6 +46,6 @@ for i = 1:size(shapes, 3)
shapes(:,2,i) = shapes_c{i}(:,2);
end
[tcdcn_error,~,~,frontal_ids] = compute_error( experiments.labels, shapes-1);
[tcdcn_error,~,~,frontal_ids] = compute_error( experiment.labels, shapes-1);
tcdcn_error_frontal = tcdcn_error(frontal_ids);
tcdcn_error_profile = tcdcn_error(~frontal_ids);

View File

@@ -1,14 +1,9 @@
function Script_CECLM_general()
addpath('../PDM_helpers/');
addpath('../fitting/normxcorr2_mex_ALL');
addpath('../fitting/');
addpath('../CCNF/');
addpath('../models/');
addpath(genpath('../'));
% Replace this with the location of in 300 faces in the wild data
% Replace this with the location of the IJB-FL data location
root_test_data = 'D:/Datasets/janus_labeled';
[images, detections, labels] = Collect_JANUS_imgs(root_test_data);
%% loading the patch experts
@@ -60,7 +55,7 @@ all_views_used = zeros(numel(images),1);
% Use the multi-hypothesis model, as bounding box tells nothing about
% orientation
multi_view = true;
verbose = true;
verbose = false;
output_img = false;
if(output_img)
@@ -129,17 +124,12 @@ experiment.shapes = shapes_all;
experiment.labels = labels_all;
experiment.all_lmark_lhoods = all_lmark_lhoods;
experiment.all_views_used = all_views_used;
% save the experiment
if(~exist('experiments', 'var'))
experiments = experiment;
else
experiments = cat(1, experiments, experiment);
end
fprintf('experiment %d done: mean normed error %.3f median normed error %.4f\n', ...
numel(experiments), mean(experiment.errors_normed), median(experiment.errors_normed));
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
mean(experiment.errors_normed), median(experiment.errors_normed));
%%
output_results = 'results/results_ceclm_general.mat';
save(output_results, 'experiments');
save(output_results, 'experiment');
end

View File

@@ -1,14 +1,9 @@
function Script_CECLM_menpo()
addpath('../PDM_helpers/');
addpath('../fitting/normxcorr2_mex_ALL');
addpath('../fitting/');
addpath('../CCNF/');
addpath('../models/');
addpath(genpath('../'));
% Replace this with the location of in 300 faces in the wild data
% Replace this with the location of the IJB-FL data location
root_test_data = 'D:/Datasets/janus_labeled';
[images, detections, labels] = Collect_JANUS_imgs(root_test_data);
%% loading the patch experts
@@ -58,7 +53,7 @@ all_views_used = zeros(numel(images),1);
% Use the multi-hypothesis model, as bounding box tells nothing about
% orientation
multi_view = true;
verbose = true;
verbose = false;
output_img = false;
if(output_img)
@@ -127,17 +122,12 @@ experiment.shapes = shapes_all;
experiment.labels = labels_all;
experiment.all_lmark_lhoods = all_lmark_lhoods;
experiment.all_views_used = all_views_used;
% save the experiment
if(~exist('experiments', 'var'))
experiments = experiment;
else
experiments = cat(1, experiments, experiment);
end
fprintf('experiment %d done: mean normed error %.3f median normed error %.4f\n', ...
numel(experiments), mean(experiment.errors_normed), median(experiment.errors_normed));
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
mean(experiment.errors_normed), median(experiment.errors_normed));
%%
output_results = 'results/results_ceclm_menpo.mat';
save(output_results, 'experiments');
save(output_results, 'experiment');
end

View File

@@ -1,14 +1,9 @@
function Script_CLNF_general_no_out()
function Script_CLNF_general()
addpath('../PDM_helpers/');
addpath('../fitting/normxcorr2_mex_ALL');
addpath('../fitting/');
addpath('../CCNF/');
addpath('../models/');
addpath(genpath('../'));
% Replace this with the location of in 300 faces in the wild data
% Replace this with the location of the IJB-FL data location
root_test_data = 'D:/Datasets/janus_labeled';
[images, detections, labels] = Collect_JANUS_imgs(root_test_data);
%% loading the patch experts
@@ -22,9 +17,6 @@ clmParams.numPatchIters = size(clmParams.window_size,1);
%% Fitting the model to the provided image
verbose = false; % set to true to visualise the fitting
output_root = './wild_fit_clnf/';
% the default PDM to use
pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat'];
@@ -53,9 +45,6 @@ inds_inner = 18:68;
[patches_inner] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*general_no_out.mat', [], [], clmParams_inner);
clmParams_inner.multi_modal_types = patches_inner(1).multi_modal_types;
% load('results/results_wild_clnf_general.mat');
% clear 'experiments';
% for recording purposes
experiment.params = clmParams;
@@ -70,6 +59,7 @@ all_views_used = zeros(numel(images),1);
% Use the multi-hypothesis model, as bounding box tells nothing about
% orientation
multi_view = true;
verbose = false; % set to true to visualise the fitting
tic
for i=1:numel(images)
@@ -143,73 +133,25 @@ for i=1:numel(images)
lhoods(i) = lhood;
if(verbose)
actualShape = squeeze(labels(i,:,:));
[height_img, width_img,~] = size(image_orig);
width = max(actualShape(:,1)) - min(actualShape(:,1));
height = max(actualShape(:,2)) - min(actualShape(:,2));
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
img_min_x = max(int32(min(actualShape(v_points,1))) - width/3,1);
img_max_x = min(int32(max(actualShape(v_points,1))) + width/3,width_img);
img_min_y = max(int32(min(actualShape(v_points,2))) - height/3,1);
img_max_y = min(int32(max(actualShape(v_points,2))) + height/3,height_img);
shape(:,1) = shape(:,1) - double(img_min_x);
shape(:,2) = shape(:,2) - double(img_min_y);
image_orig = image_orig(img_min_y:img_max_y, img_min_x:img_max_x, :);
% valid points to draw (not to draw
% occluded ones)
% f = figure('visible','off');
% f = figure;
try
if(max(image_orig(:)) > 1)
imshow(double(image_orig)/255, 'Border', 'tight');
else
imshow(double(image_orig), 'Border', 'tight');
end
axis equal;
hold on;
plot(shape(:,1), shape(:,2),'.r','MarkerSize',20);
plot(shape(:,1), shape(:,2),'.b','MarkerSize',10);
% print(f, '-r80', '-dpng', sprintf('%s/%s%d.png', output_root, 'fit', i));
% print(f, '-djpeg', sprintf('%s/%s%d.jpg', output_root, 'fit', i));
% close(f);
hold off;
drawnow expose
% close(f);
catch warn
end
DrawFaceOnFig(image_orig, shape, bbox, v_points);
end
end
toc
experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all);
experiment.errors_normed = compute_error(labels_all, shapes_all - 0.5);
experiment.lhoods = lhoods;
experiment.shapes = shapes_all;
experiment.labels = labels_all;
experiment.all_lmark_lhoods = all_lmark_lhoods;
experiment.all_views_used = all_views_used;
% save the experiment
if(~exist('experiments', 'var'))
experiments = experiment;
else
experiments = cat(1, experiments, experiment);
end
fprintf('experiment %d done: mean normed error %.3f median normed error %.4f\n', ...
numel(experiments), mean(experiment.errors_normed), median(experiment.errors_normed));
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
mean(experiment.errors_normed), median(experiment.errors_normed));
%%
output_results = 'results/results_wild_clnf_general.mat';
save(output_results, 'experiments');
save(output_results, 'experiment');
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 193 KiB