Hello All, I’m trying to run my model but facing "‘Sequential’ object has no attribute ‘predict_classes’ " My code was before it was deprecated? Help me to resolve it or help with alternatives to this code i provided. Thanks

Predicting the output

def fix_dimension(img):
new_img = np.zeros((28,28,3))
for i in range(3):
new_img[:,:,i] = img
return new_img

def show_results():
dic = {}
for i,c in enumerate(characters):
dic[i] = c

output = []
for i,ch in enumerate(char): #iterating over the characters
    img_ = cv2.resize(ch, (28,28), interpolation=cv2.INTER_AREA)
    img = fix_dimension(img_)
    img = img.reshape(1,28,28,3) #preparing image for the model
    y_ = model.predict_classes(img)[0] #predicting the class
    character = dic[y_] #
    output.append(character) #storing the result in a list
plate_number = ''.join(output)

return plate_number


Hi @dei_hunter

Welcome to the TensorFlow Forum!

This error is because you are using the older APIs with latest TensorFlow version which is not compatible. predict_classes() method was used in older Tensorflow version <=2.5 and is deprecated to use in the latest tensorflow version. However, This api method has replaced with predict() to use in the latest tensorflow version.

Please use predict() as below in your code:

y_ = model.predict(img)[0]