open source pkg v1
This commit is contained in:
226
pkg/OpenFace/matlab_version/experiments_300W/Collect_wild_imgs.m
Normal file
226
pkg/OpenFace/matlab_version/experiments_300W/Collect_wild_imgs.m
Normal file
@@ -0,0 +1,226 @@
|
||||
function [images, detections, labels] = Collect_wild_imgs(root_test_data)
|
||||
|
||||
use_afw = true;
|
||||
use_lfpw = true;
|
||||
use_helen = true;
|
||||
use_ibug = true;
|
||||
|
||||
use_68 = true;
|
||||
|
||||
images = [];
|
||||
labels = [];
|
||||
detections = [];
|
||||
|
||||
if(use_afw)
|
||||
[img, det, lbl] = Collect_AFW(root_test_data, use_68);
|
||||
images = cat(1, images, img');
|
||||
detections = cat(1, detections, det);
|
||||
labels = cat(1, labels, lbl);
|
||||
end
|
||||
|
||||
if(use_lfpw)
|
||||
[img, det, lbl] = Collect_LFPW(root_test_data, use_68);
|
||||
images = cat(1, images, img');
|
||||
detections = cat(1, detections, det);
|
||||
labels = cat(1, labels, lbl);
|
||||
end
|
||||
|
||||
if(use_ibug)
|
||||
[img, det, lbl] = Collect_ibug(root_test_data, use_68);
|
||||
images = cat(1, images, img');
|
||||
detections = cat(1, detections, det);
|
||||
labels = cat(1, labels, lbl);
|
||||
end
|
||||
|
||||
if(use_helen)
|
||||
[img, det, lbl] = Collect_helen(root_test_data, use_68);
|
||||
images = cat(1, images, img');
|
||||
detections = cat(1, detections, det);
|
||||
labels = cat(1, labels, lbl);
|
||||
end
|
||||
|
||||
% convert to format expected by the Fitting method
|
||||
detections(:,3) = detections(:,1) + detections(:,3);
|
||||
detections(:,4) = detections(:,2) + detections(:,4);
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function [images, detections, labels] = Collect_AFW(root_test_data, use_68)
|
||||
|
||||
dataset_loc = [root_test_data, '/AFW/'];
|
||||
|
||||
landmarkLabels = dir([dataset_loc '\*.pts']);
|
||||
|
||||
num_imgs = size(landmarkLabels,1);
|
||||
|
||||
images = struct;
|
||||
if(use_68)
|
||||
labels = zeros(num_imgs, 68, 2);
|
||||
else
|
||||
labels = zeros(num_imgs, 66, 2);
|
||||
end
|
||||
|
||||
detections = zeros(num_imgs, 4);
|
||||
|
||||
load([root_test_data, '/Bounding Boxes/bounding_boxes_afw.mat']);
|
||||
num_landmarks = 68;
|
||||
|
||||
for imgs = 1:num_imgs
|
||||
|
||||
[~,name,~] = fileparts(landmarkLabels(imgs).name);
|
||||
|
||||
landmarks = dlmread([dataset_loc, landmarkLabels(imgs).name], ' ', [3,0,num_landmarks+2,1]);
|
||||
|
||||
if(~use_68)
|
||||
inds_frontal = [1:60,62:64,66:68];
|
||||
landmarks = landmarks(inds_frontal,:);
|
||||
end
|
||||
|
||||
images(imgs).img = [dataset_loc, name '.jpg'];
|
||||
labels(imgs,:,:) = landmarks;
|
||||
|
||||
detections(imgs,:) = bounding_boxes{imgs}.bb_detector;
|
||||
|
||||
end
|
||||
|
||||
detections(:,3) = detections(:,3) - detections(:,1);
|
||||
detections(:,4) = detections(:,4) - detections(:,2);
|
||||
|
||||
end
|
||||
|
||||
function [images, detections, labels] = Collect_LFPW(root_test_data, use_68)
|
||||
|
||||
dataset_loc = [root_test_data, '/lfpw/testset/'];
|
||||
|
||||
landmarkLabels = dir([dataset_loc '\*.pts']);
|
||||
|
||||
num_imgs = size(landmarkLabels,1);
|
||||
|
||||
images = struct;
|
||||
if(use_68)
|
||||
labels = zeros(num_imgs, 68, 2);
|
||||
else
|
||||
labels = zeros(num_imgs, 66, 2);
|
||||
end
|
||||
|
||||
detections = zeros(num_imgs, 4);
|
||||
|
||||
load([root_test_data, '/Bounding Boxes/bounding_boxes_lfpw_testset.mat']);
|
||||
|
||||
num_landmarks = 68;
|
||||
|
||||
for imgs = 1:num_imgs
|
||||
|
||||
[~,name,~] = fileparts(landmarkLabels(imgs).name);
|
||||
|
||||
landmarks = dlmread([dataset_loc, landmarkLabels(imgs).name], ' ', [3,0,num_landmarks+2,1]);
|
||||
|
||||
if(~use_68)
|
||||
inds_frontal = [1:60,62:64,66:68];
|
||||
landmarks = landmarks(inds_frontal,:);
|
||||
end
|
||||
|
||||
images(imgs).img = [dataset_loc, name '.png'];
|
||||
|
||||
labels(imgs,:,:) = landmarks;
|
||||
|
||||
detections(imgs,:) = bounding_boxes{imgs}.bb_detector;
|
||||
|
||||
end
|
||||
|
||||
detections(:,3) = detections(:,3) - detections(:,1);
|
||||
detections(:,4) = detections(:,4) - detections(:,2);
|
||||
|
||||
|
||||
end
|
||||
|
||||
function [images, detections, labels] = Collect_ibug(root_test_data, use_68)
|
||||
|
||||
dataset_loc = [root_test_data, '/ibug/'];
|
||||
|
||||
landmarkLabels = dir([dataset_loc '\*.pts']);
|
||||
|
||||
num_imgs = size(landmarkLabels,1);
|
||||
|
||||
images = struct;
|
||||
|
||||
if(use_68)
|
||||
labels = zeros(num_imgs, 68, 2);
|
||||
else
|
||||
labels = zeros(num_imgs, 66, 2);
|
||||
end
|
||||
|
||||
detections = zeros(num_imgs, 4);
|
||||
|
||||
load([root_test_data, '/Bounding Boxes/bounding_boxes_ibug.mat']);
|
||||
num_landmarks = 68;
|
||||
|
||||
for imgs = 1:num_imgs
|
||||
|
||||
[~,name,~] = fileparts(landmarkLabels(imgs).name);
|
||||
|
||||
landmarks = dlmread([dataset_loc, landmarkLabels(imgs).name], ' ', [3,0,num_landmarks+2,1]);
|
||||
|
||||
if(~use_68)
|
||||
inds_frontal = [1:60,62:64,66:68];
|
||||
landmarks = landmarks(inds_frontal,:);
|
||||
end
|
||||
|
||||
images(imgs).img = [dataset_loc, name '.jpg'];
|
||||
|
||||
labels(imgs,:,:) = landmarks;
|
||||
|
||||
detections(imgs,:) = bounding_boxes{imgs}.bb_detector;
|
||||
|
||||
end
|
||||
|
||||
detections(:,3) = detections(:,3) - detections(:,1);
|
||||
detections(:,4) = detections(:,4) - detections(:,2);
|
||||
|
||||
end
|
||||
|
||||
function [images, detections, labels] = Collect_helen(root_test_data, use_68)
|
||||
|
||||
dataset_loc = [root_test_data, '/helen/testset/'];
|
||||
|
||||
landmarkLabels = dir([dataset_loc '\*.pts']);
|
||||
|
||||
num_imgs = size(landmarkLabels,1);
|
||||
|
||||
images = struct;
|
||||
|
||||
if(use_68)
|
||||
labels = zeros(num_imgs, 68, 2);
|
||||
else
|
||||
labels = zeros(num_imgs, 66, 2);
|
||||
end
|
||||
|
||||
detections = zeros(num_imgs, 4);
|
||||
|
||||
load([root_test_data, '/Bounding Boxes/bounding_boxes_helen_testset.mat']);
|
||||
num_landmarks = 68;
|
||||
for imgs = 1:num_imgs
|
||||
|
||||
[~,name,~] = fileparts(landmarkLabels(imgs).name);
|
||||
|
||||
landmarks = dlmread([dataset_loc, landmarkLabels(imgs).name], ' ', [3,0,num_landmarks+2,1]);
|
||||
|
||||
if(~use_68)
|
||||
inds_frontal = [1:60,62:64,66:68];
|
||||
landmarks = landmarks(inds_frontal,:);
|
||||
end
|
||||
|
||||
images(imgs).img = [dataset_loc, name '.jpg'];
|
||||
|
||||
labels(imgs,:,:) = landmarks;
|
||||
|
||||
detections(imgs,:) = bounding_boxes{imgs}.bb_detector;
|
||||
|
||||
end
|
||||
|
||||
detections(:,3) = detections(:,3) - detections(:,1);
|
||||
detections(:,4) = detections(:,4) - detections(:,2);
|
||||
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
% Run this in order to construct the results table for the CE-CLM paper
|
||||
Extract_table_results_68;
|
||||
|
||||
file_out = fopen('results/300W_68.txt', 'w');
|
||||
|
||||
fprintf(file_out, 'Errors with outline (68 points)\n');
|
||||
fprintf(file_out, '------------------------------\n');
|
||||
fprintf(file_out, 'Method\tcomm\tdiff\n');
|
||||
fprintf(file_out, 'CLNF\t%.2f\t%.2f\n', median(clnf_error_comm)*100, median(clnf_error_ibug)*100);
|
||||
fprintf(file_out, 'CFAN\t--- \t%.2f\n', median(cfan_error_ibug)*100);
|
||||
fprintf(file_out, 'DRMF\t%.2f\t%.2f\n', median(drmf_error_comm)*100, median(drmf_error_ibug)*100);
|
||||
fprintf(file_out, 'CFSS\t%.2f\t%.2f\n', median(cfss_error_comm)*100, median(cfss_error_ibug)*100);
|
||||
fprintf(file_out, 'TCDCN\t%.2f\t%.2f\n', median(tcdcn_error_comm)*100, median(tcdcn_error_ibug)*100);
|
||||
fprintf(file_out, '3DDFA\t%.2f\t%.2f\n', median(error_3ddfa_comm)*100, median(error_3ddfa_ibug)*100);
|
||||
fprintf(file_out, '------------------------------\n');
|
||||
fprintf(file_out, 'CE-CLM\t%.2f\t%.2f\n', median(ceclm_error_comm)*100, median(ceclm_error_ibug)*100);
|
||||
fclose(file_out);
|
||||
|
||||
Extract_table_results_49;
|
||||
file_out = fopen('results/300W_49.txt', 'w');
|
||||
|
||||
fprintf(file_out, 'Errors without outline (49 points)\n');
|
||||
fprintf(file_out, '------------------------------\n');
|
||||
fprintf(file_out, 'Method\tcomm\tdiff\n');
|
||||
fprintf(file_out, 'CLNF\t%.2f\t%.2f\n', median(clnf_error_comm)*100, median(clnf_error_ibug)*100);
|
||||
fprintf(file_out, 'SDM \t%.2f\t%.2f\n', median(sdm_error_comm)*100, median(sdm_error_ibug)*100);
|
||||
fprintf(file_out, 'CFAN\t--- \t%.2f\n', median(cfan_error_ibug)*100);
|
||||
fprintf(file_out, 'DRMF\t%.2f\t%.2f\n', median(drmf_error_comm)*100, median(drmf_error_ibug)*100);
|
||||
fprintf(file_out, 'CFSS\t%.2f\t%.2f\n', median(cfss_error_comm)*100, median(cfss_error_ibug)*100);
|
||||
fprintf(file_out, 'TCDCN\t%.2f\t%.2f\n', median(tcdcn_error_comm)*100, median(tcdcn_error_ibug)*100);
|
||||
fprintf(file_out, '3DDFA\t%.2f\t%.2f\n', median(error_3ddfa_comm)*100, median(error_3ddfa_ibug)*100);
|
||||
fprintf(file_out, '------------------------------\n');
|
||||
fprintf(file_out, 'CE-CLM\t%.2f\t%.2f\n', median(ceclm_error_comm)*100, median(ceclm_error_ibug)*100);
|
||||
|
||||
fclose(file_out);
|
||||
@@ -0,0 +1,160 @@
|
||||
clear
|
||||
close all
|
||||
|
||||
% First grab the numbers
|
||||
Extract_table_results_49;
|
||||
|
||||
%% Visualize all the baselines on all 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, ceclm_error_comm, ceclm_error_ibug));
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, clnf_error_comm, clnf_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, error_3ddfa_comm, error_3ddfa_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, drmf_error_comm, drmf_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, cfss_error_comm, cfss_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, sdm_error_comm, sdm_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'SDM', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, tcdcn_error_comm, tcdcn_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.01,0.07]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, ceclm_error_comm, ceclm_error_ibug));
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-49.pdf
|
||||
print -dpng results/ceclm-300W-49.png
|
||||
%% Visualize all the baselines on difficult subset of 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_ibug);
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(clnf_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(error_3ddfa_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(drmf_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cfss_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(sdm_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'SDM', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(tcdcn_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.02,0.09]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_ibug);
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-ibug-49.pdf
|
||||
print -dpng results/ceclm-300W-ibug-49.png
|
||||
|
||||
%% Visualize all the baselines on difficult subset of 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_comm);
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(clnf_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(error_3ddfa_comm);
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(drmf_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cfss_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(sdm_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'SDM', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(tcdcn_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.01,0.07]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_comm);
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-comm-49.pdf
|
||||
print -dpng results/ceclm-300W-comm-49.png
|
||||
@@ -0,0 +1,150 @@
|
||||
clear
|
||||
|
||||
% First grab the numbers
|
||||
Extract_table_results_68;
|
||||
|
||||
%% Visualize all the baselines on all 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, ceclm_error_comm, ceclm_error_ibug));
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, clnf_error_comm, clnf_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, error_3ddfa_comm, error_3ddfa_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, drmf_error_comm, drmf_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, cfss_error_comm, cfss_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, tcdcn_error_comm, tcdcn_error_ibug));
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.01,0.07]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(cat(1, ceclm_error_comm, ceclm_error_ibug));
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-68.pdf
|
||||
print -dpng results/ceclm-300W-68.png
|
||||
%% Visualize all the baselines on difficult subset of 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_ibug);
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(clnf_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(error_3ddfa_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(drmf_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cfss_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(tcdcn_error_ibug);
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.02,0.09]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_ibug);
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-ibug-68.pdf
|
||||
print -dpng results/ceclm-300W-ibug-68.png
|
||||
|
||||
%% Visualize all the baselines on difficult subset of 300W
|
||||
scrsz = get(0,'ScreenSize');
|
||||
figure1 = figure('Position',[20 50 3*scrsz(3)/4 0.9*scrsz(4)]);
|
||||
|
||||
set(figure1,'Units','Inches');
|
||||
pos = get(figure1,'Position');
|
||||
set(figure1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
|
||||
|
||||
% Create axes
|
||||
axes1 = axes('Parent',figure1,'FontSize',40,'FontName','Helvetica');
|
||||
|
||||
line_width = 6;
|
||||
hold on;
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_comm);
|
||||
plot(error_x, error_y, 'r', 'DisplayName', 'CE-CLM ', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(clnf_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(error_3ddfa_comm);
|
||||
plot(error_x, error_y, 'DisplayName', '3DDFA', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(drmf_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'DRMF', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(cfss_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width);
|
||||
|
||||
[error_x, error_y] = cummErrorCurve(tcdcn_error_comm);
|
||||
plot(error_x, error_y, 'DisplayName', 'TCDCN', 'LineWidth',line_width);
|
||||
|
||||
set(gca,'xtick',[0:0.01:0.1])
|
||||
xlim([0.01,0.07]);
|
||||
xlabel('IOD normalised MAE','FontName','Helvetica');
|
||||
ylabel('Proportion of images','FontName','Helvetica');
|
||||
grid on
|
||||
% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica');
|
||||
|
||||
leg = legend('show', 'Location', 'SouthEast');
|
||||
set(leg,'FontSize',50)
|
||||
|
||||
% Make sure CE-CLM curve is on top
|
||||
[error_x, error_y] = cummErrorCurve(ceclm_error_comm);
|
||||
plot(error_x, error_y, 'r', 'LineWidth',line_width);
|
||||
|
||||
print -dpdf results/ceclm-300W-comm-68.pdf
|
||||
print -dpng results/ceclm-300W-comm-68.png
|
||||
@@ -0,0 +1,171 @@
|
||||
clear
|
||||
|
||||
%%
|
||||
inds_ibug = 562:696;
|
||||
|
||||
load('./results/results_clnf_wild.mat');
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
clnf_error_ibug = compute_error( labels(:,:,inds_ibug), shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('./results/results_ceclm_menpo.mat');
|
||||
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
ceclm_error_ibug = compute_error( labels(:,:,inds_ibug), shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/zhu_wild.mat');
|
||||
labels_all = labels_all(18:end,:,:);
|
||||
shapes_all = shapes_all(18:end,:,:);
|
||||
|
||||
tsm_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug));
|
||||
|
||||
load('results/CFAN_300W.mat');
|
||||
shapes_all = shapes_all([1:60,62:64,66:end],:,:);
|
||||
shapes_all = shapes_all(18:end,:,:);
|
||||
labels_all = labels_all([1:60,62:64,66:end],:,:);
|
||||
labels_all = labels_all(18:end,:,:);
|
||||
|
||||
cfan_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug)+1.0);
|
||||
|
||||
load('./results/results_clm.mat');
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
clm_error_ibug = compute_error( labels(:,:,inds_ibug), shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/300W_3DDFA.mat');
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
error_3ddfa_ibug = compute_error( labels_all(:,:,inds_ibug), shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/drmf_wild.mat');
|
||||
labels_all = labels_all(18:end,:,:);
|
||||
shapes_all = shapes_all(18:end,:,:);
|
||||
|
||||
drmf_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug));
|
||||
|
||||
load('results/300W_sdm.mat');
|
||||
shapes_all = experiments.shapes;
|
||||
|
||||
sdm_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug)+1.5);
|
||||
|
||||
load('results/300W_pocr.mat');
|
||||
shapes_all = experiments.shapes;
|
||||
|
||||
po_cr_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/300W-CFSS.mat');
|
||||
|
||||
shapes = zeros(size(estimatedPose,2)/2,2,size(estimatedPose,1));
|
||||
for i=1:size(estimatedPose,1)
|
||||
xs = estimatedPose(i,1:end/2);
|
||||
ys = estimatedPose(i,end/2+1:end);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
cfss_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes(:,:,inds_ibug)+0.5);
|
||||
|
||||
load('results/tcdcn_300W.mat');
|
||||
shapes_c = shapes;
|
||||
shapes = zeros(68,2,numel(shapes));
|
||||
for i=1:numel(shapes_c)
|
||||
xs = shapes_c{i}(:,1);
|
||||
ys = shapes_c{i}(:,2);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
tcdcn_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes(:,:,inds_ibug)+0.5);
|
||||
|
||||
%%
|
||||
inds_comm = [338:561,697:1026];
|
||||
|
||||
load('./results/results_clnf_wild.mat');
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
clnf_error_comm = compute_error( labels(:,:,inds_comm), shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('./results/results_ceclm_menpo.mat');
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
ceclm_error_comm = compute_error( labels(:,:,inds_comm), shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/zhu_wild.mat');
|
||||
labels_all = labels_all(18:end,:,:);
|
||||
shapes_all = shapes_all(18:end,:,:);
|
||||
|
||||
tsm_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm));
|
||||
|
||||
load('./results/results_clm.mat');
|
||||
labels = experiment.labels([1:60,62:64,66:end],:,:);
|
||||
shapes = experiment.shapes([1:60,62:64,66:end],:,:);
|
||||
labels = labels(18:end,:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
clm_error_comm = compute_error( labels(:,:,inds_comm), shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/300W_3DDFA.mat');
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
error_3ddfa_comm = compute_error( labels_all(:,:,inds_comm), shapes(:,:,inds_comm)+1.0);
|
||||
|
||||
load('results/drmf_wild.mat');
|
||||
labels_all = labels_all(18:end,:,:);
|
||||
shapes_all = shapes_all(18:end,:,:);
|
||||
|
||||
drmf_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm));
|
||||
|
||||
load('results/300W_sdm.mat');
|
||||
shapes_all = experiments.shapes;
|
||||
|
||||
sdm_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm)+1.5);
|
||||
|
||||
load('results/300W_pocr.mat');
|
||||
shapes_all = experiments.shapes;
|
||||
|
||||
po_cr_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/300W-CFSS.mat');
|
||||
|
||||
shapes = zeros(size(estimatedPose,2)/2,2,size(estimatedPose,1));
|
||||
for i=1:size(estimatedPose,1)
|
||||
xs = estimatedPose(i,1:end/2);
|
||||
ys = estimatedPose(i,end/2+1:end);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
|
||||
cfss_error_comm = compute_error(labels_all(:,:,inds_comm), shapes(:,:,inds_comm)+0.5);
|
||||
|
||||
load('results/tcdcn_300W.mat');
|
||||
shapes_c = shapes;
|
||||
shapes = zeros(68,2,numel(shapes));
|
||||
for i=1:numel(shapes_c)
|
||||
xs = shapes_c{i}(:,1);
|
||||
ys = shapes_c{i}(:,2);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
shapes = shapes([1:60,62:64,66:end],:,:);
|
||||
shapes = shapes(18:end,:,:);
|
||||
tcdcn_error_comm = compute_error(labels_all(:,:,inds_comm), shapes(:,:,inds_comm)+0.5);
|
||||
@@ -0,0 +1,100 @@
|
||||
clear
|
||||
|
||||
%%
|
||||
inds_ibug = 562:696;
|
||||
|
||||
load('./results/results_clnf_wild.mat');
|
||||
|
||||
clnf_error_ibug = compute_error( experiment.labels(:,:,inds_ibug), experiment.shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('./results/results_ceclm_menpo.mat');
|
||||
|
||||
ceclm_error_ibug = compute_error( experiment.labels(:,:,inds_ibug), experiment.shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/zhu_wild.mat');
|
||||
|
||||
tsm_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug));
|
||||
|
||||
load('results/300W_3DDFA.mat');
|
||||
error_3ddfa_ibug = compute_error( labels_all(:,:,inds_ibug), shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/results_clm.mat');
|
||||
clm_error_ibug = compute_error( experiment.labels(:,:,inds_ibug), experiment.shapes(:,:,inds_ibug) + 1.0);
|
||||
|
||||
load('results/drmf_wild.mat');
|
||||
|
||||
drmf_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug));
|
||||
|
||||
load('results/CFAN_300W.mat');
|
||||
|
||||
cfan_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes_all(:,:,inds_ibug)+1.0);
|
||||
|
||||
load('results/300W-CFSS.mat');
|
||||
|
||||
shapes = zeros(size(estimatedPose,2)/2,2,size(estimatedPose,1));
|
||||
for i=1:size(estimatedPose,1)
|
||||
xs = estimatedPose(i,1:end/2);
|
||||
ys = estimatedPose(i,end/2+1:end);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
load('results/results_clnf_wild.mat');
|
||||
cfss_error_ibug = compute_error(experiment.labels(:,:,inds_ibug), shapes(:,:,inds_ibug)+0.5);
|
||||
|
||||
|
||||
load('results/tcdcn_300W.mat');
|
||||
shapes_c = shapes;
|
||||
shapes = zeros(68,2,numel(shapes));
|
||||
for i=1:numel(shapes_c)
|
||||
xs = shapes_c{i}(:,1);
|
||||
ys = shapes_c{i}(:,2);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
load('results/results_clnf_wild.mat');
|
||||
tcdcn_error_ibug = compute_error(experiment.labels(:,:,inds_ibug), shapes(:,:,inds_ibug)+0.5);
|
||||
|
||||
%%
|
||||
inds_comm = [338:561,697:1026];
|
||||
|
||||
load('./results/results_clnf_wild.mat');
|
||||
clnf_error_comm = compute_error( experiment.labels(:,:,inds_comm), experiment.shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('./results/results_ceclm_menpo.mat');
|
||||
ceclm_error_comm = compute_error( experiment.labels(:,:,inds_comm), experiment.shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/zhu_wild.mat');
|
||||
tsm_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm));
|
||||
|
||||
load('results/results_clm.mat');
|
||||
clm_error_comm = compute_error( experiment.labels(:,:,inds_comm), experiment.shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/drmf_wild.mat');
|
||||
drmf_error_comm = compute_error(labels_all(:,:,inds_comm), shapes_all(:,:,inds_comm));
|
||||
|
||||
load('results/300W_3DDFA.mat');
|
||||
error_3ddfa_comm = compute_error( labels_all(:,:,inds_comm), shapes(:,:,inds_comm) + 1.0);
|
||||
|
||||
load('results/300W-CFSS.mat');
|
||||
shapes = zeros(size(estimatedPose,2)/2,2,size(estimatedPose,1));
|
||||
for i=1:size(estimatedPose,1)
|
||||
xs = estimatedPose(i,1:end/2);
|
||||
ys = estimatedPose(i,end/2+1:end);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
|
||||
load('./results/results_clnf_wild.mat');
|
||||
cfss_error_comm = compute_error(experiment.labels(:,:,inds_comm), shapes(:,:,inds_comm)+0.5);
|
||||
|
||||
load('results/tcdcn_300W.mat');
|
||||
shapes_c = shapes;
|
||||
shapes = zeros(68,2,numel(shapes));
|
||||
for i=1:numel(shapes_c)
|
||||
xs = shapes_c{i}(:,1);
|
||||
ys = shapes_c{i}(:,2);
|
||||
shapes(:,1,i) = xs;
|
||||
shapes(:,2,i) = ys;
|
||||
end
|
||||
load('./results/results_clnf_wild.mat');
|
||||
tcdcn_error_comm = compute_error(experiment.labels(:,:,inds_comm), shapes(:,:,inds_comm)+0.5);
|
||||
@@ -0,0 +1,99 @@
|
||||
function Script_CECLM_general()
|
||||
|
||||
addpath(genpath('../'));
|
||||
|
||||
% Replace this with the location of the 300W data location
|
||||
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file'))
|
||||
root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
|
||||
else
|
||||
root_test_data = 'F:\Dropbox\AAM\test data/';
|
||||
end
|
||||
[images, detections, labels] = Collect_wild_imgs(root_test_data);
|
||||
|
||||
%% loading the CE-CLM model and parameters
|
||||
[patches, pdm, clmParams, early_term_params] = Load_CECLM_general();
|
||||
% Use the multi-hypothesis model, as bounding box tells nothing about
|
||||
% orientation
|
||||
views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;];
|
||||
views = views * pi/180;
|
||||
|
||||
%% Setup recording
|
||||
|
||||
num_points = numel(pdm.M)/3;
|
||||
|
||||
shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
labels_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
lhoods = zeros(numel(images),1);
|
||||
all_lmark_lhoods = zeros(num_points, numel(images));
|
||||
all_views_used = zeros(numel(images),1);
|
||||
|
||||
% Change if you want to visualize the outputs
|
||||
verbose = false;
|
||||
output_img = false;
|
||||
|
||||
if(output_img)
|
||||
output_root = './ceclm_gen_out/';
|
||||
if(~exist(output_root, 'dir'))
|
||||
mkdir(output_root);
|
||||
end
|
||||
end
|
||||
if(verbose)
|
||||
f = figure;
|
||||
end
|
||||
|
||||
%% Fitting the model to the provided images
|
||||
|
||||
tic
|
||||
for i=1:numel(images)
|
||||
|
||||
image = imread(images(i).img);
|
||||
image_orig = image;
|
||||
|
||||
if(size(image,3) == 3)
|
||||
image = rgb2gray(image);
|
||||
end
|
||||
|
||||
bbox = detections(i,:);
|
||||
|
||||
[shape,~,~,lhood,lmark_lhood,view_used] =...
|
||||
Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params);
|
||||
|
||||
all_lmark_lhoods(:,i) = lmark_lhood;
|
||||
all_views_used(i) = view_used;
|
||||
|
||||
shapes_all(:,:,i) = shape;
|
||||
labels_all(:,:,i) = labels(i,:,:);
|
||||
|
||||
if(mod(i, 200)==0)
|
||||
fprintf('%d done\n', i );
|
||||
end
|
||||
|
||||
lhoods(i) = lhood;
|
||||
|
||||
if(output_img)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points);
|
||||
end
|
||||
|
||||
if(verbose)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnFig(image_orig, shape, bbox, v_points);
|
||||
end
|
||||
end
|
||||
toc
|
||||
|
||||
experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0);
|
||||
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;
|
||||
|
||||
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, 'experiment');
|
||||
|
||||
end
|
||||
@@ -0,0 +1,101 @@
|
||||
function Script_CECLM_menpo()
|
||||
|
||||
addpath(genpath('../'));
|
||||
|
||||
% Replace this with the location of the 300W data location
|
||||
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file'))
|
||||
root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
|
||||
else
|
||||
root_test_data = 'F:\Dropbox\AAM\test data/';
|
||||
end
|
||||
[images, detections, labels] = Collect_wild_imgs(root_test_data);
|
||||
|
||||
%% loading the CE-CLM model and parameters
|
||||
[patches, pdm, clmParams, early_term_params] = Load_CECLM_menpo();
|
||||
% Use the multi-hypothesis model, as bounding box tells nothing about
|
||||
% orientation
|
||||
views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;];
|
||||
views = views * pi/180;
|
||||
|
||||
%% Setup recording
|
||||
|
||||
num_points = numel(pdm.M)/3;
|
||||
|
||||
shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
labels_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
lhoods = zeros(numel(images),1);
|
||||
all_lmark_lhoods = zeros(num_points, numel(images));
|
||||
all_views_used = zeros(numel(images),1);
|
||||
|
||||
% Change if you want to visualize the outputs
|
||||
verbose = true;
|
||||
output_img = false;
|
||||
|
||||
if(output_img)
|
||||
output_root = './ceclm_menpo_out/';
|
||||
if(~exist(output_root, 'dir'))
|
||||
mkdir(output_root);
|
||||
end
|
||||
end
|
||||
if(verbose)
|
||||
f = figure;
|
||||
end
|
||||
|
||||
|
||||
%% Fitting the model to the provided images
|
||||
|
||||
tic
|
||||
for i=1:numel(images)
|
||||
|
||||
image = imread(images(i).img);
|
||||
image_orig = image;
|
||||
|
||||
if(size(image,3) == 3)
|
||||
image = rgb2gray(image);
|
||||
end
|
||||
|
||||
bbox = detections(i,:);
|
||||
|
||||
% have a multi-view version
|
||||
[shape,~,~,lhood,lmark_lhood,view_used] =...
|
||||
Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params);
|
||||
|
||||
all_lmark_lhoods(:,i) = lmark_lhood;
|
||||
all_views_used(i) = view_used;
|
||||
|
||||
shapes_all(:,:,i) = shape;
|
||||
labels_all(:,:,i) = labels(i,:,:);
|
||||
|
||||
if(mod(i, 200)==0)
|
||||
fprintf('%d done\n', i );
|
||||
end
|
||||
|
||||
lhoods(i) = lhood;
|
||||
|
||||
if(output_img)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points);
|
||||
end
|
||||
|
||||
if(verbose)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnFig(image_orig, shape, bbox, v_points);
|
||||
end
|
||||
end
|
||||
toc
|
||||
|
||||
experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0);
|
||||
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;
|
||||
|
||||
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, 'experiment');
|
||||
|
||||
end
|
||||
104
pkg/OpenFace/matlab_version/experiments_300W/Script_CLM.m
Normal file
104
pkg/OpenFace/matlab_version/experiments_300W/Script_CLM.m
Normal file
@@ -0,0 +1,104 @@
|
||||
function Script_CLM()
|
||||
|
||||
addpath(genpath('../'));
|
||||
|
||||
% Replace this with the location of in 300 faces in the wild data
|
||||
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file'))
|
||||
root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
|
||||
else
|
||||
root_test_data = 'F:\Dropbox\AAM\test data/';
|
||||
end
|
||||
|
||||
[images, detections, labels] = Collect_wild_imgs(root_test_data);
|
||||
|
||||
%% loading the patch experts
|
||||
|
||||
[ patches, pdm, clmParams ] = Load_CLM_wild();
|
||||
|
||||
% Defining the view orientations that will be evaluated
|
||||
%views = [0,0,0];
|
||||
views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;];
|
||||
views = views * pi/180;
|
||||
|
||||
%% Fitting the model to the provided image
|
||||
|
||||
% Change if you want to visualize the outputs
|
||||
verbose = true;
|
||||
output_img = false;
|
||||
|
||||
if(output_img)
|
||||
output_root = './clm_out/';
|
||||
if(~exist(output_root, 'dir'))
|
||||
mkdir(output_root);
|
||||
end
|
||||
end
|
||||
if(verbose)
|
||||
f = figure;
|
||||
end
|
||||
|
||||
% for recording purposes
|
||||
|
||||
num_points = numel(pdm.M)/3;
|
||||
|
||||
shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
labels_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
lhoods = zeros(numel(images),1);
|
||||
all_lmark_lhoods = zeros(num_points, numel(images));
|
||||
all_views_used = zeros(numel(images),1);
|
||||
|
||||
% Use the multi-hypothesis model, as bounding box tells nothing about
|
||||
% orientation
|
||||
multi_view = false;
|
||||
|
||||
tic
|
||||
for i=1:numel(images)
|
||||
|
||||
image = imread(images(i).img);
|
||||
image_orig = image;
|
||||
|
||||
if(size(image,3) == 3)
|
||||
image = rgb2gray(image);
|
||||
end
|
||||
|
||||
bbox = detections(i,:);
|
||||
|
||||
[shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views);
|
||||
|
||||
all_lmark_lhoods(:,i) = lmark_lhood;
|
||||
all_views_used(i) = view_used;
|
||||
|
||||
shapes_all(:,:,i) = shape;
|
||||
labels_all(:,:,i) = labels(i,:,:);
|
||||
|
||||
if(mod(i, 100)==0)
|
||||
fprintf('%d done\n', i );
|
||||
end
|
||||
|
||||
lhoods(i) = lhood;
|
||||
|
||||
if(output_img)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points);
|
||||
end
|
||||
|
||||
if(verbose)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnFig(image_orig, shape, bbox, v_points);
|
||||
end
|
||||
|
||||
end
|
||||
toc
|
||||
experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0);
|
||||
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;
|
||||
|
||||
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
|
||||
mean(experiment.errors_normed), median(experiment.errors_normed));
|
||||
%%
|
||||
output_results = 'results/results_clm.mat';
|
||||
save(output_results, 'experiment');
|
||||
|
||||
end
|
||||
@@ -0,0 +1,96 @@
|
||||
function Script_CLNF_general()
|
||||
|
||||
addpath(genpath('../'));
|
||||
|
||||
% Replace this with the location of in 300 faces in the wild data
|
||||
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file'))
|
||||
root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
|
||||
else
|
||||
root_test_data = 'F:\Dropbox\AAM\test data/';
|
||||
end
|
||||
|
||||
[images, detections, labels] = Collect_wild_imgs(root_test_data);
|
||||
%% loading the patch experts and pdms
|
||||
|
||||
[ patches, pdm, clmParams ] = Load_CLNF_general();
|
||||
views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;];
|
||||
views = views * pi/180;
|
||||
|
||||
[ patches_51, pdm_51, clmParams_51, inds_full, inds_inner ] = Load_CLNF_inner();
|
||||
|
||||
%% Change if you want to visualize the outputs
|
||||
verbose = false;
|
||||
output_img = false;
|
||||
|
||||
if(output_img)
|
||||
output_root = './clnf_out_general/';
|
||||
if(~exist(output_root, 'dir'))
|
||||
mkdir(output_root);
|
||||
end
|
||||
end
|
||||
if(verbose)
|
||||
f = figure;
|
||||
end
|
||||
|
||||
%% For recording
|
||||
|
||||
shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
labels_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
lhoods = zeros(numel(images),1);
|
||||
|
||||
|
||||
%% Fitting the model to the provided image
|
||||
|
||||
tic
|
||||
for i=1:numel(images)
|
||||
|
||||
image = imread(images(i).img);
|
||||
image_orig = image;
|
||||
|
||||
if(size(image,3) == 3)
|
||||
image = rgb2gray(image);
|
||||
end
|
||||
|
||||
bbox = detections(i,:);
|
||||
|
||||
[shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views);
|
||||
|
||||
% Perform inner landmark fitting now
|
||||
[shape, shape_inner] = Fitting_from_bb_hierarch(image, pdm, pdm_51, patches_51, clmParams_51, shape, inds_full, inds_inner);
|
||||
|
||||
shapes_all(:,:,i) = shape;
|
||||
|
||||
labels_all(:,:,i) = labels(i,:,:);
|
||||
|
||||
if(mod(i, 200)==0)
|
||||
fprintf('%d done\n', i );
|
||||
end
|
||||
|
||||
lhoods(i) = lhood;
|
||||
|
||||
if(output_img)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points);
|
||||
end
|
||||
|
||||
if(verbose)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnFig(image_orig, shape, bbox, v_points);
|
||||
end
|
||||
|
||||
end
|
||||
toc
|
||||
|
||||
experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0);
|
||||
experiment.lhoods = lhoods;
|
||||
experiment.shapes = shapes_all;
|
||||
experiment.labels = labels_all;
|
||||
|
||||
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
|
||||
mean(experiment.errors_normed), median(experiment.errors_normed));
|
||||
|
||||
%%
|
||||
output_results = 'results/results_clnf_general.mat';
|
||||
save(output_results, 'experiment');
|
||||
|
||||
end
|
||||
@@ -0,0 +1,97 @@
|
||||
function Script_CLNF_wild()
|
||||
|
||||
addpath(genpath('../'));
|
||||
|
||||
% Replace this with the location of in 300 faces in the wild data
|
||||
if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file'))
|
||||
root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/'];
|
||||
else
|
||||
root_test_data = 'F:\Dropbox\AAM\test data/';
|
||||
end
|
||||
|
||||
[images, detections, labels] = Collect_wild_imgs(root_test_data);
|
||||
%% loading the patch experts and pdms
|
||||
|
||||
[ patches, pdm, clmParams ] = Load_CLNF_wild();
|
||||
%views = [0,0,0];
|
||||
% Use the multi-hypothesis model, as bounding box tells nothing about
|
||||
% orientation
|
||||
views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;];
|
||||
views = views * pi/180;
|
||||
|
||||
% for recording purposes
|
||||
experiment.params = clmParams;
|
||||
|
||||
%% Change if you want to visualize the outputs
|
||||
verbose = false;
|
||||
output_img = false;
|
||||
|
||||
if(output_img)
|
||||
output_root = './clnf_out_wild/';
|
||||
if(~exist(output_root, 'dir'))
|
||||
mkdir(output_root);
|
||||
end
|
||||
end
|
||||
if(verbose)
|
||||
f = figure;
|
||||
end
|
||||
|
||||
%% For recording
|
||||
|
||||
shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
labels_all = zeros(size(labels,2),size(labels,3), size(labels,1));
|
||||
lhoods = zeros(numel(images),1);
|
||||
|
||||
%% Fitting the model to the provided image
|
||||
|
||||
tic
|
||||
for i=1:numel(images)
|
||||
|
||||
image = imread(images(i).img);
|
||||
image_orig = image;
|
||||
|
||||
if(size(image,3) == 3)
|
||||
image = rgb2gray(image);
|
||||
end
|
||||
|
||||
bbox = detections(i,:);
|
||||
|
||||
[shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views);
|
||||
|
||||
shapes_all(:,:,i) = shape;
|
||||
|
||||
labels_all(:,:,i) = labels(i,:,:);
|
||||
|
||||
if(mod(i, 200)==0)
|
||||
fprintf('%d done\n', i );
|
||||
end
|
||||
|
||||
lhoods(i) = lhood;
|
||||
|
||||
|
||||
if(output_img)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points);
|
||||
end
|
||||
|
||||
if(verbose)
|
||||
v_points = sum(squeeze(labels(i,:,:)),2) > 0;
|
||||
DrawFaceOnFig(image_orig, shape, bbox, v_points);
|
||||
end
|
||||
|
||||
end
|
||||
toc
|
||||
|
||||
experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0);
|
||||
experiment.lhoods = lhoods;
|
||||
experiment.shapes = shapes_all;
|
||||
experiment.labels = labels_all;
|
||||
|
||||
fprintf('Done: mean normed error %.3f median normed error %.4f\n', ...
|
||||
mean(experiment.errors_normed), median(experiment.errors_normed));
|
||||
|
||||
%%
|
||||
output_results = 'results/results_clnf_wild.mat';
|
||||
save(output_results, 'experiment');
|
||||
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
%gts
|
||||
|
||||
dirs = {'../../test data/AFW/';
|
||||
'../../test data/ibug/';
|
||||
'../../test data/helen/testset/';
|
||||
'../../test data/lfpw/testset/';};
|
||||
|
||||
landmark_dets = dir('out_clnf_cpp\*.pts');
|
||||
|
||||
landmark_det_dir = 'out_clnf_cpp\';
|
||||
|
||||
num_imgs = size(landmark_dets,1);
|
||||
|
||||
labels = zeros(68,2,num_imgs);
|
||||
shapes = zeros(68,2,num_imgs);
|
||||
|
||||
landmark_gt = dir(['../../test data/AFW/*.pts']);
|
||||
|
||||
curr = 0;
|
||||
|
||||
for i=1:numel(dirs)
|
||||
|
||||
curr = curr+1;
|
||||
|
||||
gt_labels = dir([dirs{i}, '*.pts']);
|
||||
|
||||
for g=1:numel(gt_labels)
|
||||
gt_landmarks = importdata([dirs{i}, gt_labels(g).name], ' ', 3);
|
||||
gt_landmarks = gt_landmarks.data;
|
||||
|
||||
% find the corresponding detection
|
||||
|
||||
landmark_det = importdata([landmark_det_dir, gt_labels(g).name], ' ', 3);
|
||||
landmark_det = landmark_det.data;
|
||||
|
||||
labels(:,:,curr) = gt_landmarks;
|
||||
shapes(:,:,curr) = landmark_det;
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
34
pkg/OpenFace/matlab_version/experiments_300W/compute_error.m
Normal file
34
pkg/OpenFace/matlab_version/experiments_300W/compute_error.m
Normal file
@@ -0,0 +1,34 @@
|
||||
function [ error_per_image ] = compute_error( ground_truth_all, detected_points_all )
|
||||
%compute_error
|
||||
% compute the average point-to-point Euclidean error normalized by the
|
||||
% inter-ocular distance (measured as the Euclidean distance between the
|
||||
% outer corners of the eyes)
|
||||
%
|
||||
% Inputs:
|
||||
% grounth_truth_all, size: num_of_points x 2 x num_of_images
|
||||
% detected_points_all, size: num_of_points x 2 x num_of_images
|
||||
% Output:
|
||||
% error_per_image, size: num_of_images x 1
|
||||
|
||||
|
||||
num_of_images = size(ground_truth_all,3);
|
||||
num_of_points = size(ground_truth_all,1);
|
||||
|
||||
error_per_image = zeros(num_of_images,1);
|
||||
|
||||
for i =1:num_of_images
|
||||
detected_points = detected_points_all(:,:,i);
|
||||
ground_truth_points = ground_truth_all(:,:,i);
|
||||
if(num_of_points == 66 || num_of_points == 68)
|
||||
interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:));
|
||||
else
|
||||
interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:));
|
||||
end
|
||||
sum=0;
|
||||
for j=1:num_of_points
|
||||
sum = sum+norm(detected_points(j,:)-ground_truth_points(j,:));
|
||||
end
|
||||
error_per_image(i) = sum/(num_of_points*interocular_distance);
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
function [x, y] = cummErrorCurve( errorVec )
|
||||
%CUMMERRORCURVE Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
|
||||
spacing = 0.001;
|
||||
|
||||
sampling = [0:spacing:max(errorVec)];
|
||||
|
||||
x = sampling;
|
||||
|
||||
y = zeros(numel(sampling,1));
|
||||
|
||||
for i=1:numel(sampling)
|
||||
|
||||
y(i) = sum(errorVec < sampling(i)) / numel(errorVec);
|
||||
end
|
||||
end
|
||||
|
||||
18
pkg/OpenFace/matlab_version/experiments_300W/readme.txt
Normal file
18
pkg/OpenFace/matlab_version/experiments_300W/readme.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
Scripts for evaluating CE-CLM, CLNF, and CLM methods on the 300W challenge dataset - https://ibug.doc.ic.ac.uk/resources/300-W/
|
||||
|
||||
To run the models on the data using models trained on 300W + MultiPIE:
|
||||
- Script_CECLM_general.m
|
||||
- Script_CLNF_general.m
|
||||
- Script_CLM.m
|
||||
|
||||
To run CE-CLM model trained on 300W + MultiPIE + Menpo:
|
||||
- Script CECLM_menpo.m
|
||||
|
||||
To visualize the results of the models against baselines (using inner face markup - 49, and full face markup - 68):
|
||||
Display_ceclm_results_49.m
|
||||
Display_ceclm_results_68.m
|
||||
|
||||
To construct the error table:
|
||||
Construct_error_table.m
|
||||
|
||||
For a fair comparison all the models and baselines are initialized using the bounding boxes provided by the challenge authors.
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
Errors without outline (49 points)
|
||||
------------------------------
|
||||
Method comm diff
|
||||
CLNF 2.51 4.93
|
||||
SDM 3.31 10.73
|
||||
CFAN --- 6.99
|
||||
DRMF 4.22 8.64
|
||||
CFSS 2.46 4.49
|
||||
TCDCN 3.32 5.56
|
||||
3DDFA 5.17 8.34
|
||||
------------------------------
|
||||
CE-CLM 2.31 3.91
|
||||
@@ -0,0 +1,11 @@
|
||||
Errors with outline (68 points)
|
||||
------------------------------
|
||||
Method comm diff
|
||||
CLNF 3.47 6.37
|
||||
CFAN --- 8.38
|
||||
DRMF 4.97 10.36
|
||||
CFSS 3.20 5.97
|
||||
TCDCN 4.11 6.87
|
||||
3DDFA 7.27 12.31
|
||||
------------------------------
|
||||
CE-CLM 3.16 5.35
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 200 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 178 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 202 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 188 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 180 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
pkg/OpenFace/matlab_version/experiments_300W/results/yu_wild.mat
Normal file
BIN
pkg/OpenFace/matlab_version/experiments_300W/results/yu_wild.mat
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user