face_recognition
face_recognition copied to clipboard
Please install `face_recognition_models`Please install `face_recognition_models`
- face_recognition version: 1.2.2
- face_recognition_models: 0.3.0 #i have it installed
- Python version: 3.5.3
- Operating System: Rasbian (Raspberry-Pi)
Description
When I try to run this code, it quits with the message "Please install face_recognition_models
with this command before using face_recognition
:
pip install git+https://github.com/ageitgey/face_recognition_models", but I have installed it already. The Code: ` import face_recognition import picamera import numpy as np import os
camera = picamera.PiCamera() camera.resolution = (320, 240) output = np.empty((240, 320, 3), dtype=np.uint8)
known_encodings = [] known_names = []
path = "/home/pi/Desktop/images" files = [next(f for f in os.walk(path))[2]]
print("Loading...") print(files) for file in files[0]: image = face_recognition.load_image_file(path + "/" + str(file)) encoding = face_recognition.face_encodings(image)[0] known_encodings.append(encoding) known_names.append(file.split(".")[0])
face_locations = [] face_encodings = []
print("Loaded images")
while True: print("Capturing image.") # Grab a single frame of video from the RPi camera as a numpy array camera.capture(output, format="rgb")
# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(output)
print("Found {} faces in image.".format(len(face_locations)))
face_encodings = face_recognition.face_encodings(output, face_locations)
# Loop over each face found in the frame to see if it's someone we know.
for face_encoding in face_encodings:
# See if the face is a match for the known face(s)
match = face_recognition.compare_faces(known_encodings, face_encoding)
name = "<Unknown Person>"
if True in match:
name = known_names[match.index(True)]
print("I see someone named {}!".format(name))
`
What I Did
I ran the command "pip install git+https://github.com/ageitgey/face_recognition_models" a few times and it never said requirement already satisfied, it downloaded every time I ran the install. I have also tried it with pip3 but same result.
Maybe you have some problems with the path to the models, open api.py the folder where the face_recognition module is installed, and check the first lines.
face_detector = dlib.get_frontal_face_detector()
predictor_68_point_model = "models/shape_predictor_68_face_landmarks.dat"
pose_predictor_68_point = dlib.shape_predictor(predictor_68_point_model)
predictor_5_point_model = "models/shape_predictor_5_face_landmarks.dat"
pose_predictor_5_point = dlib.shape_predictor(predictor_5_point_model)
cnn_face_detection_model = "models/mmod_human_face_detector.dat"
cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)
face_recognition_model = "models/dlib_face_recognition_resnet_model_v1.dat"
face_encoder = dlib.face_recognition_model_v1(face_recognition_model)
May be it is still time to inform. I had the same problem and when I saw that running the same program in another folder it worked, I started to investigate and saw that the pycache for the older folder was Always placing a file related to another program, no matter how many times I deleted it. When I deleted this program from folder everything was back to normal.I think the culprit script was kind of running in background blocking others...it´s ok now
I also encountered the same problem. When I manually imported the face_recognition_models
module, its prompt was like this:
No module named 'pkg_resources'
I tried executing this:
pip3 install distribute
problem solved.
I solved this problem in the following way:
- installed an older version of the dlib package: pip install dlib==19.21.1
- used the --no-cache-dir flag: pip install --no-cache-dir face_recognition
I also encountered the same problem. When I manually imported the
face_recognition_models
module, its prompt was like this:No module named 'pkg_resources'
I tried executing this:
pip3 install distribute
problem solved.
Also resolved by
pip install setuptools
Thank you @jercylew pip install setuptools worked for me Also to anyone facing this issue trying doing this in an virtual env(not mandatory)
Thank you @jercylew, i've just come across with this problem and your has answer helped me!
Thank you @jercylew. Spent a week trying to solve it
just run this on your terminal window:
pip install setuptools
just run this on your terminal window:
pip install setuptools
This one works for me. ❤️
Specifically, the error is caused by an attempt to import Mutable Mapping from the collection's module, which in Python 3.10 should be imported from collections.abc instead. This issue can be resolved by updating the setuptools package to a version that supports Python 3.10. You can update setuptools using the following command:
pip install --upgrade setuptools Once successfully upgraded, you can now reinstall the face recognition model through this GitHub link...worked perfectly well for me.
@jercylew pip install setuptools is working thanks maan !!
just run this on your terminal window:
pip install setuptools
Thanks bro
I also have the same problem and I tried to fix it by running
pip install setuptools
pip3 install distribute
pip install --upgrade setuptools
after that i tried to run pip install git+https://github.com/ageitgey/face_recognition_models
but got
pi@raspberrypi:~/FaceRecognition $ pip install git+https://github.com/ageitgey/face_recognition_models
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/ageitgey/face_recognition_models
Cloning https://github.com/ageitgey/face_recognition_models to /tmp/pip-req-build-31naunc7
Running command git clone --filter=blob:none --quiet https://github.com/ageitgey/face_recognition_models /tmp/pip-req-build-31naunc7
error: RPC failed; curl 92 HTTP/2 stream 3 was not closed cleanly: CANCEL (err 8)
error: 2570 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: index-pack failed
fatal: could not fetch d4a2c4405ec2e962c521a13af91bf5f7098a62a8 from promisor remote
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet https://github.com/ageitgey/face_recognition_models /tmp/pip-req-build-31naunc7 did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet https://github.com/ageitgey/face_recognition_models /tmp/pip-req-build-31naunc7 did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
thanks in advance.
thanks @jercylew "pip install setuptools" work for me. a lot thanks.
Thanks @jercylew installing setup tools worked for me. I did not have to run this command "pip install git+https://github.com/ageitgey/face_recognition_models" again
I also encountered the same problem. When I manually imported the
face_recognition_models
module, its prompt was like this:No module named 'pkg_resources'
I tried executing this:
pip3 install distribute
problem solved.
Also resolved by
pip install setuptools
i try to fix this for 2 hours, and this works, thanks.
Thank you @jercylew from me and everyone else in the future who comes across your solution! Fixed it right away.
@jercylew @Israelshecktar Thanks, the pip install --upgrade setuptools helped.
@Israelshecktar any documentation you can recommend for this issue?
@jercylew Thank you so much brother, pip install setuptools, worked for me. I spent, so much time solving this error.
Can you give me advice for my development career i just have started and i am using chatgpt too much for code, how do you write code ? Do you write it on your own or what exactly do you do, kindly share