deepNetworkDesigner camera = webcam; inputSize = trainedNetwork_1.Layers(1).InputSize(1:2) h = figure; h.Position(3) = 2*h.Position(3); ax1 = subplot(1,2,1); ax2 = subplot(1,2,2); im = snapshot(camera); image(ax1, im) im = imresize(im,inputSize); [YPred, probs] = classify(trainedNetwork_1, im); imshow(im) label = YPred; title(string(label) + ", " + num2str(100*max(probs),3) + "%"); [~,idx] = sort(probs, 'descend'); idx = idx(5:-1:1); classes = trainedNetwork_1.Layers(end).Classes; classNamesTop = string(classes(idx)); scoreTop = probs(idx); barh(ax2, scoreTop) xlim(ax2,[0 1]) title(ax2, 'Top 5') xlabel(ax2, 'Probability') yticklabels(ax2,classNamesTop) ax2.YAxisLocation = 'right'; |