function Script_CLNF_wild() addpath(genpath('../')); % Replace this with the location of in 300 faces in the wild data if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; else root_test_data = 'D:/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;21,21]; clmParams.numPatchIters = size(clmParams.window_size,1); [patches] = Load_Patch_Experts( '../models/wild/', 'ccnf_patches_*_wild.mat', [], [], clmParams); % 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; % for recording purposes experiment.params = clmParams; %% Change if you want to visualize the outputs verbose = false; output_img = false; if(output_img) output_root = './clnf_out_wild/'; if(~exist(output_root, 'dir')) mkdir(output_root); end end if(verbose) f = figure; end %% For recording 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); % Use the multi-hypothesis model, as bounding box tells nothing about % orientation multi_view = true; %% Fitting the model to the provided image tic for i=1:numel(images) image = imread(images(i).img); image_orig = image; if(size(image,3) == 3) image = rgb2gray(image); end bbox = detections(i,:); % 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; shapes = zeros(num_points, 2, size(views,1)); ls = zeros(size(views,1),1); % Find the best orientation for v = 1:size(views,1) [shapes(:,:,v),~,~,ls(v)] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams, 'orientation', views(v,:)); end [lhood, v_ind] = max(ls); shape = shapes(:,:,v_ind); else [shape,~,~,lhood] = Fitting_from_bb(image, [], bbox, pdm, patches, clmParams); end shapes_all(:,:,i) = shape; labels_all(:,:,i) = labels(i,:,:); if(mod(i, 200)==0) fprintf('%d done\n', i ); end lhoods(i) = lhood; if(output_img) v_points = sum(squeeze(labels(i,:,:)),2) > 0; DrawFaceOnImg(image_orig, shape, sprintf('%s/%s%d.jpg', output_root, 'fit', i), bbox, v_points); end if(verbose) v_points = sum(squeeze(labels(i,:,:)),2) > 0; DrawFaceOnFig(image_orig, shape, bbox, v_points); end end toc experiment.errors_normed = compute_error(labels_all, shapes_all + 1.0); experiment.lhoods = lhoods; experiment.shapes = shapes_all; experiment.labels = labels_all; fprintf('Done: mean normed error %.3f median normed error %.4f\n', ... mean(experiment.errors_normed), median(experiment.errors_normed)); %% output_results = 'results/results_clnf_wild.mat'; save(output_results, 'experiment'); end