I had a similar problem to the one given in the following link:
I have been able to successfully run my code and also got the probabilities for each class.My concern is what will be the order of the output probabilities?Meaning how will we know which probability belongs to which class since we are assigning or mapping them manually.any assistance would be really appreciated!
Code:
class_list=style_info['articleType'].unique()
base_model = ResNet50(weights='imagenet',include_top=False,input_shape=(80, 60, 3))
img=glob.glob('images\\'+str(style_info.iloc[55,0])+'.jpg')
# add a global spatial average pooling layer
x = base_model.output
x = GlobalAveragePooling2D()(x)
# add a fully-connected layer
x = Dense(1024, activation='relu')(x)
# and a logistic layer -- let's say we have 7 classes
predictions = Dense(no_of_classes, activation='softmax')(x)
res_model = Model(inputs=base_model.input, outputs=predictions)
image1 = image.load_img(img[0], target_size=(80,60))
x = image.img_to_array(image1)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = res_model.predict(x)
# decode the results into a list of tuples (class, description, probability)
# (one such list for each sample in the batch)
#print('Predicted:', decode_predictions(preds, top=5)[0])
# Predicted: [(u'n02504013', u'Indian_elephant', 0.82658225), (u'n01871265', u'tusker', 0.1122357), (u'n02504458', u'African_elephant', 0.061040461)]
class_list[np.argmax(preds[0])]