logo

classifier-get-results

img_path = 'flowers/test/15/image_06360.jpg'

# get the predictions 
results_dict = predict(loaded_net, img_path, flowers_to_name)
for k,v in results_dict.items():
    print('{}:{}'.format(k, v))
    
""" OUTPUT
predicted_idx:[9, 62, 45, 39, 48]
classes:['yellow iris', 'black-eyed susan', 'buttercup', 'daffodil', 'common dandelion']
idx_to_class:['15', '63', '48', '42', '50']
probabilities:[0.9235654473304749, 0.04405064508318901, 0.015102370642125607, 0.010496463626623154, 0.001698569511063397]
"""
    
# get flower names fromr results dict
print(results_dict['idx_to_class'])
names = [flowers_to_name[x] for x in results_dict['idx_to_class']]
print(names)

""" OUTPUT
['15', '63', '48', '42', '50']
['yellow iris', 'black-eyed susan', 'buttercup', 'daffodil', 'common dandelion']
"""

plot_image_results(datasets, 'test', 5)
  • Share