Error using imread>get_full_filename (line 566) File "gg(21).jpg" does not exist. Error in imread (line 375) fullname = get_full_filename(filename);
Show older comments
I AM getting error while excution and images are not loading to enter the input
%% BRAIN TUMOR CLASSIFICATION USING CNN BY HOG AND LBP FEATURES
clc
clear all
close all
imds = imageDatastore('C:\Users\new\Testing',...
'IncludeSubfolders',true,...
'LabelSource','foldernames');
[Data,testData]= splitEachLabel(imds,0.8,'randomize');
% Training files
[trainData] =Data;
layers = [
imageInputLayer([200 128 3],'Name','input')%SIZE OF IMAGE 200* 128
convolution2dLayer(5,16,'Padding','same','Name','conv_1') % ZERO PADDING
batchNormalizationLayer('Name','BN_1') % BATCH NORMLIZATION LAYER
reluLayer('Name','relu_1')
convolution2dLayer(3,32,'Padding','same','Stride',2,'Name','conv_2')
batchNormalizationLayer('Name','BN_2')
reluLayer('Name','relu_2')
convolution2dLayer(3,32,'Padding','same','Name','conv_3')
batchNormalizationLayer('Name','BN_3')
reluLayer('Name','relu_3')
convolution2dLayer(3,32,'Padding','same','Name','conv_4');
batchNormalizationLayer('Name','BN_4')
reluLayer('Name','relu_4')
%
additionLayer(5,'Name','add')
averagePooling2dLayer(4,'Stride',3,'Name','avpool')
fullyConnectedLayer(4,'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classOutput')];
% Create a layer graph from the layer array. layerGraph connects all the layers in layers sequentially. Plot the layer graph.
lgraph = layerGraph(layers);
figure
plot(lgraph)
% Create the 1-by-1 convolutional layer and add it to the layer graph. Specify the number of convolutional filters and the stride so that the activation size matches the activation size of the 'relu_3' layer. This arrangement enables the addition layer to add the outputs of the 'skipConv' and 'relu_3' layers.
skipConv = convolution2dLayer(2,32,'Stride',2,'Name','skipConv');
lgraph = addLayers(lgraph,skipConv);
figure
plot(lgraph)
% Create the shortcut connection from the 'relu_1' layer to the 'add' layer. Because you specified two as the number of inputs to the addition layer when you created it, the layer has two inputs named 'in1' and 'in2'. The 'relu_3' layer is already connected to the 'in1' input. Connect the 'relu_1' layer to the 'skipConv' layer and the 'skipConv' layer to the 'in2' input of the 'add' layer. The addition layer now sums the outputs of the 'relu_3' and 'skipConv' layers. To check that the layers are connected correctly, plot the layer graph.
lgraph = connectLayers(lgraph,'relu_1','skipConv');
%lgraph = connectLayers(lgraph,'skipConv','add/in2');
lgraph = connectLayers(lgraph,'relu_2','add/in2');
lgraph = connectLayers(lgraph,'relu_3','add/in3');
lgraph = connectLayers(lgraph,'relu_4','add/in4');
lgraph = connectLayers(lgraph,'skipConv','add/in5');
figure
plot(lgraph);
options = trainingOptions('adam', ...
'MiniBatchSize',128, ...
'MaxEpochs',1, ... %% was 6
'ValidationFrequency',5, ...
'InitialLearnRate',1e-4,'Plots','training-progress');
%% network training
[convnet, traininfo] = trainNetwork(trainData,lgraph,options);
% INPUT IMAGE
inp = input('Enter input :');
I = imread(inp);
figure,imshow(I)
%% LBP FEATURES EXTRACTION
[cameraman_LBP] = LocalBinaryPattern (I);
figure
subplot(121),imshow(I, []), title('INPUT IMAGE')
subplot(122),imshow(cameraman_LBP, []), title('LBP FEATURES')
%% HOG FEATURES EXTRACTION
[featureVector,hogVisualization] = extractHOGFeatures(I);
figure,
imshow(I);title('INPUT IMAGE')
hold on;
plot(hogVisualization);
[hog1, visualization] = extractHOGFeatures(I,'CellSize',[64 64]);
figure,
subplot(1,2,1);
imshow(I),title('INPUT IMAGE');
subplot(1,2,2);
plot(visualization);
imshow(I),title('HOG FEATURES IMAGE');
figure;
hog = hog_feature_vector(I);
%% Done classification
class = classify(convnet,I);
msgbox(char(class))
%%
load HOG.mat;
% Perform Convolution Neural Network
opts.tf = 1;
opts.ho = 0.3;
opts.H = 10;
opts.Maxepochs = 50;
NN = jnn('ffnn',feat,label,opts);
% Accuracy
Accuracy= NN.acc;
% Confusion matrix
Confmat= NN.con;
%% Convolution Neural Network (CNN) with LBP Features
% LBP Features
load LBP.mat;
% Perform Convolution Neural Network
opts.tf = 2;
opts.kfold = 10;
opts.H = [10, 10, 10];
opts.Maxepochs = 50;
NN = jnn('nn',feat,label,opts);
% Accuracy
accuracy = NN.acc;
% Confusion matrix
confmat = NN.con;
msgbox("Testing of brain tumor classification using Convolution Neural Network (HOG vs LBP)successfully completed");
5 Comments
Charan sai kumar
on 24 Feb 2024
Cris LaPierre
on 24 Feb 2024
Edited: Cris LaPierre
on 24 Feb 2024
Is the image in your current folder? Or in a folder on your MATLAB Path?
If not, you need to include the path to the image along with the filename.
Charan sai kumar
on 24 Feb 2024
Edited: Charan sai kumar
on 24 Feb 2024
Cris LaPierre
on 24 Feb 2024
If the folder is already on your path, then double check that the filename is spelled correctly. Is the actual file extension JPG or jpeg?
Are you on a Linux system?
Charan sai kumar
on 25 Feb 2024
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 24 Feb 2024
You can add the path to the directory where your images are located using addpath(), e.g.:
addpath('C:\Users\new\Testing')
8 Comments
Charan sai kumar
on 24 Feb 2024
Edited: Charan sai kumar
on 24 Feb 2024
Sulaymon Eshkabilov
on 24 Feb 2024
Moved: Cris LaPierre
on 24 Feb 2024
addpath() should come at the start of your code:
clc
clear all
close all
addpath('C:\Users\new\Testing')
...
Charan sai kumar
on 25 Feb 2024
Charan sai kumar
on 25 Feb 2024
Charan sai kumar
on 25 Feb 2024
DGM
on 25 Feb 2024
The filename you entered does not have spaces.
Charan sai kumar
on 25 Feb 2024
DGM
on 25 Feb 2024
It's not on any line. It was manually entered via an interactive prompt. This is an example of why using interactive prompts is a great way to collect typos that often leave no lasting evidence when you have to go back and figure out where a bug originated. The only reason I noticed this is because the error message indicates what was entered at the prompt.
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!