from cv2 import cv2
import numpy as np
from glob import glob
from PIL import Image

train_path = 'valid/'
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('sample_model.yml')
s, l = 0, 0
for img_path in glob(train_path + '*.png'):
    img = np.array(Image.open(img_path).convert('L'), 'uint8')
    label, confidence = recognizer.predict(img)
    print(label, confidence)
    s += confidence
    l += 1
print('Average:', s / l)

from cv2 import cv2
import numpy as np
from glob import glob
from PIL import Image

train_path = 'valid/'
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('sample_model.yml')
s, l = 0, 0
for img_path in glob(train_path + '*.png'):
    img = np.array(Image.open(img_path).convert('L'), 'uint8')
    label, confidence = recognizer.predict(img)
    print(label, confidence)
    s += confidence
    l += 1
print('Average:', s / l)
