- The value 23 indicates that all the 23 images having label nonpothole(out of 43 total images) are classified correctly as as nonpothole
- The value 1 indicates that one image whose actual label is pothole is incorrectly classified as nonpothole
- The value 0 indicates that there are no images of label pothole which are classified incorrectly as nonpothole
- The value 29 indicates that 29 images out of 30 images having label pothole(out of 43 total images) are classified correctly as pothole
image agumentation_CNN
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Srinidhi Gorityala
el 16 de Abr. de 2020
Respondida: Srivardhan Gadila
el 23 de Abr. de 2020
Helo..... Iam working on a dataset of both pothole and non-pothole images which means two classes. I have worked on the below code for classification of the classes using image augmentation. I have got two confusion matrics has output. could any plz help me in understanding this.
clc;
clear all;
close all;
myTrainingFolder = 'C:\Users\Admin\Desktop\Major Project\CNN_dataset2';
%testingFolder = 'C:\Users\Be Happy\Documents\MATLAB\gtsrbtest';
imds = imageDatastore(myTrainingFolder,'IncludeSubfolders', true, 'LabelSource', 'foldernames');
%testingSet = imageDatastore(testingFolder,'IncludeSubfolders', true, 'LabelSource', 'foldernames');
labelCount = countEachLabel(imds);
numClasses = height(labelCount);
numImagesTraining = numel(imds.Files);
%% Create training and validation sets
[imdsTrainingSet, imdsValidationSet] = splitEachLabel(imds, 0.7, 'randomize');
%% Build a simple CNN
imageSize = [227 227 3];
% Specify the convolutional neural network architecture.
layers = [
imageInputLayer(imageSize)
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
%% Specify training options
options = trainingOptions('sgdm', ...
'MiniBatchSize',10, ...
'MaxEpochs',6, ...
'InitialLearnRate',1e-4, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidationSet, ...
'ValidationFrequency',3, ...
'Verbose',false, ...
'Plots','training-progress');
%% Train the network
net1 = trainNetwork(imdsTrainingSet,layers,options);
%% Report accuracy of baseline classifier on validation set
YPred = classify(net1,imdsValidationSet);
YValidation = imdsValidationSet.Labels;
imdsAccuracy = sum(YPred == YValidation)/numel(YValidation);
%% Plot confusion matrix
figure, plotconfusion(YValidation,YPred)
%% PART 2: Baseline Classifier with Data Augmentation
%% Create augmented image data store
% Specify data augmentation options and values/ranges
imageAugmenter = imageDataAugmenter( ...
'RandRotation',[-20,20], ...
'RandXTranslation',[-5 5], ...
'RandYTranslation',[-5 5]);
% Apply transformations (using randomly picked values) and build augmented
% data store
augImds = augmentedImageDatastore(imageSize,imdsTrainingSet, ...
'DataAugmentation',imageAugmenter);
% (OPTIONAL) Preview augmentation results
batchedData = preview(augImds);
figure, imshow(imtile(batchedData.input))
%% Train the network.
net2 = trainNetwork(augImds,layers,options);
%% Report accuracy of baseline classifier with image data augmentation
YPred = classify(net2,imdsValidationSet);
YValidation = imdsValidationSet.Labels;
augImdsAccuracy = sum(YPred == YValidation)/numel(YValidation);
%% Plot confusion matrix
figure, plotconfusion(YValidation,YPred);
0 comentarios
Respuesta aceptada
Srivardhan Gadila
el 23 de Abr. de 2020
The rows correspond to the predicted class (Output Class) and the columns correspond to the true class (Target Class). The diagonal cells correspond to observations that are correctly classified. The off-diagonal cells correspond to incorrectly classified observations. Both the number of observations and the percentage of the total number of observations are shown in each cell.
In case of the first Confusion matrix:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Recognition, Object Detection, and Semantic Segmentation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!