This code uses outdated methods to recognize faces. There are far better ways today that use newer methods such as neural networks. My facerec-service repo uses this method and also conveniently wraps it in a Flask API. Use that instead.
Face Recognition in Python using OpenCV