I am working on face recognition project , in which I train the model. prediction I load images and want to calculate distanse betwwen 2 images. while predection i am getting below error:
TypeError Traceback (most recent call last)
<ipython-input-21-0b1f36824e17> in <module>()
8 if(cropped_img == type(None)):
9 cropped_img = np.zeros(shape = (224, 224))
---> 10 img = (load_image(cropped_img) / 255.).astype(np.float32)
11 img = cv2.resize(img, dsize = (224,224))
12 embedding_vector = vgg_face_descriptor.predict(np.expand_dims(img, axis=0))[0]
<ipython-input-9-6d96fb74d85b> in load_image(path)
4 # OpenCV loads images with color channels
5 # in BGR order. So we need to reverse them
----> 6 return img[...,::-1]
TypeError: 'NoneType' object is not subscriptable
code is below
NoneType = type(None)
embedding =[]
for i, m in enumerate(metadata):
cropped_img = m.image_path()
print(i)
if(cropped_img == type(None)):
cropped_img = np.zeros(shape = (224, 224))
img = (load_image(cropped_img) / 255.).astype(np.float32)
img = cv2.resize(img, dsize = (224,224))
embedding_vector = vgg_face_descriptor.predict(np.expand_dims(img, axis=0))[0]
embedding.append(embedding_vector)
Load image code is as below:
def load_image(path):
img = cv2.imread(path, 1)
# OpenCV loads images with color channels
# in BGR order. So we need to reverse them
return img[...,::-1]
As I am new to python I can not understand what this error means