subasah

googlenet-use-to-classify-images

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