Hello All,
I have been struggling on this for some time now. Im following theses instructions (https://www.tomshardware.com/how-to/ras ... ecognition) All installs correctly until I get to Part 2 line 14.
I open a new terminal and input the following (As in attached image) and get an error message about import face_recognition. In the instruction it says if you have this error do the following If, when training your model (Part 2, step 15), you get errors saying “No module named imutils” or “No module named face-recognition,” install these again using pip2 instead of pip.
This is the python from the train_model.py file (https://github.com/Mezbaldwin/Raspberry ... n_model.py)
I have done the install with pip2 and still get the same error.
Has anyone done this project before if so could I please get some help and advice.
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Face Recognition
- Attachments
-
- Terminal.jpg (23.41 KiB) Viewed 1188 times
Re: Face Recognition
It has a - not a _ ?
pip install face-recognition
pip install face-recognition
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Thank you, I'm a little confused on what you mean. Sorry.
I have put it in both ways with - and _
Is this what you mean?
I have put it in both ways with - and _
Is this what you mean?
Re: Face Recognition
When l read the installation instructions you used l noticed it said what is shown below, which has a -, but when you import it it uses a _. This could be a typo.
Did it install correctly ?
Did it install correctly ?
- Attachments
-
- IMG_20220717_093100.jpg (24.02 KiB) Viewed 1101 times
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Its still not installing correctly, the below what's I've done.
In the train_model.py file I have just changed the import to import face-recognition (show below)
and still get this error (Show Below)
I have changed it back to import face_recognition and get the below error still.
Im I being stupid?
In the train_model.py file I have just changed the import to import face-recognition (show below)
Code: Select all
#! /usr/bin/python
# import the necessary packages
from imutils import paths
import face-recognition
#import argparse
import pickle
import cv2
import os
# our images are located in the dataset folder
print("[INFO] start processing faces...")
imagePaths = list(paths.list_images("dataset"))
# initialize the list of known encodings and known names
knownEncodings = []
knownNames = []
# loop over the image paths
for (i, imagePath) in enumerate(imagePaths):
# extract the person name from the image path
print("[INFO] processing image {}/{}".format(i + 1,
len(imagePaths)))
name = imagePath.split(os.path.sep)[-2]
# load the input image and convert it from RGB (OpenCV ordering)
# to dlib ordering (RGB)
image = cv2.imread(imagePath)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# detect the (x, y)-coordinates of the bounding boxes
# corresponding to each face in the input image
boxes = face_recognition.face_locations(rgb,
model="hog")
# compute the facial embedding for the face
encodings = face_recognition.face_encodings(rgb, boxes)
# loop over the encodings
for encoding in encodings:
# add each encoding + name to our set of known names and
# encodings
knownEncodings.append(encoding)
knownNames.append(name)
# dump the facial encodings + names to disk
print("[INFO] serializing encodings...")
data = {"encodings": knownEncodings, "names": knownNames}
f = open("encodings.pickle", "wb")
f.write(pickle.dumps(data))
f.close()
Code: Select all
File "train_model.py", line 5
import face-recognition
^
SyntaxError: invalid syntax
Code: Select all
Traceback (most recent call last):
File "train_model.py", line 5, in <module>
import face_recognition
ImportError: No module named face_recognition
Im I being stupid?
Re: Face Recognition
Have you tried pip install face_recognition ?
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Yes and still the same result. Im doing this on Debian Buster OS
Code: Select all
pi@raspberrypi:~ $ pip install face_recognition
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting face_recognition
Using cached https://files.pythonhosted.org/packages/1e/95/f6c9330f54ab07bfa032bf3715c12455a381083125d8880c43cbe76bb3d0/face_recognition-1.3.0-py2.py3-none-any.whl
Collecting dlib>=19.7 (from face_recognition)
Using cached https://files.pythonhosted.org/packages/e5/3b/7a8522a5c2ef6ff6252e46b0788b3d2c2280198c49d6ecf3b576b171045f/dlib-19.24.0.tar.gz
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Downloading https://www.piwheels.org/simple/face-recognition-models/face_recognition_models-0.3.0-py2.py3-none-any.whl (100.6MB)
99% |████████████████████████████████| 100.6MB 6.7MB/s eta 0:00:01Killed
pi@raspberrypi:~ $
Code: Select all
pi@raspberrypi:~ $ cd facial_recognition
pi@raspberrypi:~/facial_recognition $ python train_model.py
Traceback (most recent call last):
File "train_model.py", line 5, in <module>
import face_recognition
ImportError: No module named face_recognition
pi@raspberrypi:~/facial_recognition $
Re: Face Recognition
If using python3 try pip3 install face_recognition
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Done that too, should I try it with face-recognition
Code: Select all
pi@raspberrypi:~ $ pip3 install face_recognition
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting face_recognition
Using cached https://files.pythonhosted.org/packages/1e/95/f6c9330f54ab07bfa032bf3715c12455a381083125d8880c43cbe76bb3d0/face_recognition-1.3.0-py2.py3-none-any.whl
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from face_recognition) (1.16.2)
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Downloading https://www.piwheels.org/simple/face-recognition-models/face_recognition_models-0.3.0-py2.py3-none-any.whl (100.6MB)
100% |████████████████████████████████| 100.6MB 4.2kB/s
Requirement already satisfied: Click>=6.0 in /usr/lib/python3/dist-packages (from face_recognition) (7.0)
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from face_recognition) (5.4.1)
Collecting dlib>=19.7 (from face_recognition)
Downloading https://www.piwheels.org/simple/dlib/dlib-19.24.0-cp37-cp37m-linux_armv7l.whl (3.2MB)
100% |████████████████████████████████| 3.2MB 127kB/s
Installing collected packages: face-recognition-models, dlib, face-recognition
Successfully installed dlib-19.24.0 face-recognition-1.3.0 face-recognition-models-0.3.0
Re: Face Recognition
Did it work ?
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Nope, I've rebooted and no changes. Do you know any other face recognition for pi4?
Re: Face Recognition
Have you tried python3 train_model.py ?
-
- Posts: 7
- Joined: Tue Mar 22, 2022 8:00 pm
Re: Face Recognition
Still not working. im going to have a look at some different instruction.
Re: Face Recognition
Facing the same problem, have you fixed it by any chance?