필터 지우기
필터 지우기

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);

조회 수: 4 (최근 30일)
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
Cris LaPierre
Cris LaPierre 2024년 2월 24일
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?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2024년 2월 24일
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
Walter Roberson
Walter Roberson 2024년 2월 25일
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);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 2월 24일
You can add the path to the directory where your images are located using addpath(), e.g.:
addpath('C:\Users\new\Testing')
  댓글 수: 8
Charan sai kumar
Charan sai kumar 2024년 2월 25일
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 2024년 2월 25일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by