Hi , I am making a classifier which basically scans the historical places
and detects them .I am using SIFT for taking features of images and then
passing them to the neural network . Features are 128 dimensional and model
is trained with 97% accuracy but when i am using Single image prediction it
is giving error :
*    ValueError: Input 0 of layer sequential_9 is incompatible with the
layer: expected axis -1 of input shape to have value 128 but received input
with shape [32, 1]*
It's shape is already 128 , but I don't know why it is giving an error .
Kindly help me i got stucked in it for several days
import cv2
import numpy as np
import tensorflow as tf

# import keras
# from keras.models import load_model
# from keras.utils import CustomObjectScope

# print(tf.__version__)
# print(keras.__version__)
Categories = ["Deewane aam", "Lahore Fort Museum", "Moti masjid", "Sheesh 

sift = cv2.xfeatures2d.SIFT_create()

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)
    return feat

# from keras.initializers import glorot_uniform

# with CustomObjectScope({'GlorotUniform': glorot_uniform()}):
model = tf.keras.models.load_model("SubClassPredictions.h5")
prediction = model.predict([prepare('E:\Python Telusko\OpenCv\motimasjid.jpg')])
# print(prediction)
# print(Categories[int(prediction[0][0])])
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
Message archived at 
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to