AttributeError Traceback most recent call last Cell In28 line 4 1 #网上随便找的图片侵删 2 img_path = smilepng ---- 4 img = imageload_imgimg_path target_size=64 64 5
This error occurs when you try to use the load_img function from the keras.preprocessing.image module which is not available in your version of Keras.
To resolve this error, you can try upgrading your Keras version or use an alternative method to load the image such as using PIL library or cv2 library.
Here's an example of how to load an image using the PIL library:
from PIL import Image
img_path = 'smile.png'
img = Image.open(img_path)
img = img.resize((64,64))
img.show()
x = np.array(img)
Note: You will need to import the necessary libraries (PIL and numpy) before using the above code.
原文地址: https://www.cveoy.top/t/topic/bkNs 著作权归作者所有。请勿转载和采集!