I'm' trying to build a face recognition project with python. But I've found a problem, I can't instantiate the recognizer because when I try execute this line:
recognizer = cv2.face.LBHFaceRecognizer_create()
I got this error:
AttributeError: module 'cv2.cv2' has no attribute 'face'
So I've searched for a solution in the web, much of them, suggested to execute this command on terminal:
pip install opencv-contrib-python
it doesn't solve the problem, I've tried to reinstall to but the problem remains. I've seek information about the documentation but it looks that there's a miss of information about how to create an recognizer in the web.Do Someone know how to solve the problem?
It works for me with a slight modification:
recognizer = cv2.face.LBPHFaceRecognizer_create()
I added a P after LB.
I have a working example here
If someone knows how to solve the problem this post shows exactly the solution for this problems step by step, it's only follow the first answer:
No module named 'cv2.cv2'
Related
I am new in PIC design and I want to make a simple GDSII design following this script:
https://github.com/BYUCamachoLab/simphony/blob/master/examples/layout_aware.py
which uses gdsfactory and simphony libraries but I consistently encounter this error when I am building a cell:
AttributeError: 'gdstk.Cell' object has no attribute 'get_polygons'
This problem appears when I try to call the grating coupler or the waveguides as a component. On the other hand, the Ybranch (splitters) work just fine.
I have downloaded all the latest versions of gdstk, gdsfactory and simphony but cannot make it work.
Do you know how to overcome this issue? What am I missing?
Thanks!
Solved. In case anybody finds in the same situation, the problem was with the gdstk library. For whatever reason, the version installed could not be changed and it remained always in 7.0.
By reinstalling Anaconda, the gdstk latest version could be installed without issues, and from there the program worked.
I just started with Python. I had watched a video on youtube about googletrans library, when I tried it on my VS Code, I had this issue. Can anyone help me?
P/s: This is the link to the video that I have watched: https://www.youtube.com/watch?v=IBqLWm47mjM
Thanks all.
[enter image description here][1]
[1]: https://i.stack.imgur.com/JQjVC.png
This issue has related to the package release, it is not related to you or your system, you can use this specific version to preventing from the issue: 4.0.0rc1
pip install googletrans==4.0.0rc1
Also, you can find more solutions here:
googletrans stopped working with error 'NoneType' object has no attribute 'group'
I've been going round in circles for ages trying to figure this out. Why am I getting this attribute error? I've tried using absolute references, and get the same issue. PyCharm is also highlighting CascadeClassifier, cvtColor and COLOR_BGR2GRAY saying it cannot find reference in cv2.py. I'm not sure if more information is relevant to solving this problem, so please ask if more is needed.
import cv2
face_cascade = cv2.CascadeClassifier('read_only/haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('read_only/haarcascade_eye.xml')
grayed_images = []
for x in np_images:
gray_img = cv2.cvtColor(x, cv2.COLOR_BGR2GRAY)
grayed_images.append(gray_img)
print(x)
If I am correct, you are using an environment different from where you run.
Step1: In command line/terminal where you see the opencv-python when you run pip list:
run python command. Copy your code, check if it works (you can simply import cv2 alternatively)
If it works, my idea should be correct. Otherwise, there is something bigger.
Step 2: (Assuming step1 works.) In Pycharm, Under Run > Edit Configurations, change python interpreter to whichever interpreter is you are that has opencv.
Step2 better alternative: On Pycharm, open the terminal, pip install opencv-python. After that you should have the opencv.
Downgrade opencv to the version 4.5.5.64.
You can install opencv using
pip install opencv-python==4.5.5.64.
This works for me
I am trying to use LBPHfacerecognizer in my python3.6 code.
recognizer = cv2.face.createLBPHFaceRecognizer()
I am aware that face module is in opencv_contrib module. I even uninstalled openCV and installed again with contrib module. I compiled OpenCV with it and python still gives an error which is:
AttributeError: module 'cv2.cv2' has no attribute 'face'
Although in opencv/build/lib I have libopencv_face.dylib, it doesn't compile with python3 and opencv.
I tried everything I can think of but I am running out of ideas.
Any ideas?
edit: Python doesn't give an error when I am working under python3 environment anymore but I still have the same error when I try to run my code in the terminal.
What I am trying to run:
python3 main.py
Any ideas why I have this problem or how I can fix it?
Firstly, the first mistake of mine was after making cmake for few times, I didn't delete old cv2.so file and replace it with new cv2.so.
And it turned out that for working opencv_contrib face module, I have to put this new cv2.so file in the same file that my main.py exists. I don't know if this is the way how should be in the first place. I totally find out this coincidently by myself.
After this, my code worked without any error.
recognizer = cv2.createLBPHFaceRecognizer();
This makes error for me
I tried out, just view the image here.
Try out the code below, it may give you result.
recognizer = cv2.face.LBPHFaceRecognizer_create();
Recently I've been trying out machine learning with tensorflow. This tutorial, has me stuck because I keep getting the error: AttributeError: module 'midi' has no attribute 'Pattern' Does anyone know how to fix this error? I've tried installing py-midi (pip), python-midi (github), and the midi module (pip). However, the midi module never installed properly ("Could not find a version that satisfies the requirement midi"). I'm using python 3.5
My code:
import midi
pattern = midi.Pattern()
track = midi.Track()
pattern.append(track)
-Thanks in advance!
Fixed this error by installing the module directly from git: pip install git+https://github.com/vishnubob/python-midi#feature/python3 Found this command on this github page.