Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %loading the pre-trained googlenet model for image classification
- net = googlenet;
- %image to be classified must be of inputsize, that is first layer of the %neural network, googlenet
- inputSize = net.Layers(1).InputSize;
- I = imread('dog.jpg');
- I = imresize(I,inputSize(1:2));
- [label,scores] = classify(net,I);
- figure
- imshow(I)
- %last layer gives us the number of classes the googlenet model has
- classNames = net.Layers(end).ClassNames;
- % line below will display the percentage of probability for the image to be in % the same class
- title(string(label) + ", " + num2str(100*scores(classNames == label),3) + "%");
Add Comment
Please, Sign In to add comment