Python Forum

Full Version: pycharm face recognition
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am very new to pycharm and face_recognition, and I am trying to play with them a little.
First of all, here's my code and error:

import face_recognition
face_recognition


bill_gates_pic = face_recognition.load_image_file('./Desktop/pics_python/bill gates.jpg')
bill_gates_face_location = face_recognition.face_locations(bill_gates_pic)

print(bill_gates_face_location)
Error:
C:\Users\PycharmProjects\faces\venv\Scripts\python.exe C:/Users/PycharmProjects/faces/face.py Traceback (most recent call last): File "C:/Users/PycharmProjects/faces/face.py", line 5, in <module> bill_gates_pic = face_recognition.load_image_file('./Desktop/pics_python/bill gates.jpg') File "C:\Users\PycharmProjects\faces\venv\lib\site-packages\face_recognition\api.py", line 83, in load_image_file im = PIL.Image.open(file) File "C:\Users\PycharmProjects\faces\venv\lib\site-packages\PIL\Image.py", line 2652, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: './Desktop/pics_python/bill gates.jpg' Process finished with exit code 1
Now I have a few general questions:

1-as you can see, in line 2 I had to write 'face_recognition' again because the minute I don't, line 1 becomes
inactive.Why so?
2-It looks like that anytime I start a new project, I have to install 'face_recognition' again, how come?
3-pycharm runs slowly, is it normal?
4- what is the best way to start a project in pycharm? In spyder all I do is to click 'new file' in the upper right corner, isn't it supposed to be as simple in pycharm?


Thank you in advance.
face recognition has nothing to do with pycharm.
pycharm is an IDE, not a language. Any python code that will run in pycharm will run on it's own, or in any other IDE.

So proper question is what packages are used by python.
With that said, see: https://pypi.org/search/?q=face+recognition
I never said that pycharm is a language, I obviously know is a compiler.
However, the problems listed above still persist.
How so?
The link you sent me has exactly the same line of code that I wrote, yet,
the issues are still there.
pycharm is not a compiler either, it's an IDE an editor.
The link that I sent is a URL for python packages having to do with facial recognition
I managed to make the program run, however, now I am running into a semantic error.
The 'unknown picture' I have chosen is someone who looks like bill gates but is not him,
however, the outcome I get is: "this is bill gates".
Do you perhaps know what's wrong?

Moreover, pycharm is still taking awhile before displaying the outcome (20 sec or something),
do you perhaps know why?
Is it normal?

import face_recognition


bill_gates_pic = face_recognition.load_image_file('./pics_python/bill gates.jpg')
bill_gates_face_location = face_recognition.face_locations(bill_gates_pic)
bill_face_encoding=face_recognition.face_encodings(bill_gates_pic)[0]

unknown_face = face_recognition.load_image_file('./pics_python/bill-gates-lookalike.jpg')
unknown_face_encoding=face_recognition.face_encodings(unknown_face)[0]


results = face_recognition.compare_faces([bill_face_encoding], unknown_face_encoding)

if results[0]:
    print('this is bill gates')
else:
    print('this is NOT bill gates')

by the way, this is the lookalike picture I am using:

http://www.lookalike.com/lookalikes/bill-gates-2.htm
I have never used this package, but looking at the docs, I see that you can isolate parts, eyes, nose, etc.
Perhaps comparing these might help.

Also, see this on changing tolerance: https://github.com/ageitgey/face_recognition/issues/160