|
a |
|
b/functions/computeClassPerformanceFineTuneCNN.m |
|
|
1 |
function [errorStruct] = computeClassPerformanceFineTuneCNN(imagesCell, Labels, folder, inputSize, netTransfer, fidLogs) |
|
|
2 |
|
|
|
3 |
% imdsTest = imageDatastore(folder, 'IncludeSubfolders', true, 'LabelSource', 'foldernames'); |
|
|
4 |
|
|
|
5 |
im_temp = imagesCell{1}; |
|
|
6 |
imsizeOrig = size(im_temp); |
|
|
7 |
imArray = zeros(imsizeOrig(1), imsizeOrig(2), imsizeOrig(3), numel(imagesCell)); |
|
|
8 |
for ind_im = 1 : numel(imagesCell) |
|
|
9 |
imArray(:,:,:,ind_im) = imagesCell{ind_im}; |
|
|
10 |
end %for ind_im |
|
|
11 |
|
|
|
12 |
% imdsTestAugm = augmentedImageDatastore(inputSize(1:2), imdsTest); |
|
|
13 |
imdsTestAugm = augmentedImageDatastore(inputSize(1:2), imArray, categorical(Labels)'); |
|
|
14 |
|
|
|
15 |
tic |
|
|
16 |
%[TestOutput, scores] = classify(netTransfer, imArrayTest); |
|
|
17 |
[TestOutput, scores] = classify(netTransfer, imdsTestAugm, 'MiniBatchSize', 10); |
|
|
18 |
|
|
|
19 |
% scores |
|
|
20 |
% TestOutput |
|
|
21 |
% double(imdsTest.Labels) |
|
|
22 |
% oneHotLabels = onehot(double(imdsTest.Labels)); |
|
|
23 |
% correlationProc = computeCorrelation(scores, oneHotLabels) |
|
|
24 |
|
|
|
25 |
%cast |
|
|
26 |
%TestOutput = double(TestOutput)-1; |
|
|
27 |
timeClass = toc; |
|
|
28 |
fprintf_pers(fidLogs, ['\t\tTime for classification: ' num2str(timeClass) ' s\n']); |
|
|
29 |
%Confusion matrix |
|
|
30 |
%C_knn = confusionmat(TestLabels, TestOutput); |
|
|
31 |
C_knn = confusionmat(categorical(Labels), TestOutput); |
|
|
32 |
|
|
|
33 |
%Error metrics |
|
|
34 |
errorStruct = computeErrorsFromCM(C_knn); |
|
|
35 |
|