# How to find the filename associated with a prediction in Keras?

My question is really simple, how to find the filename associated with a prediction in Keras? That is, if I have a set of 100 test samples named and I get a numpy array which contains the estimated class probabilities, how do I map the filenames to the probabilities?

import cv2
import os
import glob

X_test = []
y_test = []
os.chdir(testing_path)
file_list = glob.glob('*.png')
for test_image in file_list:
X_test.append(img)
y_test.append(1)
return X_test,y_test

if __name__ == '__main__':
X_test = np.array(X_test, dtype = np.uint8)
X_test = X_test.reshape(X_test.shape[0],3,100,100)
X_test = X_test.astype('float32')
X_test /= 255

• I guess these are image files loaded by some utility? Could you clarify how you are loading the data to be tested? Edit the question and show just the code you have written to load and test the images. Dec 7 '16 at 18:12
• Is the prediction in the same order as the the output of glob? Dec 8 '16 at 17:27
• @Raghuram Yes it is. Dec 8 '16 at 18:57