Почему модуль face_recognition не работает?

После выполнения кода столкнулся со следующей проблемой: Please install face_recognition_modelswith this command before usingface_recognition`:

pip install git+https://github.com/ageitgey/face_recognition_models

Process finished with exit code 0`

После прописывания команды в консоль код всё равно отказывается работать. Код выглядит следующим образом:

import cv2
import face_recognition

def face_capture():
    cascade_path = "C:/sputnik/faces.xml"

    clf = cv2.CascadeClassifier(cascade_path)
    camera = cv2.VideoCapture('video (2).mp4')
    image = face_recognition.load_image_file('image.jpeg')
    face_encoding = face_recognition.face_encodings(image)[0]
    known_faces = [
        face_encoding,
    ]


    while True:
        _, frame = camera.read()

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = clf.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            flags=cv2.CASCADE_SCALE_IMAGE
        )
        face_locations = face_recognition.face_locations(frame, model="cnn")
        face_encodings = face_recognition.face_encodings(frame, face_locations)
        face_names = []

        for face_encoding in face_encodings:
            match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=0.50)
            name = None
            if match[0]:
                name = "123"
                face_names.append(name)
        for (top, right, bottom, left), name in zip(face_locations, face_names):
            if not name:
                continue
            cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
            cv2.rectangle(frame, (left, bottom - 25), (right, bottom), (0, 0, 255), cv2.FILLED)
            font = cv2.FONT_HERSHEY_DUPLEX
            cv2.putText(frame, name, (left + 6, bottom - 6), font, 0.5, (255, 255, 255), 1)

        '''
        for (x, y, width, height) in faces:
            cv2.rectangle(frame, (x, y), (x + width, y + height), (255, 255, 0), 2)
        cv2.imshow("Faces", frame)
        '''
        if cv2.waitKey(1) == ord("q"):
            break
    camera.release()
    cv2.destroyAllWindows()

def main():
    face_capture()

if __name__ == "__main__":
    main()

Что делать в такой ситуации?

Пробовал установить модели напрямую в PyCharm, но ничего не получилось. Также искал решения на других сайтах, но ничего стоящего не нашел


Ответы (0 шт):