I am also facing an same issue after installation of these below command in my command prompt.
> pip install opencv-contrib-python
> pip install opencv-contrib-python --user
Facing this below error in jupyter notebook.
Training done ---------------
--------------------------------------------------------------------------- AttributeError Traceback (most recent call
last) ~\AppData\Local\Temp/ipykernel_4424/3540845204.py in
40 labels = np.array(labels)
41
---> 42 face_recognizer = cv.face.LBPHFaceRecognizer_create()
43
44 # Train the Recognizer on the features list and the labels list
AttributeError: module 'cv2' has no attribute 'face'
After i am tried with visual studio code but make sure your running with this below confirmation commands in your command prompt or terminal.
I will suggest you to try in command prompt.
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Admin>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
4.5.5
>>> **recognizer = cv2.face.LBPHFaceRecognizer_create()**
>>> **print(recognizer)**
**<face_LBPHFaceRecognizer 000001F890F3D8D0>**
>>>
After successfully fixed this issue, i have got these below outputs.
on.exe' 'c:\Users\Admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher'
'55275' '--' 'c:\Users\Admin\Downloads\Opencv\Faces\face.py'
> Training done ---------------
PS C:\Users\Admin\Downloads\Opencv\Faces> c:; cd 'c:\Users\Admin\Downloads\Opencv\Faces'; & 'C:\Program
Files\Python310\pyth0' '--'
'c:\Users\Admin\Downloads\Opencv\Faces\face_recognization1.py'
> Label = Elton John with a confidence of 0.0
> Label = Elton John with a confidence of 0.0
on.exe'
'c:\Users\Admin\.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher'
'55339' '--'
'c:\Users\Admin\Downloads\Opencv\Faces\face_recognization1.py'
> Label = nidhi agarwal with a confidence of 0.0