MATLAB Answers

i am getting error while predicting image??

29 views (last 30 days)
Shivam  Kumar
Shivam Kumar on 29 Oct 2019
Answered: arun anoop m on 17 Jul 2020 at 16:26
img=imread('4.jpg');
>> imshow(img)
>> net=alexnet;
>> predict=classify(net,img)
Error using DAGNetwork/calculatePredict>predictBatch (line 151)
Incorrect input size. The input images must have a size of [227 227 3].
Error in DAGNetwork/calculatePredict (line 17)
Y = predictBatch( ...
Error in DAGNetwork/classify (line 134)
scores = this.calculatePredict( ...
Error in SeriesNetwork/classify (line 502)
[labels, scores] = this.UnderlyingDAGNetwork.classify(X, varargin{:});

  0 Comments

Sign in to comment.

Accepted Answer

Sai Bhargav Avula
Sai Bhargav Avula on 29 Oct 2019
Hi,
The issue might be due input image resolution. alexnet expects an input of size 227*227*3. The image you are passing may not be of the same size. Try resizing the image using imresize function to 227*227*3.
Hope this helps

  0 Comments

Sign in to comment.

More Answers (1)

arun anoop m
arun anoop m on 17 Jul 2020 at 16:26
this helped me to solve errors.
Hope it may help. Nice.

  0 Comments

Sign in to comment.


Translated by