Error using imread>get_full_filename (line 566) File "gg(21).jpg" does not exist. Error in imread (line 375) fullname = get_full_f​ilename(fi​lename);

3 vues (au cours des 30 derniers jours)
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 commentaires
Cris LaPierre
Cris LaPierre le 24 Fév 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
Charan sai kumar le 25 Fév 2024
no i not an linux system and images are of JPG format

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Fév 2024
imds = imageDatastore('C:\Users\new\Testing',...
'IncludeSubfolders',true,...
'LabelSource','foldernames');
The data store includes subfolders
inp = input('Enter input :');
I = imread(inp);
What is being entered is a plain file name, relative to the current directory . It is not going to be looked for under C:\Users\new\Testing -- and if it were to be looked for there, there would be the problem that files by the same name might exist in any of several different subdirectories of C:\Users\new\Testing
The user needs to enter a filename that exists in the current directory, or the user needs to enter a fully-qualified filename.
Alternately, it is possible to search the imds for the file... though there is the risk that the file appears multiple times.
  5 commentaires
Walter Roberson
Walter Roberson le 25 Fév 2024
Replace
inp = input('Enter input :');
with
[filename, pathname] = uigetfile('*.*', 'Select a file');
if isnumeric(filename)
error('User canceled file selection');
end
inp = fullfile(pathname, filename);
Charan sai kumar
Charan sai kumar le 25 Fév 2024
Sir, Thnak you so much i got it correct these time
love u alot

Connectez-vous pour commenter.

Plus de réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 24 Fév 2024
You can add the path to the directory where your images are located using addpath(), e.g.:
addpath('C:\Users\new\Testing')
  8 commentaires
Charan sai kumar
Charan sai kumar le 25 Fév 2024
can u tell me at which line i dont have spaces so i can gt more clarity
testing is my folder and i have images in them and they i dont have any spaces if their i have to change tell me how to do.
if it is in the code pl mention me the line so i can be easy to understand for me
DGM
DGM le 25 Fév 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by