Skip to content

Commit

Permalink
- Script to evaluate students submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorros committed Oct 26, 2016
1 parent 9c1c4ff commit 62d9392
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions compute_results.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
addpath(genpath('.'))

%groups = [1,2,3,4,5,6,7,8];
%groups = [1,5,6,7,8];
groups = [0];
week = 1;
window_evaluation = 1;


out_results_pix = sprintf ('W%d_pixel_results.txt', week);
pixFile = fopen(out_results_pix, 'w');
if window_evaluation == 1,
out_results_win = sprintf ('W%d_window_results.txt', week);
winFile = fopen(out_results_win, 'w');
end

test_dir = '/home/ihcv00/DataSetCorrected/test/';
test_files = ListFiles(test_dir);

for jj=1: length(groups),
results_dir = sprintf('/home/ihcv%02d/m1-results/week%d/test', groups(jj), week );

pixelTP=0; pixelFN=0; pixelFP=0; pixelTN=0;
windowTP=0; windowFN=0; windowFP=0;

methods = dir (results_dir);
for kk=3: length(methods),

result_files = ListFiles([results_dir, '/', methods(kk).name]);
sprintf ('Method %s : %d files found', size(result_files,1);

for ii=1:size(result_files,1),

% Read mask file
candidate_masks_name = fullfile(results_dir, methods(kk).name, result_files(ii).name);
pixelCandidates = imread(candidate_masks_name)>0;

% Accumulate pixel performance of the current image %%%%%%%%%%%%%%%%%
[pathstr,name,ext] = fileparts(test_files(ii).name);
gt_mask_name = fullfile(test_dir, 'mask', ['mask.' name '.png']);

pixelAnnotation = imread(gt_mask_name)>0;
[localPixelTP, localPixelFP, localPixelFN, localPixelTN] = PerformanceAccumulationPixel(pixelCandidates, pixelAnnotation);
pixelTP = pixelTP + localPixelTP;
pixelFP = pixelFP + localPixelFP;
pixelFN = pixelFN + localPixelFN;
pixelTN = pixelTN + localPixelTN;

if window_evaluation == 1,
% Read .mat file
[pathstr_r,name_r, ext_r] = fileparts(result_files(ii).name);
mat_name = fullfile(results_dir, methods(kk).name, [name_r '.mat']);
clear windowCandidates
load(mat_name);

gt_annotations_name = fullfile(test_dir, 'gt', ['gt.' name '.txt']);
windowAnnotations = LoadAnnotations(gt_annotations_name);

[localWindowTP, localWindowFN, localWindowFP] = PerformanceAccumulationWindow(windowCandidates, windowAnnotations);
windowTP = windowTP + localWindowTP;
windowFN = windowFN + localWindowFN;
windowFP = windowFP + localWindowFP;
end
end

% Plot performance evaluation
[pixelPrecision, pixelAccuracy, pixelSpecificity, pixelSensitivity] = PerformanceEvaluationPixel(pixelTP, pixelFP, pixelFN, pixelTN);
pixelF1 = 2*((pixelPrecision*pixelSensitivity)/(pixelPrecision + pixelSensitivity));

fprintf (pixFile, 'Group %02d pixel, method %s : %.2f, %.2f, %.2f\n', groups(jj), methods(kk).name, pixelPrecision, pixelSensitivity, pixelF1);
sprintf ( 'Group %02d pixel, method %s : %.2f, %.2f, %.2f\n', groups(jj), methods(kk).name, pixelPrecision, pixelSensitivity, pixelF1)

if window_evaluation == 1,
[windowPrecision, windowSensitivity, windowAccuracy] = PerformanceEvaluationWindow(windowTP, windowFN, windowFP); % (Needed after Week 3)
windowF1 =0;

fprintf (winFile, 'Group %02d window, method %s : %.2f, %.2f, %.2f\n', groups(jj), methods(kk).name, windowPrecision, windowSensitivity, windowF1);
sprintf ( 'Group %02d window, method %s : %.2f, %.2f, %.2f\n', groups(jj), methods(kk).name, windowPrecision, windowSensitivity, windowF1)
end
end
end
fclose(pixFile);
if window_evaluation == 1,
fclose(winFile);
end

0 comments on commit 62d9392

Please sign in to comment.