I'm trying to deploy my flask application by Heroku but I have a problem. In the app, the sent image will be analyzed by OpenCV but error happens.
According to the heroku log, the error is
recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'face'
In local environment, the apllication works. I thought openCV is not installed in Heroku, so I added heroku.yml with below code.
build:
languages:
- python
packages:
- libopencv-dev
run:
web: gunicorn server:app --log-file -
However, the same error still happens... Now, I doubt that import of opencv_contrib_python in Heroku is necessary but I don't know how to do.
I really need somebody's advise... Thanks.
The actual code:
def load_model():
global recognizer
print(" * Loading pre-trained model ...")
cascadePath = './haarcascade_frontalface_alt.xml'
faceCascade = cv2.CascadeClassifier(cascadePath)
recognizer = cv2.face.LBPHFaceRecognizer_create()