%% Classify an Image Using AlexNet
% Read, resize, and classify an image using AlexNet. First, load a pretrained AlexNet model.

net = alexnet;

% Read the image using imread.

I = imread('peppers.png');
figure
imshow(I)

% The pretrained model requires the image size to be the same as the input size of the network. Determine the input size of the network using the InputSize property of the first layer of the network.

sz = net.Layers(1).InputSize

% Resize the image to the input size of the network.

I = imresize(I,sz(1:2));
figure
imshow(I)

% Classify the image using classify.

label = classify(net,I)

% Show the image and classification result together.

figure
imshow(I)
title(label)

%
% Copyright 2018 The MathWorks, Inc.