I have added following libraries and half part of the code is executing. In second half I get this error.
Libraries added:
JavaScript
x
6
1
#importing libraries
2
import keras
3
import tensorflow as tf
4
from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input
5
from tensorflow.keras.utils import img_to_array
6
Error: AttributeError: module ‘keras.preprocessing.image’ has no attribute ‘img_to_array’
I was following this code and changes the libraries too still can’t resolve the issue. https://www.analyticsvidhya.com/blog/2021/06/k-means-clustering-and-transfer-learning-for-image-classification/
Advertisement
Answer
It has now moved to tf.keras.utils.img_to_array
. See the docs