How to fix Sequential AttributeError: 'Sequential' object has no attribute 'predict_classes'

Viewed 35
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 = {}
    characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    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
print(show_results())

AttributeError: 
Traceback (most recent call last) c:\Users\Venugopala K S\Desktop\New folder\Untitled-1.ipynb Cell 21 in <cell line: 26>() 22 plate_number = ''.join(output) 24 return plate_number ---> 26 print(show_results()) c:\Users\Venugopala K S\Desktop\New folder\Untitled-1.ipynb Cell 21 in show_results() 16 img = fix_dimension(img_) 17 img = img.reshape(1,28,28,3) #preparing image for the model ---> 18 y_ = model.predict_classes(img)[0] #predicting the class 19 character = dic[y_] 20 output.append(character) #storing the result in a list 

AttributeError: 'Sequential' object has no attribute 'predict_classes'
0 Answers
Related