import numpy as np
from keras.preprocessing import image
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
path = './test/paper2.png'
img = image.load_img(path, target_size=(150,150))
imgplot = plt.imshow(img)
x = image.img_to_array(img)
img_test = np.expand_dims(x, axis=0)
classes = model.predict(img_test, batch_size=10)
print(classes)
paper, rock, scissors = classes[0]
if paper==1.:
print('paper')
elif rock==1.:
print('rock')
else:
print('scissors')
output :
AttributeError: module 'keras.preprocessing.image' has no attribute 'load_img'
when I try to run. What does the error mean and how can I fix it? help guys :) I'm trying to learn I don't know anymore which one is wrong
CodePudding user response:
there is no 'load_img' https://github.com/keras-team/keras/blob/master/keras/preprocessing/image.py
I suppose you trying to use load_img of keras.utils.image_utils
CodePudding user response:
I'm facing the same problem today.
You can try using tensorflow 2.8.0 to fix it or try tf.keras.utils.load_img
instead of image.load_img
.