Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
5 views
in Python by (120 points)

I have trained the model and now i am predicting a single image using keras and tensorflow . I have passed the input shape 128 to train the model . I change the tensorflow version to 2.0.1 . Now i am getting error again as shown above . Kindly resolve my this issue 

import cv2
import numpy as np
import tensorflow as tf
from sklearn.metrics import confusion_matrix

Categories = ["Badshahi Masjid", "Minare Pakistan", "ShahiQila(Lahore Fort)"]

sift = cv2.xfeatures2d.SIFT_create()

print(tf.__version__)

def prepare(filepath):
    IMG_SIZE = (124, 124)
    img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
    new_array = cv2.resize(img_array, IMG_SIZE)
    keyImage, desImage = sift.detectAndCompute(new_array, None)
    feat = np.sum(desImage, axis=0)
    print(feat.shape)
    return feat


model = tf.keras.models.load_model("SuperClassPredictions.h5")
prediction = model.predict([np.asarray(prepare('E:\Python Telusko\OpenCv\MinarePakistan1.jpg'))])
print(prediction)
print(Categories[int(prediction[0][0])])
Please log in to answer this question.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...