diff --git a/matlab_version/experiments_iccv_300w/Collect_wild_imgs.m b/matlab_version/experiments_300W/Collect_wild_imgs.m similarity index 100% rename from matlab_version/experiments_iccv_300w/Collect_wild_imgs.m rename to matlab_version/experiments_300W/Collect_wild_imgs.m diff --git a/matlab_version/experiments_300W/Display_ceclm_results_49.m b/matlab_version/experiments_300W/Display_ceclm_results_49.m new file mode 100644 index 00000000..8dde3c21 --- /dev/null +++ b/matlab_version/experiments_300W/Display_ceclm_results_49.m @@ -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 diff --git a/matlab_version/experiments_300W/Display_ceclm_results_68.m b/matlab_version/experiments_300W/Display_ceclm_results_68.m new file mode 100644 index 00000000..aa9bdf2b --- /dev/null +++ b/matlab_version/experiments_300W/Display_ceclm_results_68.m @@ -0,0 +1,151 @@ +clear +close all + +% 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 diff --git a/matlab_version/experiments_300W/Extract_table_results_49.m b/matlab_version/experiments_300W/Extract_table_results_49.m new file mode 100644 index 00000000..143134b2 --- /dev/null +++ b/matlab_version/experiments_300W/Extract_table_results_49.m @@ -0,0 +1,173 @@ +clear + +%% +inds_ibug = 562:696; + +load('./results/results_clnf.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_wild_dclm_general_v4.mat'); +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) + 0.5); + +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)); + +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,:,:); + +load('results/results_clnf.mat'); +tcdcn_error_ibug = compute_error(labels_all(:,:,inds_ibug), shapes(:,:,inds_ibug)); + +%% +inds_comm = [338:561,697:1026]; + +load('./results/results_clnf.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)+0.5); + +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)); + +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)); \ No newline at end of file diff --git a/matlab_version/experiments_300W/Extract_table_results_68.m b/matlab_version/experiments_300W/Extract_table_results_68.m new file mode 100644 index 00000000..20b69770 --- /dev/null +++ b/matlab_version/experiments_300W/Extract_table_results_68.m @@ -0,0 +1,100 @@ +clear + +%% +inds_ibug = 562:696; + +load('results/results_clnf.mat'); + +clnf_error_ibug = compute_error( experiment.labels(:,:,inds_ibug), experiment.shapes(:,:,inds_ibug) + 1.0); + +load('./results/results_ceclm_general.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) + 0.5); + +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.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.mat'); +tcdcn_error_ibug = compute_error(experiment.labels(:,:,inds_ibug), shapes(:,:,inds_ibug)); + +%% +inds_comm = [338:561,697:1026]; + +load('./results/results_clnf.mat'); +clnf_error_comm = compute_error( experiment.labels(:,:,inds_comm), experiment.shapes(:,:,inds_comm) + 1.0); + +load('./results/results_ceclm_general.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) + 0.5); + +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.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.mat'); +tcdcn_error_comm = compute_error(experiment.labels(:,:,inds_comm), shapes(:,:,inds_comm)); diff --git a/matlab_version/experiments_300W/Script_CECLM_general.m b/matlab_version/experiments_300W/Script_CECLM_general.m new file mode 100644 index 00000000..8be7765c --- /dev/null +++ b/matlab_version/experiments_300W/Script_CECLM_general.m @@ -0,0 +1,109 @@ +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 = 'D:/Dropbox/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 +multi_view = true; + +%% Setup recording +experiment.params = clmParams; + +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,:); + + % have a multi-view version + if(multi_view) + + views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;]; + views = views * pi/180; + + [shape,~,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); + else + [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); + end + + 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 diff --git a/matlab_version/experiments_300W/Script_CECLM_menpo.m b/matlab_version/experiments_300W/Script_CECLM_menpo.m new file mode 100644 index 00000000..90427a75 --- /dev/null +++ b/matlab_version/experiments_300W/Script_CECLM_menpo.m @@ -0,0 +1,109 @@ +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 = 'D:/Dropbox/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 +multi_view = true; + +%% Setup recording +experiment.params = clmParams; + +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_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 + if(multi_view) + + views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;]; + views = views * pi/180; + + [shape,~,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); + else + [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); + end + + 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 diff --git a/matlab_version/experiments_iccv_300w/Script_CLM_wild_iccv.m b/matlab_version/experiments_300W/Script_CLM.m similarity index 57% rename from matlab_version/experiments_iccv_300w/Script_CLM_wild_iccv.m rename to matlab_version/experiments_300W/Script_CLM.m index 367269c6..86b91e1a 100644 --- a/matlab_version/experiments_iccv_300w/Script_CLM_wild_iccv.m +++ b/matlab_version/experiments_300W/Script_CLM.m @@ -1,15 +1,12 @@ -function Script_CLM_wild_iccv() +function Script_CLM() -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../models/'); +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/Dropbox/AAM/test data/'; + root_test_data = 'D:/Dropbox/Dropbox/AAM/test data/'; end [images, detections, labels] = Collect_wild_imgs(root_test_data); @@ -25,8 +22,19 @@ 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_clm/'; +% Change if you want to visualize the outputs +verbose = false; +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 % the default PDM to use pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; @@ -79,7 +87,7 @@ for i=1:numel(images) % have a multi-view version if(multi_view) - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; + views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;]; views = views * pi/180; shapes = zeros(num_points, 2, size(views,1)); @@ -113,72 +121,30 @@ for i=1:numel(images) end lhoods(i) = lhood; - if(verbose) - % Center the pixel - actualShape = squeeze(labels(i,:,:)) - 0.5; - - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(:,1)) - min(actualShape(:,1)); - height = max(actualShape(:,2)) - min(actualShape(:,2)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) + + if(output_img) v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end + 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 - 0.5, shapes_all); +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; -% 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_clm.mat'; -save(output_results, 'experiments'); +output_results = 'results/results_clm.mat'; +save(output_results, 'experiment'); end diff --git a/matlab_version/experiments_in_the_wild/Script_CLNF_general_no_out.m b/matlab_version/experiments_300W/Script_CLNF.m similarity index 59% rename from matlab_version/experiments_in_the_wild/Script_CLNF_general_no_out.m rename to matlab_version/experiments_300W/Script_CLNF.m index d58e94a3..064109ed 100644 --- a/matlab_version/experiments_in_the_wild/Script_CLNF_general_no_out.m +++ b/matlab_version/experiments_300W/Script_CLNF.m @@ -1,10 +1,6 @@ -function Script_CLNF_general_no_out() +function Script_CLNF() -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 if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) @@ -14,20 +10,14 @@ else end [images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts +%% loading the patch experts and pdms clmParams = struct; clmParams.window_size = [25,25; 23,23; 21,21]; clmParams.numPatchIters = size(clmParams.window_size,1); -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -verbose = true; % set to true to visualise the fitting -output_root = './wild_fit_clnf/'; +[patches] = Load_Patch_Experts( '../models/wild/', 'ccnf_patches_*_wild.mat', [], [], clmParams); % the default PDM to use pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; @@ -57,12 +47,24 @@ 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; +%% Change if you want to visualize the outputs +verbose = false; +output_img = false; + +if(output_img) + output_root = './clnf_out/'; + if(~exist(output_root, 'dir')) + mkdir(output_root); + end +end +if(verbose) + f = figure; +end + +%% For recording num_points = numel(M)/3; shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); @@ -75,6 +77,8 @@ all_views_used = zeros(numel(images),1); % orientation multi_view = true; +%% Fitting the model to the provided image + tic for i=1:numel(images) @@ -90,7 +94,7 @@ for i=1:numel(images) % have a multi-view version if(multi_view) - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; + views = [0,0,0; 0,-30,0; 0,30,0; 0,0,30; 0,0,-30;]; views = views * pi/180; shapes = zeros(num_points, 2, size(views,1)); @@ -120,9 +124,9 @@ for i=1:numel(images) if(a > 0.9) g_param = [a; Rot2Euler(R)'; T]; - bbox = [min(shape_inner(:,1)), min(shape_inner(:,2)), max(shape_inner(:,1)), max(shape_inner(:,2))]; + bbox_2 = [min(shape_inner(:,1)), min(shape_inner(:,2)), max(shape_inner(:,1)), max(shape_inner(:,2))]; - [shape_inner] = Fitting_from_bb(image, [], bbox, pdm_inner, patches_inner, clmParams_inner, 'gparam', g_param, 'lparam', l_params); + [shape_inner] = Fitting_from_bb(image, [], bbox_2, pdm_inner, patches_inner, clmParams_inner, 'gparam', g_param, 'lparam', l_params); % Now after detections incorporate the eyes back % into the face model @@ -146,72 +150,32 @@ 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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) + + if(output_img) v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end + 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 - 0.5, shapes_all); +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; -% 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_final_inner.mat'; -save(output_results, 'experiments'); +output_results = 'results/results_clnf.mat'; +save(output_results, 'experiment'); end diff --git a/matlab_version/experiments_iccv_300w/comp_error_pts.m b/matlab_version/experiments_300W/comp_error_pts.m similarity index 100% rename from matlab_version/experiments_iccv_300w/comp_error_pts.m rename to matlab_version/experiments_300W/comp_error_pts.m diff --git a/matlab_version/experiments_iccv_300w/compute_error.m b/matlab_version/experiments_300W/compute_error.m similarity index 100% rename from matlab_version/experiments_iccv_300w/compute_error.m rename to matlab_version/experiments_300W/compute_error.m diff --git a/matlab_version/experiments_iccv_300w/cummErrorCurve.m b/matlab_version/experiments_300W/cummErrorCurve.m similarity index 100% rename from matlab_version/experiments_iccv_300w/cummErrorCurve.m rename to matlab_version/experiments_300W/cummErrorCurve.m diff --git a/matlab_version/experiments_iccv_300w/results/300W-CFSS.mat b/matlab_version/experiments_300W/results/300W-CFSS.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/300W-CFSS.mat rename to matlab_version/experiments_300W/results/300W-CFSS.mat diff --git a/matlab_version/experiments_300W/results/300W_3DDFA.mat b/matlab_version/experiments_300W/results/300W_3DDFA.mat new file mode 100644 index 00000000..e4fba563 Binary files /dev/null and b/matlab_version/experiments_300W/results/300W_3DDFA.mat differ diff --git a/matlab_version/experiments_iccv_300w/results/300W_pocr.mat b/matlab_version/experiments_300W/results/300W_pocr.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/300W_pocr.mat rename to matlab_version/experiments_300W/results/300W_pocr.mat diff --git a/matlab_version/experiments_iccv_300w/results/300W_sdm.mat b/matlab_version/experiments_300W/results/300W_sdm.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/300W_sdm.mat rename to matlab_version/experiments_300W/results/300W_sdm.mat diff --git a/matlab_version/experiments_300W/results/CFAN_300W.mat b/matlab_version/experiments_300W/results/CFAN_300W.mat new file mode 100644 index 00000000..a711b634 Binary files /dev/null and b/matlab_version/experiments_300W/results/CFAN_300W.mat differ diff --git a/matlab_version/experiments_iccv_300w/results/GNDPM_300W.mat b/matlab_version/experiments_300W/results/GNDPM_300W.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/GNDPM_300W.mat rename to matlab_version/experiments_300W/results/GNDPM_300W.mat diff --git a/matlab_version/experiments_300W/results/ceclm-300W-49.pdf b/matlab_version/experiments_300W/results/ceclm-300W-49.pdf new file mode 100644 index 00000000..e5d122ef Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-49.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-49.png b/matlab_version/experiments_300W/results/ceclm-300W-49.png new file mode 100644 index 00000000..4adc0069 Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-49.png differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-68.pdf b/matlab_version/experiments_300W/results/ceclm-300W-68.pdf new file mode 100644 index 00000000..59b61221 Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-68.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-68.png b/matlab_version/experiments_300W/results/ceclm-300W-68.png new file mode 100644 index 00000000..1dc88d1d Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-68.png differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-comm-49.pdf b/matlab_version/experiments_300W/results/ceclm-300W-comm-49.pdf new file mode 100644 index 00000000..9dc2015e Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-comm-49.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-comm-49.png b/matlab_version/experiments_300W/results/ceclm-300W-comm-49.png new file mode 100644 index 00000000..067d3bbd Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-comm-49.png differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-comm-68.pdf b/matlab_version/experiments_300W/results/ceclm-300W-comm-68.pdf new file mode 100644 index 00000000..1de2520e Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-comm-68.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-comm-68.png b/matlab_version/experiments_300W/results/ceclm-300W-comm-68.png new file mode 100644 index 00000000..df24aa1a Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-comm-68.png differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.pdf b/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.pdf new file mode 100644 index 00000000..20f8ce89 Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.png b/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.png new file mode 100644 index 00000000..2c992a03 Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-ibug-49.png differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.pdf b/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.pdf new file mode 100644 index 00000000..3eb25d8c Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.pdf differ diff --git a/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.png b/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.png new file mode 100644 index 00000000..53af1eb6 Binary files /dev/null and b/matlab_version/experiments_300W/results/ceclm-300W-ibug-68.png differ diff --git a/matlab_version/experiments_iccv_300w/results/drmf_wild.mat b/matlab_version/experiments_300W/results/drmf_wild.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/drmf_wild.mat rename to matlab_version/experiments_300W/results/drmf_wild.mat diff --git a/matlab_version/experiments_300W/results/results_ceclm_general.mat b/matlab_version/experiments_300W/results/results_ceclm_general.mat new file mode 100644 index 00000000..e83ef2fc Binary files /dev/null and b/matlab_version/experiments_300W/results/results_ceclm_general.mat differ diff --git a/matlab_version/experiments_300W/results/results_ceclm_menpo.mat b/matlab_version/experiments_300W/results/results_ceclm_menpo.mat new file mode 100644 index 00000000..c90aa8b8 Binary files /dev/null and b/matlab_version/experiments_300W/results/results_ceclm_menpo.mat differ diff --git a/matlab_version/experiments_iccv_300w/results/results_wild_clm.mat b/matlab_version/experiments_300W/results/results_clm.mat similarity index 50% rename from matlab_version/experiments_iccv_300w/results/results_wild_clm.mat rename to matlab_version/experiments_300W/results/results_clm.mat index b8133a71..f581164c 100644 Binary files a/matlab_version/experiments_iccv_300w/results/results_wild_clm.mat and b/matlab_version/experiments_300W/results/results_clm.mat differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat b/matlab_version/experiments_300W/results/results_clnf.mat similarity index 50% rename from matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat rename to matlab_version/experiments_300W/results/results_clnf.mat index f102d978..6a37e2ff 100644 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat and b/matlab_version/experiments_300W/results/results_clnf.mat differ diff --git a/matlab_version/experiments_300W/results/tcdcn_300W.mat b/matlab_version/experiments_300W/results/tcdcn_300W.mat new file mode 100644 index 00000000..6ba01e14 Binary files /dev/null and b/matlab_version/experiments_300W/results/tcdcn_300W.mat differ diff --git a/matlab_version/experiments_iccv_300w/results/yu_wild.mat b/matlab_version/experiments_300W/results/yu_wild.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/yu_wild.mat rename to matlab_version/experiments_300W/results/yu_wild.mat diff --git a/matlab_version/experiments_iccv_300w/results/zhu_wild.mat b/matlab_version/experiments_300W/results/zhu_wild.mat similarity index 100% rename from matlab_version/experiments_iccv_300w/results/zhu_wild.mat rename to matlab_version/experiments_300W/results/zhu_wild.mat diff --git a/matlab_version/experiments_JANUS/Extract_table_results_49.m b/matlab_version/experiments_JANUS/Extract_table_results_49.m index 86a2cf6b..4d49cde5 100644 --- a/matlab_version/experiments_JANUS/Extract_table_results_49.m +++ b/matlab_version/experiments_JANUS/Extract_table_results_49.m @@ -1,6 +1,6 @@ clear -load('results/results_wild_clnf_general.mat'); +load('results/results_clnf_wild.mat'); [clnf_error, ~,~,frontal_ids] = compute_error_small( experiment.labels, experiment.shapes-1.0); clnf_error_frontal = clnf_error(frontal_ids); diff --git a/matlab_version/experiments_JANUS/Extract_table_results_68.m b/matlab_version/experiments_JANUS/Extract_table_results_68.m index 3c3cdcfe..f716ec65 100644 --- a/matlab_version/experiments_JANUS/Extract_table_results_68.m +++ b/matlab_version/experiments_JANUS/Extract_table_results_68.m @@ -1,6 +1,6 @@ clear -load('results/results_wild_clnf_general.mat'); +load('results/results_clnf_wild.mat'); [clnf_error, ~,~,frontal_ids] = compute_error( experiment.labels, experiment.shapes-1.0); clnf_error_frontal = clnf_error(frontal_ids); diff --git a/matlab_version/experiments_JANUS/Script_CECLM_menpo.m b/matlab_version/experiments_JANUS/Script_CECLM_menpo.m index e6555ffa..e8253493 100644 --- a/matlab_version/experiments_JANUS/Script_CECLM_menpo.m +++ b/matlab_version/experiments_JANUS/Script_CECLM_menpo.m @@ -28,7 +28,7 @@ verbose = false; output_img = false; if(output_img) - output_root = './ceclm_gen_out/'; + output_root = './ceclm_menpo_out/'; if(~exist(output_root, 'dir')) mkdir(output_root); end diff --git a/matlab_version/experiments_JANUS/Script_CLNF_general.m b/matlab_version/experiments_JANUS/Script_CLNF_general.m index e91508ed..3f576760 100644 --- a/matlab_version/experiments_JANUS/Script_CLNF_general.m +++ b/matlab_version/experiments_JANUS/Script_CLNF_general.m @@ -13,7 +13,7 @@ clmParams = struct; clmParams.window_size = [25,25; 23,23; 21,21]; clmParams.numPatchIters = size(clmParams.window_size,1); -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); +[patches] = Load_Patch_Experts( '../models/wild/', 'ccnf_patches_*_wild.mat', [], [], clmParams); %% Fitting the model to the provided image @@ -106,9 +106,9 @@ for i=1:numel(images) if(a > 0.9) g_param = [a; Rot2Euler(R)'; T]; - bbox = [min(shape_inner(:,1)), min(shape_inner(:,2)), max(shape_inner(:,1)), max(shape_inner(:,2))]; + bbox_2 = [min(shape_inner(:,1)), min(shape_inner(:,2)), max(shape_inner(:,1)), max(shape_inner(:,2))]; - [shape_inner] = Fitting_from_bb(image, [], bbox, pdm_inner, patches_inner, clmParams_inner, 'gparam', g_param, 'lparam', l_params); + [shape_inner] = Fitting_from_bb(image, [], bbox_2, pdm_inner, patches_inner, clmParams_inner, 'gparam', g_param, 'lparam', l_params); % Now after detections incorporate the eyes back % into the face model @@ -151,7 +151,7 @@ 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'; +output_results = 'results/results_clnf_wild.mat'; save(output_results, 'experiment'); end diff --git a/matlab_version/experiments_JANUS/results/Janus-full.pdf b/matlab_version/experiments_JANUS/results/Janus-full.pdf index 368c630b..c5e88702 100644 Binary files a/matlab_version/experiments_JANUS/results/Janus-full.pdf and b/matlab_version/experiments_JANUS/results/Janus-full.pdf differ diff --git a/matlab_version/experiments_JANUS/results/Janus-full.png b/matlab_version/experiments_JANUS/results/Janus-full.png index 532746cd..de54b75d 100644 Binary files a/matlab_version/experiments_JANUS/results/Janus-full.png and b/matlab_version/experiments_JANUS/results/Janus-full.png differ diff --git a/matlab_version/experiments_JANUS/results/Janus-no-outline.pdf b/matlab_version/experiments_JANUS/results/Janus-no-outline.pdf index c629a240..d790d8b9 100644 Binary files a/matlab_version/experiments_JANUS/results/Janus-no-outline.pdf and b/matlab_version/experiments_JANUS/results/Janus-no-outline.pdf differ diff --git a/matlab_version/experiments_JANUS/results/Janus-no-outline.png b/matlab_version/experiments_JANUS/results/Janus-no-outline.png index e0a0a10e..a30cbdf2 100644 Binary files a/matlab_version/experiments_JANUS/results/Janus-no-outline.png and b/matlab_version/experiments_JANUS/results/Janus-no-outline.png differ diff --git a/matlab_version/experiments_JANUS/results/results_clnf_wild.mat b/matlab_version/experiments_JANUS/results/results_clnf_wild.mat new file mode 100644 index 00000000..882e8843 Binary files /dev/null and b/matlab_version/experiments_JANUS/results/results_clnf_wild.mat differ diff --git a/matlab_version/experiments_JANUS/results/results_wild_clnf_general.mat b/matlab_version/experiments_JANUS/results/results_wild_clnf_general.mat deleted file mode 100644 index f0541f2f..00000000 Binary files a/matlab_version/experiments_JANUS/results/results_wild_clnf_general.mat and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/Display_clnf_results.m b/matlab_version/experiments_iccv_300w/Display_clnf_results.m deleted file mode 100644 index 522e8a42..00000000 --- a/matlab_version/experiments_iccv_300w/Display_clnf_results.m +++ /dev/null @@ -1,181 +0,0 @@ -clear - -%% -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; - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all, shapes_all); - -% removing faces that were not detected by intraface for fairness -detected = intraface_wild_error < 1; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,detected); -shapes = experiments.shapes([1:60,62:64,66:end],:,detected); -labels = labels(18:end,:,:); -% center the pixel -shapes = shapes(18:end,:,:) + 0.5; - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); - -plot(error_x, error_y, 'r','DisplayName', 'OpenFace', 'LineWidth',line_width); -hold on; -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,detected); -% center the pixel -shapes_all = shapes_all(18:end,:,detected) + 0.5; - -intraface_wild_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM (CVPR 13)', 'LineWidth',line_width); -hold on; - -load('results/GNDPM_300W.mat'); -% center the pixel -shapes_all = shapes_all(:,:,detected) + 1; -labels_all = labels_all(:,:,detected); - -gndpm_wild_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(gndpm_wild_error); - -plot(error_x, error_y, '-.','DisplayName', 'GNDPM (CVPR 14)', 'LineWidth',line_width); -hold on; - - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,detected); -shapes_all = shapes_all(18:end,:,detected); - -zhu_wild_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (CVPR 12)', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,detected); -shapes = experiments.shapes([1:60,62:64,66:end],:,detected); -labels = labels(18:end,:,:); -% center the pixel -shapes = shapes(18:end,:,:) + 0.5; - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,detected); -shapes_all = shapes_all(18:end,:,detected); - -drmf_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF (CVPR 13)', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.08]); -xlabel('Size normalised shape RMS error','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',30) - -print -dpdf results/in-the-wild-clnf-no-outline.pdf - -%% -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -% center the pixel -shapes = experiments.shapes([1:60,62:64,66:end],:,:) + 0.5; - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'OpenFace', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); - -zhu_wild_error = compute_error(labels_all(:,:,:), shapes_all(:,:,:)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Zhu et al.', 'LineWidth',line_width); - -load('results/yu_wild.mat'); - -yu_wild_error = compute_error(lmark_dets_all(:,:,:)-1, shapes_all(:,:,:)); -yu_wild_error(isnan(yu_wild_error)) = 1; -yu_wild_error(isinf(yu_wild_error)) = 1; - -[error_x, error_y] = cummErrorCurve(yu_wild_error); - -plot(error_x, error_y, 'xg','DisplayName', 'Yu et al.', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -experiments(1).labels = experiments(1).labels([1:60,62:64,66:end],:,:); -% center the pixel -experiments(1).shapes = experiments(1).shapes([1:60,62:64,66:end],:,:) + 0.5; - -clm_error = compute_error( experiments(1).labels, experiments(1).shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); - -drmf_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -%title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-comparison.pdf diff --git a/matlab_version/experiments_iccv_300w/Display_clnf_results_per_db.m b/matlab_version/experiments_iccv_300w/Display_clnf_results_per_db.m deleted file mode 100644 index c400c60c..00000000 --- a/matlab_version/experiments_iccv_300w/Display_clnf_results_per_db.m +++ /dev/null @@ -1,246 +0,0 @@ -clear - -%% -inds = 1:337; -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_afw.pdf - -%% -inds = 562:696; - -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_ibug.pdf - -%% -inds = [338:561,697:1026]; - -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_lfpw_helen.pdf diff --git a/matlab_version/experiments_iccv_300w/Display_dclm_results.m b/matlab_version/experiments_iccv_300w/Display_dclm_results.m deleted file mode 100644 index b8bd86ec..00000000 --- a/matlab_version/experiments_iccv_300w/Display_dclm_results.m +++ /dev/null @@ -1,246 +0,0 @@ -clear - -inds = 338:1026; -%% -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; - -load('../experiments_in_the_wild/results/results_wild_dclm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:) + 1.0; - -dclm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(dclm_error(inds)); - -plot(error_x, error_y, 'r', 'DisplayName', 'DCLM ', 'LineWidth',line_width); - -load('../experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -% center the pixel -shapes = shapes(18:end,:,:) + 0.5; - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width); -hold on; - -load('results/300W_pocr.mat'); - -% center the pixel -shapes_all = experiments.shapes; - -pocr_error = compute_error(labels, shapes_all(:,:,:) + 1.0); - -[error_x, error_y] = cummErrorCurve(pocr_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'PO-CR', 'LineWidth',line_width); -hold on; - -load('results/300W-CFSS.mat'); - -% center the pixel -shapes_all = zeros(68, 2, size(estimatedPose,1)); -for i = 1:size(estimatedPose,1) - - shapes_all(:,1,i) = estimatedPose(i,1:68)'; - shapes_all(:,2,i) = estimatedPose(i,69:end)'; -end -shapes_all = shapes_all([1:60,62:64,66:end],:,:); -shapes_all = shapes_all(18:end,:,:); - -cfss_error = compute_error(labels, shapes_all(:,:,:) + 0.5); - -[error_x, error_y] = cummErrorCurve(cfss_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width); -hold on; - -load('results/300W_sdm.mat'); - -% center the pixel -shapes_all = experiments.shapes; - -sdm_error = compute_error(labels, shapes_all(:,:,:)); -[error_x, error_y] = cummErrorCurve(sdm_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'SDM (CVPR 13)', 'LineWidth',line_width); -hold on; - -load('results/GNDPM_300W.mat'); -% center the pixel -shapes_all = shapes_all(:,:,:) + 1; -labels_all = labels_all(:,:,:); - -gndpm_wild_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(gndpm_wild_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'GNDPM', 'LineWidth',line_width); -hold on; - - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error(inds)); - -plot(error_x, error_y, 'c','DisplayName', 'Tree based', 'LineWidth',line_width); - -% load('results/results_wild_clm.mat'); -% labels = experiments.labels([1:60,62:64,66:end],:,:); -% shapes = experiments.shapes([1:60,62:64,66:end],:,:); -% labels = labels(18:end,:,:); -% % center the pixel -% shapes = shapes(18:end,:,:) + 0.5; -% -% clm_error = compute_error( labels, shapes); -% -% [error_x, error_y] = cummErrorCurve(clm_error); -% -% plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(drmf_error(inds)); - -plot(error_x, error_y, 'k','DisplayName', 'DRMF (CVPR 13)', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.01:0.1]) -xlim([0.01,0.07]); -xlabel('IOD normalised MSE','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',30) -savefig('results/dclm-in-the-wild-no-outline.fig'); -print -dpdf results/dclm-in-the-wild-clnf-no-outline.pdf -print -dpng results/dclm-300W-no-outline.png -%% -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; - -load('../experiments_in_the_wild/results/results_wild_dclm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -% center the pixel -shapes = experiments.shapes([1:60,62:64,66:end],:,:) + 0.5; - -dclm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(dclm_error(inds)); - -plot(error_x, error_y, 'r', 'DisplayName', 'DCLM ', 'LineWidth',line_width); - -load('../experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -% center the pixel -shapes = experiments.shapes([1:60,62:64,66:end],:,:) + 1; - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error(inds)); -hold on; - -plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width); - - -load('results/300W-CFSS.mat'); - -% center the pixel -shapes_all = zeros(68, 2, size(estimatedPose,1)); -for i = 1:size(estimatedPose,1) - - shapes_all(:,1,i) = estimatedPose(i,1:68)'; - shapes_all(:,2,i) = estimatedPose(i,69:end)'; -end - -cfss_error = compute_error(labels, shapes_all(:,:,:) + 0.5); - -[error_x, error_y] = cummErrorCurve(cfss_error(inds)); - -plot(error_x, error_y, 'DisplayName', 'CFSS', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); - -zhu_wild_error = compute_error(labels_all(:,:,:), shapes_all(:,:,:)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based', 'LineWidth',line_width); - -% load('results/yu_wild.mat'); - -% yu_wild_error = compute_error(lmark_dets_all(:,:,:)-1, shapes_all(:,:,:)); -% yu_wild_error(isnan(yu_wild_error)) = 1; -% yu_wild_error(isinf(yu_wild_error)) = 1; -% -% [error_x, error_y] = cummErrorCurve(yu_wild_error(inds)); -% -% plot(error_x, error_y, 'xg','DisplayName', 'Yu et al.', 'LineWidth',line_width); - -% load('results/results_wild_clm.mat'); -% experiments(1).labels = experiments(1).labels([1:60,62:64,66:end],:,:); -% % center the pixel -% experiments(1).shapes = experiments(1).shapes([1:60,62:64,66:end],:,:) + 0.5; -% -% clm_error = compute_error( experiments(1).labels, experiments(1).shapes); -% -% [error_x, error_y] = cummErrorCurve(clm_error(inds)); -% -% plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); - -drmf_error = compute_error(labels_all, shapes_all); - -[error_x, error_y] = cummErrorCurve(drmf_error(inds)); - -plot(error_x, error_y, 'k','DisplayName', 'DRMF', 'LineWidth',line_width); - -set(gca,'xtick',[0.01:0.02:0.15]) -xlim([0.01,0.15]); -xlabel('IOD normalised MSE','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -%title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/dclm-in-the-wild-comparison.pdf -savefig('results/dclm-in-the-wild-outline.fig'); -print -dpng results/dclm-300W-outline.png \ No newline at end of file diff --git a/matlab_version/experiments_iccv_300w/Display_dlm_results_per_db.m b/matlab_version/experiments_iccv_300w/Display_dlm_results_per_db.m deleted file mode 100644 index 31cdd7c2..00000000 --- a/matlab_version/experiments_iccv_300w/Display_dlm_results_per_db.m +++ /dev/null @@ -1,258 +0,0 @@ -clear - -%% -inds = 1:337; -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_afw.pdf - -%% -inds = 562:696; - -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('../experiments_in_the_wild/results/results_wild_dclm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,inds); -shapes = experiments.shapes([1:60,62:64,66:end],:,inds); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:) + 1.0; - -dclm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(dclm_error); - -plot(error_x, error_y, 'DisplayName', 'DCLM ', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_ibug.pdf - -%% -inds = [338:561,697:1026]; - -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; - -load('results/results_wild_clnf.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLM + CCNF', 'LineWidth',line_width); - -load('results/intraface_wild_resize.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -intraface_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(intraface_wild_error); - -plot(error_x, error_y, '.-g','DisplayName', 'SDM [32]', 'LineWidth',line_width); - -load('results/zhu_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -zhu_wild_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(zhu_wild_error); - -plot(error_x, error_y, '.-c','DisplayName', 'Tree based (p204) [28]', 'LineWidth',line_width); - -load('results/results_wild_clm.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:); -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels(:,:,inds), shapes(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM + SVR', 'LineWidth',line_width); - -load('results/drmf_wild.mat'); -labels_all = labels_all(18:end,:,:); -shapes_all = shapes_all(18:end,:,:); - -drmf_error = compute_error(labels_all(:,:,inds), shapes_all(:,:,inds)); - -[error_x, error_y] = cummErrorCurve(drmf_error); - -plot(error_x, error_y, '-.k','DisplayName', 'DRMF [27]', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.05:0.15]) -xlim([0,0.15]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -print -dpdf results/in-the-wild-clnf-no-outline_lfpw_helen.pdf diff --git a/matlab_version/experiments_iccv_300w/Script_CFSS_vis.m b/matlab_version/experiments_iccv_300w/Script_CFSS_vis.m deleted file mode 100644 index 99ee8b5b..00000000 --- a/matlab_version/experiments_iccv_300w/Script_CFSS_vis.m +++ /dev/null @@ -1,81 +0,0 @@ -function Script_CFSS_vis() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -images = images(:); -labels = labels(:,:,:); - f = figure; -load('results/300W-CFSS.mat'); -output_root = './wild_fit_cfss/'; -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - pred = estimatedPose(i,:); - preds = cat(2, pred(1:68)', pred(69:end)'); - - actualShape = squeeze(labels(i,:,:)); - - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(v_points,1)) - min(actualShape(v_points,1)); - height = max(actualShape(v_points,2)) - min(actualShape(v_points,2)); - sz = (width+height)/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); - - preds(:,1) = preds(:,1) - double(img_min_x); - preds(:,2) = preds(:,2) - double(img_min_y); - - image_orig = image_orig(img_min_y:img_max_y, img_min_x:img_max_x, :); - - scale = 600/sz; - image_orig = imresize(image_orig, scale); - - % valid points to draw (not to draw - % occluded ones) - -% f = figure('visible','off'); - - 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(preds(:,1) * scale, preds(:,2) * scale,'.r','MarkerSize', int32(40)); - plot(preds(:,1) * scale, preds(:,2) * scale,'.g','MarkerSize',int32(20)); -% plot(preds(:,1), preds(:,2),'.w','MarkerSize',40); - % plot(preds(:,1), preds(:,2),'.k','MarkerSize',30); - print(f, '-r80', '-dpng', sprintf('%s/%s%d_cfss.png', output_root, 'fit', i)); -% print(f, '-dpng', sprintf('%s/%s%d.png', output_root, 'fit', i)); -% close(f); - hold off; -% drawnow expose -% close(f); - catch warn - - end - -end \ No newline at end of file diff --git a/matlab_version/experiments_iccv_300w/Script_CLNF_vis.m b/matlab_version/experiments_iccv_300w/Script_CLNF_vis.m deleted file mode 100644 index f34a84ed..00000000 --- a/matlab_version/experiments_iccv_300w/Script_CLNF_vis.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_CLNF_vis() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -images = images(:); -labels = labels(:,:,:); - f = figure; -load('../experiments_in_the_wild/results/results_wild_clnf_general_final_inner.mat'); -output_root = './wild_fit_clnf/'; -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - preds = experiments.shapes(:,:,i); - - actualShape = squeeze(labels(i,:,:)); - - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(v_points,1)) - min(actualShape(v_points,1)); - height = max(actualShape(v_points,2)) - min(actualShape(v_points,2)); - sz = (width+height)/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); - - preds(:,1) = preds(:,1) - double(img_min_x); - preds(:,2) = preds(:,2) - double(img_min_y); - - image_orig = image_orig(img_min_y:img_max_y, img_min_x:img_max_x, :); - - scale = 600/sz; - image_orig = imresize(image_orig, scale); - - % valid points to draw (not to draw - % occluded ones) - -% f = figure('visible','off'); - - 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(preds(:,1) * scale, preds(:,2) * scale,'.r','MarkerSize', int32(40)); - plot(preds(:,1) * scale, preds(:,2) * scale,'.g','MarkerSize',int32(20)); -% plot(preds(:,1), preds(:,2),'.w','MarkerSize',40); - % plot(preds(:,1), preds(:,2),'.k','MarkerSize',30); - print(f, '-r80', '-dpng', sprintf('%s/%s%d_clnf.png', output_root, 'fit', i)); -% print(f, '-dpng', sprintf('%s/%s%d.png', output_root, 'fit', i)); -% close(f); - hold off; -% drawnow expose -% close(f); - catch warn - - end - -end \ No newline at end of file diff --git a/matlab_version/experiments_iccv_300w/Script_CLNF_wild_iccv.m b/matlab_version/experiments_iccv_300w/Script_CLNF_wild_iccv.m deleted file mode 100644 index 2c81b6db..00000000 --- a/matlab_version/experiments_iccv_300w/Script_CLNF_wild_iccv.m +++ /dev/null @@ -1,188 +0,0 @@ -function Script_CLNF_wild_iccv() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -% load the images to detect landmarks of -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21; 19,19;]; - -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/wild/', 'ccnf_patches_*_wild.mat', [], [], clmParams); - -%% 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']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -% the default model parameters to use -clmParams.regFactor = [35, 27, 20, 5]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.75]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 12.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; - -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - all_lmark_lhoods(:,i) = lmark_lhood; - all_views_used(i) = view_used; - - % shape correction for matlab format - shapes_all(:,:,i) = shape; - labels_all(:,:,i) = labels(i,:,:); - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - lhoods(i) = lhood; - if(verbose) - % Center the pixel - actualShape = squeeze(labels(i,:,:)) - 0.5; - - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(:,1)) - min(actualShape(:,1)); - height = max(actualShape(:,2)) - min(actualShape(:,2)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); -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)); - -%% -output_results = 'results/results_wild_clnf.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_iccv_300w/Script_DCLM_vis.m b/matlab_version/experiments_iccv_300w/Script_DCLM_vis.m deleted file mode 100644 index 22ce33ad..00000000 --- a/matlab_version/experiments_iccv_300w/Script_DCLM_vis.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_DCLM_vis() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -images = images(:); -labels = labels(:,:,:); - f = figure; -load('../experiments_in_the_wild/results/results_wild_dclm_general.mat'); -output_root = './wild_fit_dclm/'; -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - preds = experiments.shapes(:,:,i); - - actualShape = squeeze(labels(i,:,:)); - - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(v_points,1)) - min(actualShape(v_points,1)); - height = max(actualShape(v_points,2)) - min(actualShape(v_points,2)); - sz = (width+height)/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); - - preds(:,1) = preds(:,1) - double(img_min_x); - preds(:,2) = preds(:,2) - double(img_min_y); - - image_orig = image_orig(img_min_y:img_max_y, img_min_x:img_max_x, :); - - scale = 600/sz; - image_orig = imresize(image_orig, scale); - - % valid points to draw (not to draw - % occluded ones) - -% f = figure('visible','off'); - - 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(preds(:,1) * scale, preds(:,2) * scale,'.r','MarkerSize', int32(40)); - plot(preds(:,1) * scale, preds(:,2) * scale,'.g','MarkerSize',int32(20)); -% plot(preds(:,1), preds(:,2),'.w','MarkerSize',40); - % plot(preds(:,1), preds(:,2),'.k','MarkerSize',30); - print(f, '-r80', '-dpng', sprintf('%s/%s%d_dclm.png', output_root, 'fit', i)); -% print(f, '-dpng', sprintf('%s/%s%d.png', output_root, 'fit', i)); -% close(f); - hold off; -% drawnow expose -% close(f); - catch warn - - end - -end \ No newline at end of file diff --git a/matlab_version/experiments_iccv_300w/errors.mat b/matlab_version/experiments_iccv_300w/errors.mat deleted file mode 100644 index bf9d2ef8..00000000 Binary files a/matlab_version/experiments_iccv_300w/errors.mat and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-300W-no-outline.png b/matlab_version/experiments_iccv_300w/results/dclm-300W-no-outline.png deleted file mode 100644 index 5f8c7c2c..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-300W-no-outline.png and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-300W-outline.png b/matlab_version/experiments_iccv_300w/results/dclm-300W-outline.png deleted file mode 100644 index 1605381a..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-300W-outline.png and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-clnf-no-outline.pdf b/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-clnf-no-outline.pdf deleted file mode 100644 index 949b75dd..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-clnf-no-outline.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-comparison.pdf b/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-comparison.pdf deleted file mode 100644 index 7fc7564b..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-comparison.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-no-outline.fig b/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-no-outline.fig deleted file mode 100644 index 619a4013..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-no-outline.fig and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-outline.fig b/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-outline.fig deleted file mode 100644 index e63263dd..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/dclm-in-the-wild-outline.fig and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline.pdf b/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline.pdf deleted file mode 100644 index ecb2602d..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_afw.pdf b/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_afw.pdf deleted file mode 100644 index 2e4b59b1..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_afw.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_ibug.pdf b/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_ibug.pdf deleted file mode 100644 index e80c8c0b..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_ibug.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_lfpw_helen.pdf b/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_lfpw_helen.pdf deleted file mode 100644 index aaf35a4d..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/in-the-wild-clnf-no-outline_lfpw_helen.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/in-the-wild-comparison.pdf b/matlab_version/experiments_iccv_300w/results/in-the-wild-comparison.pdf deleted file mode 100644 index e4abb7f2..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/in-the-wild-comparison.pdf and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/intraface_wild_resize.mat b/matlab_version/experiments_iccv_300w/results/intraface_wild_resize.mat deleted file mode 100644 index e36e29e1..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/intraface_wild_resize.mat and /dev/null differ diff --git a/matlab_version/experiments_iccv_300w/results/results_wild_clnf.mat b/matlab_version/experiments_iccv_300w/results/results_wild_clnf.mat deleted file mode 100644 index 751f4ebd..00000000 Binary files a/matlab_version/experiments_iccv_300w/results/results_wild_clnf.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/Collect_wild_imgs.m b/matlab_version/experiments_in_the_wild/Collect_wild_imgs.m deleted file mode 100644 index 8c9efd60..00000000 --- a/matlab_version/experiments_in_the_wild/Collect_wild_imgs.m +++ /dev/null @@ -1,226 +0,0 @@ -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 diff --git a/matlab_version/experiments_in_the_wild/Collect_wild_imgs_train.m b/matlab_version/experiments_in_the_wild/Collect_wild_imgs_train.m deleted file mode 100644 index de04310b..00000000 --- a/matlab_version/experiments_in_the_wild/Collect_wild_imgs_train.m +++ /dev/null @@ -1,121 +0,0 @@ -function [images, detections, labels] = Collect_wild_imgs_train(root_test_data) - - use_lfpw = true; - use_helen = true; - - use_68 = true; - - images = []; - labels = []; - detections = []; - - 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_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_LFPW(root_test_data, use_68) - -dataset_loc = [root_test_data, '/lfpw/trainset/']; - -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_trainset.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_helen(root_test_data, use_68) - -dataset_loc = [root_test_data, '/helen/trainset/']; - -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_trainset.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 diff --git a/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results.m b/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results.m deleted file mode 100644 index 8a5406fc..00000000 --- a/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results.m +++ /dev/null @@ -1,63 +0,0 @@ -clear - -%% -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; - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_dclm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, 'DisplayName', 'DCLM', 'LineWidth',line_width); - -load('results/results_wild_dclm_wild.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, 'DisplayName', 'DCLM2', 'LineWidth',line_width); - - -set(gca,'xtick',[0:0.01:0.08]) -xlim([0,0.08]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting on 300W','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); -print -dpng results/dclm_results.png diff --git a/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results_sparse.m b/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results_sparse.m deleted file mode 100644 index 21f0f868..00000000 --- a/matlab_version/experiments_in_the_wild/Display_clnf_dclm_results_sparse.m +++ /dev/null @@ -1,49 +0,0 @@ -clear - -%% -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; - -load('results/results_wild_dclm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, 'DisplayName', 'DCLM', 'LineWidth',line_width); - -load('results/results_wild_dclm_general_sparse_h.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, 'DisplayName', 'DCLM sparse', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.01:0.08]) -xlim([0,0.08]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting on 300W','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); -% print -dpng results/dclm_results.png diff --git a/matlab_version/experiments_in_the_wild/Display_clnf_results_general.m b/matlab_version/experiments_in_the_wild/Display_clnf_results_general.m deleted file mode 100644 index fb41ee9c..00000000 --- a/matlab_version/experiments_in_the_wild/Display_clnf_results_general.m +++ /dev/null @@ -1,116 +0,0 @@ -clear - -%% -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; - -load('results/results_wild_clnf_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'g','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clm_general.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clm_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -% plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels([1:60,62:64,66:end],:,:); -shapes = experiments.shapes([1:60,62:64,66:end],:,:); -labels = labels(18:end,:,:) - 0.5; -shapes = shapes(18:end,:,:); - -clnf_hierarch_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_hierarch_error); - -plot(error_x, error_y, 'r','DisplayName', 'OpenFace', 'LineWidth',line_width); - - -set(gca,'xtick',[0:0.02:0.06]) -xlim([0,0.08]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -% title('Fitting in the wild without outline','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -%% -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','Times New Roman'); - -line_width = 6; -hold on; - -load('results/results_wild_clnf_general.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, '--g','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clm_general.mat'); -experiments(1).labels = experiments(1).labels - 0.5; -experiments(1).shapes = experiments(1).shapes; - -clm_error = compute_error( experiments(1).labels, experiments(1).shapes); - -[error_x, error_y] = cummErrorCurve(clm_error); - -plot(error_x, error_y, '--b','DisplayName', 'CLM+', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_final_inner.mat'); -experiments(1).labels = experiments(1).labels - 0.5; -experiments(1).shapes = experiments(1).shapes; - -clnf_hierarch_error = compute_error( experiments(1).labels, experiments(1).shapes); - -[error_x, error_y] = cummErrorCurve(clnf_hierarch_error); - -plot(error_x, error_y, 'r','DisplayName', 'CLNF hierarch', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.02:0.08]) -xlim([0,0.08]); -xlabel('Size normalised shape RMS error','FontName','Times New Roman'); -ylabel('Proportion of images','FontName','Times New Roman'); -grid on -title('Fitting in the wild with outline','FontSize',60,'FontName','Times New Roman'); - -legend('show', 'Location', 'SouthEast'); diff --git a/matlab_version/experiments_in_the_wild/Errors_PDM_basic.mat b/matlab_version/experiments_in_the_wild/Errors_PDM_basic.mat deleted file mode 100644 index f83dba9e..00000000 Binary files a/matlab_version/experiments_in_the_wild/Errors_PDM_basic.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/Errors_PDM_eyes.mat b/matlab_version/experiments_in_the_wild/Errors_PDM_eyes.mat deleted file mode 100644 index 53f3aa1e..00000000 Binary files a/matlab_version/experiments_in_the_wild/Errors_PDM_eyes.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/Script_CLM_general.m b/matlab_version/experiments_in_the_wild/Script_CLM_general.m deleted file mode 100644 index df9ebf1f..00000000 --- a/matlab_version/experiments_in_the_wild/Script_CLM_general.m +++ /dev/null @@ -1,185 +0,0 @@ -function Script_CLM_general() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'svr_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -verbose = false; % set to true to visualise the fitting -output_root = './wild_fit_clm_general/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -% the default model parameters to use -clmParams.regFactor = [35, 27, 20, 5]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.75]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 12.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; - -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - all_lmark_lhoods(:,i) = lmark_lhood; - all_views_used(i) = view_used; - - % shape correction for matlab format - shapes_all(:,:,i) = shape; - labels_all(:,:,i) = labels(i,:,:); - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - 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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc -experiment.lhoods = lhoods; -experiment.shapes = shapes_all; -experiment.labels = labels_all; -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_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)); - -%% -output_results = 'results/results_wild_clm_general.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/Script_CLM_general_vis_resp.m b/matlab_version/experiments_in_the_wild/Script_CLM_general_vis_resp.m deleted file mode 100644 index 66d6b983..00000000 --- a/matlab_version/experiments_in_the_wild/Script_CLM_general_vis_resp.m +++ /dev/null @@ -1,82 +0,0 @@ -function Script_CLM_general_vis_resp() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -to_vis = [29,51,75,79,81,9,112,146,152,172,199,204,230,234,235,241,251,256,263,272,279,340,342,348,358,362,394,478,484,486]; -images = images(to_vis); -detections = detections(to_vis,:); -labels = labels(to_vis,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [31,31;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'svr_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -out_dir_root = './patch_expert_responses/'; - -if(~exist(out_dir_root, 'dir')) - mkdir(out_dir_root); -end - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 1; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(M)/3; - -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,:); - out_dir = [out_dir_root, '/', num2str(to_vis(i))]; - if(~exist(out_dir, 'dir')) - mkdir(out_dir); - end - - Fitting_from_bb_vis(image, [], bbox, pdm, patches, clmParams, out_dir); - -end - -end diff --git a/matlab_version/experiments_in_the_wild/Script_CLNF_general.m b/matlab_version/experiments_in_the_wild/Script_CLNF_general.m deleted file mode 100644 index cddb448e..00000000 --- a/matlab_version/experiments_in_the_wild/Script_CLNF_general.m +++ /dev/null @@ -1,187 +0,0 @@ -function Script_CLNF_general() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image -patches = patches(1); -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']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 3; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; - -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - -% 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc - -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); -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)); - -%% -output_results = 'results/results_wild_clnf_general.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/Script_CLNF_general_vis_resp.m b/matlab_version/experiments_in_the_wild/Script_CLNF_general_vis_resp.m deleted file mode 100644 index 73843056..00000000 --- a/matlab_version/experiments_in_the_wild/Script_CLNF_general_vis_resp.m +++ /dev/null @@ -1,82 +0,0 @@ -function Script_CLNF_general_vis_resp() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -to_vis = [29,51,75,79,81,9,112,146,152,172,199,204,230,234,235,241,251,256,263,272,279,340,342,348,358,362,394,478,484,486]; -images = images(to_vis); -detections = detections(to_vis,:); -labels = labels(to_vis,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [31,31;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -out_dir_root = './patch_expert_responses/'; - -if(~exist(out_dir_root, 'dir')) - mkdir(out_dir_root); -end - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 1; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(M)/3; - -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,:); - out_dir = [out_dir_root, '/', num2str(to_vis(i))]; - if(~exist(out_dir, 'dir')) - mkdir(out_dir); - end - - Fitting_from_bb_vis(image, [], bbox, pdm, patches, clmParams, out_dir); - -end - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general.m deleted file mode 100644 index 584597e9..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general.m +++ /dev/null @@ -1,186 +0,0 @@ -function Script_DCLM_general() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21; 21,21]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/dpn/', 'dpn_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 4; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; -verbose = 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,:); - - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - -% 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc - -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); -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)); - -%% -output_results = 'results/results_wild_dclm_general.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_sparse.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_sparse.m deleted file mode 100644 index 06f38cfe..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_sparse.m +++ /dev/null @@ -1,211 +0,0 @@ -function Script_DCLM_general_sparse() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21; 21,21]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/dpn/', 'dpn_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm_sparse/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 4; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; -verbose = false; -tic - - -% for recording purposes -experiment.params = clmParams; - -% Turn off the visibilities for scale 0, as we do not need to detect all -% landmarks in the first scale -to_rem_from = [1,2,3,6,7]; -% Median based -%to_rem_init = [68;56;4;34;29;39;19;62;59;18;54;14;11;61;30;42;48;41;52;51;44;33;9;63;2;16;58;25;28;67];%;23;35;26;7;]; -% Mean based - -to_rem_1 = [4;68;58;62;51;6;59;20;63;53;25;56;14;64;9;67;2;33;11;37;17;52;26;60;28;34;44;38;29;8;21;15;12;18]; -to_rem_2 = [6;62;50;25;59;20;17;66;64;57;39;14;12;68;41;45;34;43;30;60;4;29;1;61;47;9;65;52;37;22;15;35;54;58]; -to_rem_3 = [66;62;54;60;38;5;30;13;28;59;44]; - -patches(1).visibilities(to_rem_from, to_rem_1) = 0; -patches(2).visibilities(to_rem_from, to_rem_2) = 0; -patches(3).visibilities(to_rem_from, to_rem_3) = 0; - -% If the third scale the same as first, does it work? -% patches(3).visibilities(to_rem_from, to_rem_3) = 0; - -% patches(4).visibilities(to_rem_from, to_rem_2) = 0; - -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - -% 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc - -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); -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)); - -%% -output_results = 'results/results_wild_dclm_general_sparse_h.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_resp.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_resp.m deleted file mode 100644 index 3f072154..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_resp.m +++ /dev/null @@ -1,82 +0,0 @@ -function Script_DCLM_general_vis_resp() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -to_vis = [29,51,75,79,81,9,112,146,152,172,199,204,230,234,235,241,251,256,263,272,279,340,342,348,358,362,394,478,484,486]; -images = images(to_vis); -detections = detections(to_vis,:); -labels = labels(to_vis,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [31,31;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/general/', 'dccnf_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -out_dir_root = './patch_expert_responses/'; - -if(~exist(out_dir_root, 'dir')) - mkdir(out_dir_root); -end - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 1; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(M)/3; - -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,:); - out_dir = [out_dir_root, '/', num2str(to_vis(i))]; - if(~exist(out_dir, 'dir')) - mkdir(out_dir); - end - - Fitting_from_bb_vis(image, [], bbox, pdm, patches, clmParams, out_dir); - -end - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select.m deleted file mode 100644 index 5f95421e..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select.m +++ /dev/null @@ -1,232 +0,0 @@ -function Script_DCLM_general_vis_select() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'C:\Users\tbaltrus\Documents\DATA/300-W/'; -end - -[images, detections, labels] = Collect_wild_imgs_train(root_test_data); - -% Only use a subset of images as otherwise it will take a bit too long -rng(0); -subset = randperm(numel(images), 750); -images = images(subset); -detections = detections(subset,:); -labels = labels(subset,:,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/dpn/', 'dpn_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 3; - -num_points = numel(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 = true; -verbose = false; -tic - -experiments_full = struct; - -best_so_far = [66;62;54;60;38;5;30;13;28;59;44]; - -% The first patch removal -to_rem_1 = [4;68;58;62;51;6;59;20;63;53;25;56;14;64;9;67;2;33;11;37;17;52;26;60;28;34;44;38;29;8;21;15;12;18]; -to_rem_2 = [6;62;50;25;59;20;17;66;64;57;39;14;12;68;41;45;34;43;30;60;4;29;1;61;47;9;65;52;37;22;15;35;54;58]; -to_rem_from = [1,2,3,6,7]; -% patches(1).visibilities(to_rem_from,to_rem_init) = 0; - -% A greedy method for removing visibilities -for to_rem = 1:23 - - % Not ideal ones to turn off, but a much faster version - all_ids = 1:68; - visibility_off = setdiff(all_ids, best_so_far); - inds = randperm(numel(visibility_off), 20); - visibility_off = visibility_off(inds); - - % for recording purposes - experiment.params = clmParams; - - for w=visibility_off - - patches(1).visibilities(to_rem_from,to_rem_1) = 0; - patches(2).visibilities(to_rem_from,to_rem_2) = 0; - patches(3).visibilities(to_rem_from,:) = 1; - to_rem_c = cat(1, best_so_far, w); - if(w > 0) - patches(3).visibilities(to_rem_from,to_rem_c) = 0; - end - 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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - % 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - - end - toc - - experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); - experiment.v_off = w; - experiment.err = mean(experiment.errors_normed); - experiment.err_med = median(experiment.errors_normed); - % 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)); - - end - - % Grab the best suceeding switch off - [~,id] = min(cat(1, experiments.err)); - best_so_far = cat(1, best_so_far, experiments(id).v_off); - experiments_full(numel(best_so_far)).best_so_far = best_so_far; - experiments_full(numel(best_so_far)).error_mean = experiments(id).err; - experiments_full(numel(best_so_far)).error_med = experiments(id).err_med; - output_results = 'results/results_wild_dclm_vis_off_scale3.mat'; - save(output_results, 'experiments_full'); - clear experiments - clear experiment -end -%% - - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_base.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_base.m deleted file mode 100644 index 4a94c6ca..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_base.m +++ /dev/null @@ -1,233 +0,0 @@ - function Script_DCLM_general_vis_select_base() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs_train(root_test_data); - -% Only use a subset of images as otherwise it will take a bit too long -rng(0); -subset = randperm(numel(images), 500); -images = images(subset); -detections = detections(subset,:); -labels = labels(subset,:,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21; 21,21]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/dpn/', 'dpn_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 4; - -num_points = numel(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 = true; -verbose = false; -tic - -experiments_full = struct; - -best_so_far = []; - -% Base is 0.033 mean and 0.0291 median - -% The first patch removal -% to_rem_init = [68;56;4;34;29;39;19;62;59;18;54;14;11;61;30;42;48;41;52;51;44;33;9;63;2;16;58;25;28;67;23;35;26;7;]; -% to_rem_from = [1,2,3,6,7]; -% patches(1).visibilities(to_rem_from,to_rem_init) = 0; - -% A greedy method for removing visibilities -for to_rem = 1:1 - - visibility_off = 0:1:68; - visibility_off = setdiff(visibility_off, best_so_far); - - % for recording purposes - experiment.params = clmParams; - - for w=visibility_off - - -% patches(2).visibilities(to_rem_from,:) = 1; - to_rem_c = cat(1, best_so_far, w); - if(w > 0) - patches(2).visibilities(to_rem_from,to_rem_c) = 0; - end - 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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - % 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - - end - toc - - experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); - 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; - experiment.visibilities = patches(1).visibilities; - experiment.v_off = w; - experiment.err = median(experiment.errors_normed); - % 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)); - - end - - % Grab the best suceeding switch off - [~,id] = min(cat(1, experiments.err)); - best_so_far = cat(1, best_so_far, experiments(id).v_off); - experiments_full(numel(best_so_far)).best_so_far = best_so_far; - experiments_full(numel(best_so_far)).error = experiments(id).err; - output_results = 'results/results_wild_dclm_vis_on.mat'; - save(output_results, 'experiments_full'); - clear experiments - clear experiment -end -%% - - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_scale_0.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_scale_0.m deleted file mode 100644 index 580f013a..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_vis_select_scale_0.m +++ /dev/null @@ -1,199 +0,0 @@ -function Script_DCLM_general_vis_select_scale_0() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs_train(root_test_data); - -% Only use a subset of images as otherwise it will take a bit too long -rng(0); -subset = randperm(numel(images), 1000); -images = images(subset); -detections = detections(subset,:); -labels = labels(subset,:,:); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/dpn/', 'dpn_patches_*_general.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 1; - -num_points = numel(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 = true; -verbose = false; -tic - -experiments_full = struct; - -% The first patch removal -to_rem_from = [1,2,3,6,7]; - - -% A greedy method for removing visibilities -for reps = 1:500 - - % Removing half of the landmarks - to_rem = randperm(68, 34); - - patches(1).visibilities(to_rem_from,:) = 1; - - patches(1).visibilities(to_rem_from, to_rem) = 0; - - 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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - % 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - - end - toc - - experiments_full(reps).to_rem = to_rem; - experiments_full(reps).mean_error = mean(compute_error(labels_all - 0.5, shapes_all)); - experiments_full(reps).median_error = median(compute_error(labels_all - 0.5, shapes_all)); - - output_results = 'results/results_wild_dclm_vis_off_scale_0.mat'; - save(output_results, 'experiments_full'); - -end -%% - - -end diff --git a/matlab_version/experiments_in_the_wild/Script_DCLM_general_wild.m b/matlab_version/experiments_in_the_wild/Script_DCLM_general_wild.m deleted file mode 100644 index 3071f31d..00000000 --- a/matlab_version/experiments_in_the_wild/Script_DCLM_general_wild.m +++ /dev/null @@ -1,186 +0,0 @@ -function Script_DCLM_general_wild() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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 = 'D:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21; 21,21]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_DCLM_Patch_Experts( '../models/wild/', 'dccnf_patches_*_wild.mat', [], [], clmParams); - -%% Fitting the model to the provided image - -output_root = './wild_fit_dclm/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -clmParams.regFactor = [35, 27, 20, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5, 7.5]; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams.numPatchIters = 4; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; -verbose = true; -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - 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(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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - -% 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc - -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_all); -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)); - -%% -output_results = 'results/results_wild_dclm_wild.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/compute_error.m b/matlab_version/experiments_in_the_wild/compute_error.m deleted file mode 100644 index 8debb0f8..00000000 --- a/matlab_version/experiments_in_the_wild/compute_error.m +++ /dev/null @@ -1,41 +0,0 @@ -function [ error_per_image, err_pp, err_pp_dim ] = 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); -err_pp = zeros(num_of_images, num_of_points); -err_pp_dim = zeros(num_of_images, num_of_points, 2); - -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,:)); - err_pp(i,j) = norm(detected_points(j,:)-ground_truth_points(j,:)); - err_pp_dim(i,j,1) = detected_points(j,1)-ground_truth_points(j,1); - err_pp_dim(i,j,2) = detected_points(j,2)-ground_truth_points(j,2); - end - error_per_image(i) = sum/(num_of_points*interocular_distance); - err_pp(i,:) = err_pp(i,:) ./ interocular_distance; - err_pp_dim(i,:) = err_pp_dim(i,:) ./ interocular_distance; -end - -end diff --git a/matlab_version/experiments_in_the_wild/cummErrorCurve.m b/matlab_version/experiments_in_the_wild/cummErrorCurve.m deleted file mode 100644 index e18a1ada..00000000 --- a/matlab_version/experiments_in_the_wild/cummErrorCurve.m +++ /dev/null @@ -1,19 +0,0 @@ -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 - diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Display_clnf_results_hierarch.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Display_clnf_results_hierarch.m deleted file mode 100644 index dd35f903..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Display_clnf_results_hierarch.m +++ /dev/null @@ -1,202 +0,0 @@ -clear - -%% -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; - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; -labels(1:17,:,:) = []; -shapes(1:17,:,:) = []; - -[clnf_error, err_pp] = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'b','DisplayName', 'CLNF inner', 'LineWidth',line_width); - -load('results/results_wild_clnf_general.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; -labels(1:17,:,:) = []; -shapes(1:17,:,:) = []; - -[clnf_error, err_pp] = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'g','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_hierarch.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -labels(1:17,:,:) = []; -shapes(1:17,:,:) = []; -[clnf_error, err_pp_h] = compute_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLNF hierarch', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.025:0.1]) -xlim([0,0.1]); -xlabel('Size normalised shape RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -%% -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; - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error_left = compute_error_point_to_line_left_eye( labels, shapes); -clnf_error_right = compute_error_point_to_line_right_eye( labels, shapes); -clnf_error = cat(1, clnf_error_left, clnf_error_right); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'b','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_hierarch.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error_left = compute_error_point_to_line_left_eye( labels, shapes); -clnf_error_right = compute_error_point_to_line_right_eye( labels, shapes); -clnf_error = cat(1, clnf_error_left, clnf_error_right); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLNF hierarch', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.01:0.05]) -xlim([0,0.05]); -xlabel('Size normalised eyelid RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -%% -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; - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error = compute_mouth_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'b','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_hierarch.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error = compute_mouth_error( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLNF hierarch', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.02:0.08]) -xlim([0,0.08]); -xlabel('Size normalised mouth RMS error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); - -%% -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; - -load('results/results_wild_clnf_general_final_inner.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error = compute_brow_error_to_line( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'b','DisplayName', 'CLNF', 'LineWidth',line_width); - -load('results/results_wild_clnf_general_hierarch.mat'); -labels = experiments.labels - 0.5; -shapes = experiments.shapes; - -clnf_error = compute_brow_error_to_line( labels, shapes); - -[error_x, error_y] = cummErrorCurve(clnf_error); -hold on; - -plot(error_x, error_y, 'r','DisplayName', 'CLNF hierarch', 'LineWidth',line_width); - -set(gca,'xtick',[0:0.02:0.08]) -xlim([0,0.08]); -xlabel('Brow error','FontName','Helvetica'); -ylabel('Proportion of images','FontName','Helvetica'); -grid on -title('Fitting in the wild','FontSize',60,'FontName','Helvetica'); - -legend('show', 'Location', 'SouthEast'); \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_basic.mat b/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_basic.mat deleted file mode 100644 index 2111488a..00000000 Binary files a/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_basic.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_eyes.mat b/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_eyes.mat deleted file mode 100644 index 783c4ffa..00000000 Binary files a/matlab_version/experiments_in_the_wild/hierarch_checks/Errors_PDM_eyes.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_eyes.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_eyes.m deleted file mode 100644 index 4e86e78d..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_eyes.m +++ /dev/null @@ -1,196 +0,0 @@ -function Script_CLNF_general_eyes() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -%% 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_eyes.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -% the default model parameters to use -clmParams.regFactor = 25; -clmParams.sigmaMeanShift = 2; -clmParams.tikhonov_factor = 5; - -clmParams.startScale = 1; -clmParams.num_RLMS_iter = 10; -clmParams.fTol = 0.01; -clmParams.useMultiScale = true; -clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; - -% for recording purposes -experiment.params = clmParams; - -num_points = numel(M)/3; - -errors = zeros(numel(images),1); -shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -errors_normed = zeros(numel(images),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 = true; - -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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - all_lmark_lhoods(:,i) = lmark_lhood; - all_views_used(i) = view_used; - - % TODO the shape correction? - shape = shape + 1; - - shapes_all(:,:,i) = shape; - labels_all(:,:,i) = labels(i,:,:); - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - valid_points = sum(squeeze(labels(i,:,:)),2) > 0; - valid_points(1:17) = 0; - - actualShape = squeeze(labels(i,:,:)); - errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); - width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; - errors_normed(i) = errors(i)/width; - lhoods(i) = lhood; - if(verbose) - [height_img, width_img,~] = size(image_orig); - width = max(actualShape(:,1)) - min(actualShape(:,1)); - height = max(actualShape(:,2)) - min(actualShape(:,2)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc -experiment.errors = errors; -experiment.errors_normed = errors_normed; -experiment.lhoods = lhoods; -experiment.shapes = shapes_all; -experiment.labels = labels_all; -experiment.ibug_error = compute_error(labels_all, shapes_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(errors_normed), median(errors_normed)); - -%% -output_results = 'results/results_wild_clnf_general_eyes.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_hierarch.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_hierarch.m deleted file mode 100644 index 8b3258f5..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_hierarch.m +++ /dev/null @@ -1,252 +0,0 @@ -function Script_CLNF_general_hierarch() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% loading the patch experts and PDMs - -clmParams = struct; - -clmParams.window_size = [25,25; 23,23; 21,21;]; -clmParams.numPatchIters = size(clmParams.window_size,1); - -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -verbose = true; % set to true to visualise the fitting -output_root = './wild_fit_clnf_hierarch/'; - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); -pdm = struct; pdm.M = double(M); pdm.E = double(E); pdm.V = double(V); - -% the default full face model parameters to use -clmParams.regFactor = [35, 27, 20]; -clmParams.sigmaMeanShift = [1.25, 1.375, 1.5]; -clmParams.tikhonov_factor = [2.5, 5, 7.5]; - -clmParams.startScale = 1; clmParams.num_RLMS_iter = 10; clmParams.fTol = 0.01; -clmParams.useMultiScale = true; clmParams.use_multi_modal = 1; -clmParams.multi_modal_types = patches(1).multi_modal_types; - -% Loading eye PDM and patch experts -[clmParams_eye, pdm_right_eye, pdm_left_eye] = Load_CLM_params_eye(); -[patches_right_eye] = Load_Patch_Experts( '../models/hierarch/', 'ccnf_patches_*_combined.mat', [], [], clmParams_eye); -[patches_left_eye] = Load_Patch_Experts( '../models/hierarch/', 'left_ccnf_patches_*_combined.mat', [], [], clmParams_eye); -clmParams_eye.multi_modal_types = patches_right_eye(1).multi_modal_types; -right_eye_inds = [43,44,45,46,47,48]; -left_eye_inds = [37,38,39,40,41,42]; - -% Loading mouth PDM and patch experts -[clmParams_mouth, pdm_mouth] = Load_CLM_params_mouth(); -[patches_mouth] = Load_Patch_Experts( '../models/hierarch/', 'ccnf_patches_*_mouth_mv.mat', [], [], clmParams_mouth); -clmParams_mouth.multi_modal_types = patches_mouth(1).multi_modal_types; -mouth_inds = 49:68; - -% Loading brow PDM and patch experts -[clmParams_brow, pdm_brow] = Load_CLM_params_brows(); -[patches_brow] = Load_Patch_Experts( '../models/hierarch/', 'ccnf_patches_*_brow.mat', [], [], clmParams_brow); -clmParams_mouth.multi_modal_types = patches_brow(1).multi_modal_types; -brow_inds = 18:27; - -%% for recording purposes -experiment.params = clmParams; - -num_points = numel(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 = true; - -%% 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 - if(multi_view) - - views = [0,0,0; 0,-30,0; -30,0,0; 0,30,0; 30,0,0]; - views = views * pi/180; - - shapes = zeros(num_points, 2, size(views,1)); - ls = zeros(size(views,1),1); - lmark_lhoods = zeros(num_points,size(views,1)); - views_used = zeros(num_points,size(views,1)); - - % Find the best orientation - for v = 1:size(views,1) - [shapes(:,:,v),~,~,ls(v),lmark_lhoods(:,v),views_used(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); - end - - [lhood, v_ind] = max(ls); - lmark_lhood = lmark_lhoods(:,v_ind); - - shape = shapes(:,:,v_ind); - view_used = views_used(v); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - all_lmark_lhoods(:,i) = lmark_lhood; - all_views_used(i) = view_used; - - %% now fit the hierarchical models (eyes and mouth) - - % Perform eye fitting now - shape_r_eye = shape(right_eye_inds, :); - - [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D_no_reg(pdm_right_eye.M, pdm_right_eye.E, pdm_right_eye.V, shape_r_eye); - - bbox = [min(shape_r_eye(:,1)), min(shape_r_eye(:,2)), max(shape_r_eye(:,1)), max(shape_r_eye(:,2))]; - - g_param = [a; Rot2Euler(R)'; T]; - - [shape_r_eye] = Fitting_from_bb(image, [], bbox, pdm_right_eye, patches_right_eye, clmParams_eye, 'gparam', g_param, 'lparam', l_params); - - % Perform eye fitting now - shape_l_eye = shape(left_eye_inds, :); - - [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D_no_reg(pdm_left_eye.M, pdm_left_eye.E, pdm_left_eye.V, shape_l_eye); - - bbox = [min(shape_l_eye(:,1)), min(shape_l_eye(:,2)), max(shape_l_eye(:,1)), max(shape_l_eye(:,2))]; - - g_param = [a; Rot2Euler(R)'; T]; - - [shape_l_eye] = Fitting_from_bb(image, [], bbox, pdm_left_eye, patches_left_eye, clmParams_eye, 'gparam', g_param, 'lparam', l_params); - - % Perform mouth fitting now - shape_mouth = shape(mouth_inds, :); - - [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D_no_reg(pdm_mouth.M, pdm_mouth.E, pdm_mouth.V, shape_mouth); - - bbox = [min(shape_mouth(:,1)), min(shape_mouth(:,2)), max(shape_mouth(:,1)), max(shape_mouth(:,2))]; - - g_param = [a; Rot2Euler(R)'; T]; - - [shape_mouth] = Fitting_from_bb(image, [], bbox, pdm_mouth, patches_mouth, clmParams_mouth, 'gparam', g_param, 'lparam', l_params); - - % Perform brow fitting now - shape_brow = shape(brow_inds, :); - - [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D_no_reg(pdm_brow.M, pdm_brow.E, pdm_brow.V, shape_brow); - g_param = [a; Rot2Euler(R)'; T]; - - bbox = [min(shape_brow(:,1)), min(shape_brow(:,2)), max(shape_brow(:,1)), max(shape_brow(:,2))]; - - [shape_brow] = Fitting_from_bb(image, [], bbox, pdm_brow, patches_brow, clmParams_brow, 'gparam', g_param, 'lparam', l_params); - - % Now after detections incorporate the eyes back - % into the face model - - shape(left_eye_inds, :) = shape_l_eye; - shape(right_eye_inds, :) = shape_r_eye; - shape(mouth_inds, :) = shape_mouth; - shape(brow_inds, :) = shape_brow; - - [ ~, ~, ~, ~, ~, ~, shape_fit] = fit_PDM_ortho_proj_to_2D_no_reg(pdm.M, pdm.E, pdm.V, shape); - - %% Incorporate the hierarchical models back into the joint PDM - - shapes_all(:,:,i) = shape_fit; - labels_all(:,:,i) = labels(i,:,:); - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - 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)); - - img_min_x = max(int32(min(actualShape(:,1))) - width/3,1); - img_max_x = min(int32(max(actualShape(:,1))) + width/3,width_img); - - img_min_y = max(int32(min(actualShape(:,2))) - height/3,1); - img_max_y = min(int32(max(actualShape(:,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) - v_points = sum(squeeze(labels(i,:,:)),2) > 0; - - 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(v_points,1), shape(v_points,2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points,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; - close(f); - catch warn - - end - end - -end -toc -experiment.lhoods = lhoods; -experiment.shapes = shapes_all; -experiment.labels = labels_all; -experiment.errors_normed = compute_error(labels_all - 0.5, shapes_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)); - -%% -output_results = 'results/results_wild_clnf_general_hierarch.mat'; -save(output_results, 'experiments'); - -end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m deleted file mode 100644 index e83a29d6..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_PDM_eyes() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% Fitting the model to the provided image - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild_eyes.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -num_points = numel(M)/3; - -errors = zeros(numel(images),1); -shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -errors_normed = zeros(numel(images),1); - -errors_left_eye = zeros(numel(images),1); -errors_right_eye = zeros(numel(images),1); - -tic -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - if(size(image,3) == 3) - image = rgb2gray(image); - end - - labels_curr = squeeze(labels(i,:,:)); - - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); - - shape = shapeOrtho; - shapes_all(:,:,i) = shapeOrtho; - labels_all(:,:,i) = labels_curr; - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - valid_points = sum(squeeze(labels(i,:,:)),2) > 0; - valid_points(1:17) = 0; - - actualShape = squeeze(labels(i,:,:)); - errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); - width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; - errors_normed(i) = errors(i)/width; - - errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); - errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - - if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) - imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; - end -end - -save('Errors_PDM_eyes.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); - -end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m deleted file mode 100644 index fb52e2ed..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_PDM_general() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% 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/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% Fitting the model to the provided image - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -num_points = numel(M)/3; - -errors = zeros(numel(images),1); -shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -errors_normed = zeros(numel(images),1); - -errors_left_eye = zeros(numel(images),1); -errors_right_eye = zeros(numel(images),1); - -tic -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - if(size(image,3) == 3) - image = rgb2gray(image); - end - - labels_curr = squeeze(labels(i,:,:)); - - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); - - shape = shapeOrtho; - shapes_all(:,:,i) = shapeOrtho; - labels_all(:,:,i) = labels_curr; - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - valid_points = sum(squeeze(labels(i,:,:)),2) > 0; - valid_points(1:17) = 0; - - actualShape = squeeze(labels(i,:,:)); - errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); - width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; - errors_normed(i) = errors(i)/width; - - errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); - errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - - if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) - imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; - end -end - -save('Errors_PDM_basic.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); - -end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_brow_error_to_line.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_brow_error_to_line.m deleted file mode 100644 index 594a8ba0..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_brow_error_to_line.m +++ /dev/null @@ -1,89 +0,0 @@ -function [ error_per_image ] = compute_brow_error( ground_truth_all, detected_points_all, occluded ) -%compute_error -% compute the average point-to-point Euclidean error of right eye 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 - -brow_inds_from_68 = 18:27; -brow_inds_from_49 = 1:10; - -brow_inds_from_66 = 18:27; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 10) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68) - detected_points = detected_points_all(brow_inds_from_68,:,i); - elseif(num_points_det == 66) - detected_points = detected_points_all(brow_inds_from_66,:,i); - elseif(num_points_det == 49) - detected_points = detected_points_all(brow_inds_from_49,:,i); - end - - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(brow_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(brow_inds_from_68,:,:); - end - - sum=0; - - for j=1:size(detected_points,1) - - if(j== 1 || j == 5 || j == 6 || j == 10) - % eye corners should align perfectly - sum = sum + norm(detected_points(j,:)-ground_truth_points(j,:)); - else - sum = sum + point_to_segments(detected_points(j,:), ground_truth_points(j-1:j+1,:)); - end - end - - error_per_image(i) = sum/(size(detected_points,1)*interocular_distance); -end - -if(nargin > 2) - error_per_image = error_per_image(~occluded); -end - -end - -function seg_dist = point_to_segments(point, segments) - - seg_dists = zeros(size(segments, 1)-1,1); - - for i=1:size(segments, 1)-1 - - vec1 = point - segments(i,:); - vec2 = segments(i+1,:) - segments(i,:); - - d = (vec1 * vec2') / (norm(vec2)^2); - - if(d < 0) - seg_dists(i) = norm(vec1); - elseif(d > 1) - seg_dists(i) = norm(point - segments(i+1,:)); - else - seg_dists(i) = sqrt( norm(vec1)^2 - norm(d * vec2)^2); - end - end - seg_dist = min(seg_dists); -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m deleted file mode 100644 index 4b93b432..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m +++ /dev/null @@ -1,86 +0,0 @@ -function [ error_per_image ] = compute_error_point_to_line_left_eye( ground_truth_all, detected_points_all, occluded ) -%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 - - - -right_eye_inds_from_68 = [37,38,39,40,41,42,37]; -right_eye_inds_from_28 = [9,11,13,15,17,19]; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 6) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68 || num_points_det == 66) - detected_points = detected_points_all(right_eye_inds_from_68,:,i); - elseif(num_points_det == 28) - detected_points = detected_points_all(right_eye_inds_from_28,:,i); - elseif(num_points_det == 49) - - end - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - end - - sum=0; - for j=1:6 - - if(j== 1 || j == 6) - % eye corners should align perfectly - sum = sum + norm(detected_points(j,:)-ground_truth_points(j,:)); - else - % points between eye corners measured in distance to the two appropriate line - % segments - sum = sum + point_to_segments(detected_points(j,:), ground_truth_points(j-1:j+1,:)); - end - end - error_per_image(i) = sum/(6*interocular_distance); -end - -error_per_image = error_per_image(~occluded); - -end - -function seg_dist = point_to_segments(point, segments) - - seg_dists = zeros(size(segments, 1)-1,1); - - for i=1:size(segments, 1)-1 - - vec1 = point - segments(i,:); - vec2 = segments(i+1,:) - segments(i,:); - - d = (vec1 * vec2') / (norm(vec2)^2); - - if(d < 0) - seg_dists(i) = norm(vec1); - elseif(d > 1) - seg_dists(i) = norm(point - segments(i+1,:)); - else - seg_dists(i) = sqrt( norm(vec1)^2 - norm(d * vec2)^2); - end - end - seg_dist = min(seg_dists); -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m deleted file mode 100644 index b6dd94a0..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m +++ /dev/null @@ -1,86 +0,0 @@ -function [ error_per_image ] = compute_error_point_to_line_right_eye( ground_truth_all, detected_points_all, occluded ) -%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 - - - -right_eye_inds_from_68 = [43,44,45,46,47,48,43]; -right_eye_inds_from_28 = [9,11,13,15,17,19]; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 6) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68 || num_points_det == 66) - detected_points = detected_points_all(right_eye_inds_from_68,:,i); - elseif(num_points_det == 28) - detected_points = detected_points_all(right_eye_inds_from_28,:,i); - elseif(num_points_det == 49) - - end - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - end - - sum=0; - for j=1:6 - - if(j== 1 || j == 6) - % eye corners should align perfectly - sum = sum + norm(detected_points(j,:)-ground_truth_points(j,:)); - else - % points between eye corners measured in distance to the two appropriate line - % segments - sum = sum + point_to_segments(detected_points(j,:), ground_truth_points(j-1:j+1,:)); - end - end - error_per_image(i) = sum/(6*interocular_distance); -end - -error_per_image = error_per_image(~occluded); - -end - -function seg_dist = point_to_segments(point, segments) - - seg_dists = zeros(size(segments, 1)-1,1); - - for i=1:size(segments, 1)-1 - - vec1 = point - segments(i,:); - vec2 = segments(i+1,:) - segments(i,:); - - d = (vec1 * vec2') / (norm(vec2)^2); - - if(d < 0) - seg_dists(i) = norm(vec1); - elseif(d > 1) - seg_dists(i) = norm(point - segments(i+1,:)); - else - seg_dists(i) = sqrt( norm(vec1)^2 - norm(d * vec2)^2); - end - end - seg_dist = min(seg_dists); -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_mouth_error.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_mouth_error.m deleted file mode 100644 index 8c79c7ba..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_mouth_error.m +++ /dev/null @@ -1,66 +0,0 @@ -function [ error_per_image ] = compute_mouth_error( ground_truth_all, detected_points_all, occluded ) -%compute_error -% compute the average point-to-point Euclidean error of right eye 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 - -mouth_inds_from_68 = 49:68; -mouth_inds_from_49 = 30:49; - -mouth_inds_from_66 = 49:66; - -mouth_inds_from_20 = [1:12, 14:16, 18:20]; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 20) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68) - detected_points = detected_points_all(mouth_inds_from_68,:,i); - elseif(num_points_det == 66) - detected_points = detected_points_all(mouth_inds_from_66,:,i); - elseif(num_points_det == 49) - detected_points = detected_points_all(mouth_inds_from_49,:,i); - end - - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(mouth_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(mouth_inds_from_68,:,:); - end - - if(size(detected_points,1) == 18 && size(ground_truth_points,1) == 20) - ground_truth_points = ground_truth_points(mouth_inds_from_20,:); - end - sum=0; - - for j=1:size(detected_points,1) - sum = sum+norm(detected_points(j,:)-ground_truth_points(j,:)); - end - - error_per_image(i) = sum/(size(detected_points,1)*interocular_distance); -end - -if(nargin > 2) - error_per_image = error_per_image(~occluded); -end - -end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/plotcov2.m b/matlab_version/experiments_in_the_wild/hierarch_checks/plotcov2.m deleted file mode 100644 index bbd223b2..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/plotcov2.m +++ /dev/null @@ -1,182 +0,0 @@ -% PLOTCOV2 - Plots a covariance ellipse with major and minor axes -% for a bivariate Gaussian distribution. -% -% Usage: -% h = plotcov2(mu, Sigma[, OPTIONS]); -% -% Inputs: -% mu - a 2 x 1 vector giving the mean of the distribution. -% Sigma - a 2 x 2 symmetric positive semi-definite matrix giving -% the covariance of the distribution (or the zero matrix). -% -% Options: -% 'conf' - a scalar between 0 and 1 giving the confidence -% interval (i.e., the fraction of probability mass to -% be enclosed by the ellipse); default is 0.9. -% 'num-pts' - the number of points to be used to plot the -% ellipse; default is 100. -% -% This function also accepts options for PLOT. -% -% Outputs: -% h - a vector of figure handles to the ellipse boundary and -% its major and minor axes -% -% See also: PLOTCOV3 - -% Copyright (C) 2002 Mark A. Paskin -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -function h = plotcov2(mu, Sigma, varargin) - -if size(Sigma) ~= [2 2], error('Sigma must be a 2 by 2 matrix'); end -if length(mu) ~= 2, error('mu must be a 2 by 1 vector'); end - -[p, ... - n, ... - plot_opts] = process_options(varargin, 'conf', 0.9, ... - 'num-pts', 100); -h = []; -holding = ishold; -if (Sigma == zeros(2, 2)) - z = mu; -else - % Compute the Mahalanobis radius of the ellipsoid that encloses - % the desired probability mass. - k = conf2mahal(p, 2); - % The major and minor axes of the covariance ellipse are given by - % the eigenvectors of the covariance matrix. Their lengths (for - % the ellipse with unit Mahalanobis radius) are given by the - % square roots of the corresponding eigenvalues. - if (issparse(Sigma)) - [V, D] = eigs(Sigma); - else - [V, D] = eig(Sigma); - end - % Compute the points on the surface of the ellipse. - t = linspace(0, 2*pi, n); - u = [cos(t); sin(t)]; - w = (k * V * sqrt(D)) * u; - z = repmat(mu, [1 n]) + w; - % Plot the major and minor axes. - L = k * sqrt(diag(D)); - h = plot([mu(1); mu(1) + L(1) * V(1, 1)], ... - [mu(2); mu(2) + L(1) * V(2, 1)], plot_opts{:}); - hold on; - h = [h; plot([mu(1); mu(1) + L(2) * V(1, 2)], ... - [mu(2); mu(2) + L(2) * V(2, 2)], plot_opts{:})]; -end - -h = [h; plot(z(1, :), z(2, :), plot_opts{:})]; -if (~holding) hold off; end -end - -function [varargout] = process_options(args, varargin) - -% Check the number of input arguments -n = length(varargin); -if (mod(n, 2)) - error('Each option must be a string/value pair.'); -end - -% Check the number of supplied output arguments -if (nargout < (n / 2)) - error('Insufficient number of output arguments given'); -elseif (nargout == (n / 2)) - warn = 1; - nout = n / 2; -else - warn = 0; - nout = n / 2 + 1; -end - -% Set outputs to be defaults -varargout = cell(1, nout); -for i=2:2:n - varargout{i/2} = varargin{i}; -end - -% Now process all arguments -nunused = 0; -for i=1:2:length(args) - found = 0; - for j=1:2:n - if strcmpi(args{i}, varargin{j}) - varargout{(j + 1)/2} = args{i + 1}; - found = 1; - break; - end - end - if (~found) - if (warn) - warning(sprintf('Option ''%s'' not used.', args{i})); - args{i} - else - nunused = nunused + 1; - unused{2 * nunused - 1} = args{i}; - unused{2 * nunused} = args{i + 1}; - end - end -end - -% Assign the unused arguments -if (~warn) - if (nunused) - varargout{nout} = unused; - else - varargout{nout} = cell(0); - end -end -end - -% CONF2MAHAL - Translates a confidence interval to a Mahalanobis -% distance. Consider a multivariate Gaussian -% distribution of the form -% -% p(x) = 1/sqrt((2 * pi)^d * det(C)) * exp((-1/2) * MD(x, m, inv(C))) -% -% where MD(x, m, P) is the Mahalanobis distance from x -% to m under P: -% -% MD(x, m, P) = (x - m) * P * (x - m)' -% -% A particular Mahalanobis distance k identifies an -% ellipsoid centered at the mean of the distribution. -% The confidence interval associated with this ellipsoid -% is the probability mass enclosed by it. Similarly, -% a particular confidence interval uniquely determines -% an ellipsoid with a fixed Mahalanobis distance. -% -% If X is an d dimensional Gaussian-distributed vector, -% then the Mahalanobis distance of X is distributed -% according to the Chi-squared distribution with d -% degrees of freedom. Thus, the Mahalanobis distance is -% determined by evaluating the inverse cumulative -% distribution function of the chi squared distribution -% up to the confidence value. -% -% Usage: -% -% m = conf2mahal(c, d); -% -% Inputs: -% -% c - the confidence interval -% d - the number of dimensions of the Gaussian distribution -% -% Outputs: -% -% m - the Mahalanobis radius of the ellipsoid enclosing the -% fraction c of the distribution's probability mass -% -% See also: MAHAL2CONF - -% Copyright (C) 2002 Mark A. Paskin -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function m = conf2mahal(c, d) - -m = chi2inv(c, d); -% pr = 0.95 ; c = (1 - pr)/2 ; -% m = norminv([c 1-c],0,1) ; - -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/visualise_errors.m b/matlab_version/experiments_in_the_wild/hierarch_checks/visualise_errors.m deleted file mode 100644 index 2f9635bd..00000000 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/visualise_errors.m +++ /dev/null @@ -1,93 +0,0 @@ -% Visualising the errors - -%% First draw the initialisation errors -if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) - root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; -else - root_test_data = 'F:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; -labels = labels - 0.5; -num_points = size(labels,2); - -load(pdmLoc); -pdm = struct; pdm.M = double(M); pdm.E = double(E); pdm.V = double(V); - -shapes_init_all = zeros(num_points, 2, size(detections,1)); -errors_init_all = zeros(size(detections,1), 1); -views_used = zeros(size(detections,1), 1); -labels_all = zeros(num_points, 2, size(detections,1)); - -for i=1:size(detections,1) - labels_all(:,:,i) = labels(i,:,:); - % Find the best orientation - views = [0,0,0; 0,-20,0; 0,20,0; 30,0,0]; - views = views * pi/180; - - shapes_init = zeros(num_points, 2, size(views,1)); - error_init = zeros(size(views,1),1); - - for v = 1:size(views,1) - - bbox = detections(i,:); - bbox(2) = bbox(2) + 0.025 * (bbox(4) - bbox(2)); - rot = Euler2Rot(views(v,:)); - rot_m = rot * reshape(M, num_points, 3)'; - width_model = max(rot_m(1,:)) - min(rot_m(1,:)); - height_model = max(rot_m(2,:)) - min(rot_m(2,:)); - - a = (((bbox(3) - bbox(1)) / width_model) + ((bbox(4) - bbox(2))/ height_model)) / 2; - - tx = (bbox(3) + bbox(1))/2; - ty = (bbox(4) + bbox(2))/2; - - % correct it so that the bounding box is just around the minimum - % and maximum point in the initialised face - tx = tx - a*(min(rot_m(1,:)) + max(rot_m(1,:)))/2; - ty = ty - a*(min(rot_m(2,:)) + max(rot_m(2,:)))/2; - - % visualisation of the initial state - %hold off;imshow(Image);hold on;plot(a*rot_m(1,:)+tx, a*rot_m(2,:)+ty,'.r');hold on;rectangle('Position', [bounding_box(1), bounding_box(2), bounding_box(3)-bounding_box(1), bounding_box(4)-bounding_box(2)]); - global_params = [a, 0, 0, 0, tx, ty]'; - global_params(2:4) = views(v,:); - local_params = zeros(size(E)); - [shape2D] = GetShapeOrtho(M, V, local_params, global_params); - shapes_init(:,:,v) = shape2D(:,1:2); - error_init(v) = compute_error(squeeze(labels(i,:,:)), shapes_init(:,:,v)); - end - - [~,ind] = min(error_init); - views_used(i) = ind; - shapes_init_all(:,:,i) = shapes_init(:,:,ind); - errors_init_all(i) = error_init(ind); -end -[~,~,errs_pp] = compute_error(labels_all, shapes_init_all); -views_used(errors_init_all > 0.5) = -1; - -%% -load('results/results_wild_clnf_general_hierarch.mat'); -[~,~,errs_pp] = compute_error(labels_all, experiments.shapes); -% for v=1:size(views,1) -% % Want to scatter them around mean of each landmark -% figure; -% set(gca,'YDir','reverse'); -% rot = Euler2Rot(views(v,:)); -% rot_m = rot * reshape(M, num_points, 3)'; -% -% plot(rot_m(1,:), +rot_m(2,:), '.r'); -% hold on; -% for p=1:num_points -% errors_x = squeeze(errs_pp(views_used==v,p,1)) * 30; -% errors_y = squeeze(errs_pp(views_used==v,p,2)) * 30; -% % scatter(bsxfun(@plus, rot_m(1,p), errors_x), bsxfun(@plus, -rot_m(2,p), -errors_y)); -% sig = cov(errors_x, errors_y); -% plotcov2([rot_m(1,p) + mean(errors_x); rot_m(2,p) + mean(errors_y)], sig, 'conf', 0.5); -% end -% -% % plot(rot_m(1,:) + errors(:,1)'*65, -rot_m(2,:) - errors(:,2)'*65, '.b'); -% axis equal; -% hold off; -% end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/results/dclm_results.pdf b/matlab_version/experiments_in_the_wild/results/dclm_results.pdf deleted file mode 100644 index b8dfb8ec..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/dclm_results.pdf and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/dclm_results.png b/matlab_version/experiments_in_the_wild/results/dclm_results.png deleted file mode 100644 index 1b8fb42a..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/dclm_results.png and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_clm_general.mat b/matlab_version/experiments_in_the_wild/results/results_wild_clm_general.mat deleted file mode 100644 index 7b4426f6..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_clm_general.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general.mat b/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general.mat deleted file mode 100644 index db9882e5..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_eyes.mat b/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_eyes.mat deleted file mode 100644 index 6804f275..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_clnf_general_eyes.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general.mat deleted file mode 100644 index bfa03be6..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse.mat deleted file mode 100644 index 64778fef..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_h.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_h.mat deleted file mode 100644 index 4c00924e..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_h.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v2.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v2.mat deleted file mode 100644 index 9278e88a..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v2.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v3.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v3.mat deleted file mode 100644 index c24ea65b..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v3.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v4.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v4.mat deleted file mode 100644 index 959479d2..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_general_sparse_v4.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off.mat deleted file mode 100644 index 24780ed9..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_30.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_30.mat deleted file mode 100644 index 97f49754..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_30.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale2.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale2.mat deleted file mode 100644 index 1c846d1a..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale2.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale_0.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale_0.mat deleted file mode 100644 index 182c905e..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_vis_off_scale_0.mat and /dev/null differ diff --git a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_wild.mat b/matlab_version/experiments_in_the_wild/results/results_wild_dclm_wild.mat deleted file mode 100644 index 48723360..00000000 Binary files a/matlab_version/experiments_in_the_wild/results/results_wild_dclm_wild.mat and /dev/null differ