diff --git a/matlab_version/experiments_menpo/Script_CECLM_cross_data.m b/matlab_version/experiments_menpo/Script_CECLM_cross_data.m index f4bd57d3..b846eeda 100644 --- a/matlab_version/experiments_menpo/Script_CECLM_cross_data.m +++ b/matlab_version/experiments_menpo/Script_CECLM_cross_data.m @@ -2,11 +2,13 @@ function Script_CECLM_cross_data() addpath(genpath('../')); -[images, detections, labels] = Collect_menpo_imgs('D:\Datasets\menpo/'); +[images, detections, labels] = Collect_menpo_imgs('G:\Datasets\menpo/'); %% loading the CE-CLM model and parameters [patches, pdm, clmParams, early_term_params] = Load_CECLM_general(); - +views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; +views = views * pi/180; + % As early termination weights were trained on part of menpo turn them off, % to perform a clean cross-data experiment early_term_params.weights_scale(:) = 1; @@ -53,18 +55,9 @@ for i=1:numel(images) bbox = squeeze(detections(i,:)); - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; - 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 + % The actual work get's done here + [shape,~,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); all_lmark_lhoods(:,i) = lmark_lhood; all_views_used(i) = view_used; diff --git a/matlab_version/experiments_menpo/Script_CECLM_menpo_test_frontal.m b/matlab_version/experiments_menpo/Script_CECLM_menpo_test_frontal.m index 6dab83a5..f1f6f6c5 100644 --- a/matlab_version/experiments_menpo/Script_CECLM_menpo_test_frontal.m +++ b/matlab_version/experiments_menpo/Script_CECLM_menpo_test_frontal.m @@ -3,14 +3,12 @@ function Script_CECLM_menpo_test_frontal() addpath(genpath('../')); addpath(genpath('./menpo_challenge_helpers')); -[images, detections] = Collect_menpo_test_frontal('D:\Datasets\menpo\testset\semifrontal/'); +[images, detections] = Collect_menpo_test_frontal('G:\Datasets\menpo\testset\semifrontal/'); %% 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; +views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; +views = views * pi/180; %% Setup recording experiment.params = clmParams; @@ -53,19 +51,8 @@ for i=1:numel(images) bbox = squeeze(detections(i,:)); - % have a multi-view version - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; - 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 + [shape,~,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); shape = shape + 0.5; [~, name_org, ~] = fileparts(images(i).img); diff --git a/matlab_version/experiments_menpo/Script_CECLM_menpo_test_profile.m b/matlab_version/experiments_menpo/Script_CECLM_menpo_test_profile.m index ce5a7b2a..94817319 100644 --- a/matlab_version/experiments_menpo/Script_CECLM_menpo_test_profile.m +++ b/matlab_version/experiments_menpo/Script_CECLM_menpo_test_profile.m @@ -3,14 +3,12 @@ function Script_CECLM_menpo_test_profile() addpath(genpath('../')); addpath(genpath('./menpo_challenge_helpers')); -[images, detections] = Collect_menpo_test_profile('D:\Datasets\menpo\testset\profile/'); +[images, detections] = Collect_menpo_test_profile('G:\Datasets\menpo\testset\profile/'); %% 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; +views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; +views = views * pi/180; %% Setup recording experiment.params = clmParams; @@ -41,7 +39,7 @@ if(~exist(out_pts, 'dir')) mkdir(out_pts); end -load('../pdm_generation/menpo_pdm/menpo_chin/conversion.mat'); +load('menpo_challenge_helpers/conversion.mat'); %% for i=1:numel(images) @@ -55,19 +53,8 @@ for i=1:numel(images) bbox = squeeze(detections(i,:)); - % have a multi-view version - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; - views = views * pi/180; - - [shape,g_params,~,lhood,lmark_lhood,view_used] =... - Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); - - else - [shape,g_params,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end + [shape,g_params,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); shape = shape + 0.5; diff --git a/matlab_version/experiments_menpo/Script_CECLM_menpo_valid.m b/matlab_version/experiments_menpo/Script_CECLM_menpo_valid.m index 41bdca4c..a021dc19 100644 --- a/matlab_version/experiments_menpo/Script_CECLM_menpo_valid.m +++ b/matlab_version/experiments_menpo/Script_CECLM_menpo_valid.m @@ -2,14 +2,12 @@ function Script_CECLM_menpo_valid() addpath(genpath('../')); -[images, detections, labels] = Collect_valid_imgs('D:\Datasets\menpo/'); +[images, detections, labels] = Collect_valid_imgs('G:\Datasets\menpo/'); %% 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; +views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; +views = views * pi/180; %% Setup recording experiment.params = clmParams; @@ -47,18 +45,8 @@ for i=1:numel(images) bbox = squeeze(detections(i,:)); - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; - 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 + [shape,~,~,lhood,lmark_lhood,view_used] =... + Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views, early_term_params); all_lmark_lhoods(:,i) = lmark_lhood; all_views_used(i) = view_used; diff --git a/matlab_version/experiments_menpo/Script_CLNF_cross_data_general.m b/matlab_version/experiments_menpo/Script_CLNF_cross_data_general.m index ad4d2251..e1896039 100644 --- a/matlab_version/experiments_menpo/Script_CLNF_cross_data_general.m +++ b/matlab_version/experiments_menpo/Script_CLNF_cross_data_general.m @@ -3,51 +3,24 @@ function Script_CLNF_cross_data_general() addpath(genpath('../')); % Replace this with the location of the Menpo dataset -[images, detections, labels] = Collect_menpo_imgs('D:\Datasets\menpo/'); +[images, detections, labels] = Collect_menpo_imgs('G:\Datasets\menpo/'); %% loading the patch experts -clmParams = struct; +[ patches, pdm, clmParams ] = Load_CLNF_general(); +views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; +views = views * pi/180; -clmParams.window_size = [25,25; 23,23; 21,21; 21,21]; -clmParams.numPatchIters = size(clmParams.window_size,1); +[ patches_51, pdm_51, clmParams_51, inds_full, inds_inner ] = Load_CLNF_inner(); -[patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); - -%% 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); - -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; - -% Loading the final scale -[clmParams_inner, pdm_inner] = Load_CLM_params_inner(); -clmParams_inner.window_size = [17,17;19,19;21,21;23,23]; -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; +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); % for recording purposes experiment.params = clmParams; -num_points = numel(M)/3; +num_points = numel(pdm.M)/3; shapes_all = cell(numel(images), 1); labels_all = cell(numel(images), 1); @@ -55,9 +28,6 @@ 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; % set to true to visualise the fitting tic @@ -72,55 +42,10 @@ for i=1:numel(images) bbox = detections(i,:); - % have a multi-view version - if(multi_view) - - views = [0,0,0; 0,-30,0; 0,30,0; 0,-55,0; 0,55,0; 0,0,30; 0,0,-30; 0,-90,0; 0,90,0; 0,-70,40; 0,70,-40]; - 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(size(views,1),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_ind); - - else - [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); - end - - % Perform inner face fitting - shape_inner = shape(inds_inner,:); - - [ a, R, T, ~, l_params, err] = fit_PDM_ortho_proj_to_2D_no_reg(pdm_inner.M, pdm_inner.E, pdm_inner.V, shape_inner); - if(a > 0.9) - g_param = [a; Rot2Euler(R)'; T]; - - 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_2, pdm_inner, patches_inner, clmParams_inner, 'gparam', g_param, 'lparam', l_params); - - % Now after detections incorporate the eyes back - % into the face model - - shape(inds_inner, :) = shape_inner; - - [ ~, ~, ~, ~, ~, ~, shape_fit] = fit_PDM_ortho_proj_to_2D_no_reg(pdm.M, pdm.E, pdm.V, shape); - - all_lmark_lhoods(:,i) = lmark_lhood; - all_views_used(i) = view_used; - - shape = shape_fit; - end + [shape,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb_multi_hyp(image, [], bbox, pdm, patches, clmParams, views); + + % Perform inner landmark fitting now + [shape, shape_inner] = Fitting_from_bb_hierarch(image, pdm, pdm_51, patches_51, clmParams_51, shape, inds_full, inds_inner); all_lmark_lhoods(:,i) = lmark_lhood; all_views_used(i) = view_used;