I am trying to load a face-recogniser model I trained in the pythonanywhere.com flask server.
import cv2
import numpy as np
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('model.yml')
....
However, I encountered the following error.
cv2.error: OpenCV(3.4.2) /io/opencv_contrib/modules/face/src/facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'read'
**NO MATCH**
Did not encounter this problem locally. And from what I read in other forum posts, their error was because of indicating the wrong path. However, my yml model is placed in the same directory as this python file, so that does not seem to be the problem.
Help, anyone? Thanks.
Try using an absolute path instead of a relative one.
'/home/username/something/model.yml'
instead of 'model.yml'
If you don't want to hardcode the path, use os.path
to build it.