AttributeError:'NoneType'对象没有属性'predict'

时间:2019-11-20 18:17:51

标签: python opencv face-recognition training-data

#creating recognizer
recognizer= cv2.face_LBPHFaceRecognizer()
....
#predicting sad images
image_paths = [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.sad')]
for image_path in image_paths:
    predict_image_pil = Image.open(image_path).convert('L')
    predict_image = np.array(predict_image_pil, 'uint8')
    faces = faceCascade.detectMultiScale(predict_image)
    for (x, y, w, h) in faces:
        nbr_predicted, conf = recognizer.predict(predict_image[y: y + h, x: x + w])
....

发现错误

  

nbr_predicted,conf = identifierr.predict(predict_image [y:y + h,x:x + w])   AttributeError:“ NoneType”对象没有属性“ predict”

由于face_PredictCollector()也不起作用,如何解决此错误

0 个答案:

没有答案