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')
输出:
AttributeError: module 'keras.preprocessing.image' has no attribute 'load_img'
当我尝试运行时,出现了错误。这个错误是什么意思,我该如何修复呢?帮帮我吧 :) 我正在努力学习, 我不知道哪一个是错误的。
from tensorflow.keras.preprocessing import image
,如此处所述 @Almaz Fazulzyanov。 - Elias