def predictLabel(unpredictedImage, model, label, imageFormatIsNP): print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print(type(unpredictedImage)) # https://stackoverflow.com/questions/22906394/numpy-ndarray-object-has-no-attribute-read if imageFormatIsNP: test_image = Image.fromarray(unpredictedImage).resize(size=(64, 64)) else: test_image = image.load_img(unpredictedImage, target_size=(64, 64)) test_image = image.img_to_array(test_image) test_image = np.expand_dims(test_image, axis=0) result = model.predict(test_image) print(result) classIndex = np.argmax(result) print("^&^&^&^&^&^^^^^^^^^^^^^^^^^&^&^&^&^&^&^&^&^&^&^&^&^&^&^&^&^&^&^&") fr = open(label) dic = eval(fr.read()) fr.close() for key in dic: if dic[key] == classIndex: return key return "null"