Step 1: Install dependancies
sudo apt -y update && sudo apt -y full-upgrade
sudo apt install build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-base-dev \
libavcodec-dev \
libavformat-dev \
libboost-all-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
python3-pip \
zip \
python3-picamera
Step 2: Updates
sudo pip3 install --upgrade picamera[array]
Step 3: Increase the swap file size so we can build dlib
sudo nano /etc/dphys-swapfile
Find CONF_SWAPSIZE and change its value from 100 to 1024. Save
and exit then run this command:
sudo /etc/init.d/dphys-swapfile restart
Step 4: Build and install dlib
cd
git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git
cd ./dlib
sudo python3 setup.py install --compiler-flags "-mfpu=neon"
This may take a significant time to run (Raspberry Pi 4 took about 30 minutes)
Step 5: Revert the swap size
sudo nano /etc/dphys-swapfile
Find CONF_SWAPSIZE and change its value from 1024 to 100. Save
and exit then run this command:
sudo /etc/init.d/dphys-swapfile restart
Step 6: Install face_recognition and examples
sudo pip3 install face_recognition
You're done!
Hello and thank you for your work!
I'm trying to install on a Pi 4 running 32-bit Bookworm (I was originally trying with the 64-bit version, but switched to 32 when I started having problems because I understand software compatibility to be greater in the 32-bit version).
As per the "Python on Raspberry Pi" section of this support doc on the raspberry.com website, you can no longer use pip to install python packages systemwide and you must use a virtual environment. This also prevents you from being able to use
sudowhen doingpip install.It also seems to be the case that in step 1,
python3-picameradoes not exist in the apt library, butpython3-pycamera2does. When I add the2to the package name, drop the-b 'v19.6'from step 4, and do everything inside a virtual environment (created using venv) and not using sudo, I get all the way through toSuccessfully installed face-recognition-models-0.3.0 face_recognition-1.3.0