ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
52.34k stars 13.36k forks source link

Please install `face_recognition_models`Please install `face_recognition_models` #608

Open Terobero opened 5 years ago

Terobero commented 5 years ago

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.

AndreWicked commented 5 years ago

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)
luizabbadia commented 4 years ago

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

MemoryShadow commented 1 year ago

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.

Andrei-Mihailov commented 9 months ago

I solved this problem in the following way:

  1. installed an older version of the dlib package: pip install dlib==19.21.1
  2. used the --no-cache-dir flag: pip install --no-cache-dir face_recognition
jercylew commented 8 months ago

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

abrarsharif66 commented 7 months ago

Thank you @jercylew pip install setuptools worked for me Also to anyone facing this issue trying doing this in an virtual env(not mandatory)

GustavoHNRamos commented 6 months ago

Thank you @jercylew, i've just come across with this problem and your has answer helped me!

sgivskud commented 5 months ago

Thank you @jercylew. Spent a week trying to solve it

Daveakan95 commented 4 months ago

just run this on your terminal window:

pip install setuptools

sachidumaleesha commented 4 months ago

just run this on your terminal window:

pip install setuptools

This one works for me. ❤️

Israelshecktar commented 4 months ago

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.

assraf-nur-p2m commented 4 months ago

@jercylew pip install setuptools is working thanks maan !!

usmonaliyev99 commented 4 months ago

just run this on your terminal window:

pip install setuptools

Thanks bro

yohanprabayoga commented 3 months ago

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.

souvik980055 commented 1 month ago

thanks @jercylew "pip install setuptools" work for me. a lot thanks.

martin-creator commented 1 month ago

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

duhanpxixi commented 1 month ago

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.

PaulRyu commented 3 weeks ago

Thank you @jercylew from me and everyone else in the future who comes across your solution! Fixed it right away.

k-ibet commented 3 weeks ago

@jercylew @Israelshecktar Thanks, the pip install --upgrade setuptools helped.

@Israelshecktar any documentation you can recommend for this issue?

litshivang commented 1 week ago

@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