serengil / deepface

A Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python
https://www.youtube.com/watch?v=WnUVYQP4h44&list=PLsS_1RYmYQQFdWqxQggXHynP1rqaYXv_E&index=1
MIT License
13.71k stars 2.15k forks source link

Importing Age model kills the running script - Raspberry Pi #475

Closed pierfrancescomartinello closed 2 years ago

pierfrancescomartinello commented 2 years ago

Hello everyone, I hope someone can help me with this issue. I'm currently working with a Raspberry Pi 4 Model B and I want to use DeepFace for a project I have in mind. I was running a script calling the DeepFace.stream() function, but as the library was loading the Age models, the program is killed. As I was trying to do some manual debug with a few print lines in /deepface/extendedmodels/Age.py , I noticed that it crashes after age_model.load_weights(home+'/.deepface/weights/age_model_weights.h5') is being called at line 51 of the aforementioned file. I notice a spike of CPU usage to 99% before the program is killed. I suppose it's a problem due to the dimensions of the models. I also notice that the model weights for facial expression analysis is loaded without any error (I suppose it loads because it's the lighter of the files, and I therefore suppose that Gender model too kills the execution). Following, some additional info. Hope you can help me with this problem, thank you for your time reading about my ordeal and for any support. PM

Current Python version:Python 3.7.3

Some info from neofetch:

OS: Raspbian GNU/Linux 10 (buster) armv7l
Host: Raspberry Pi 4 Model B Rev 1.5
Kernel: 5.10.103-v7l+
CPU: BCM2711 (4) @ 1.500GHz
Memory: 578MiB / 1820MiB

Output of "pip3 freeze":

pi@raspberrypi:~ $ pip3 freeze
absl-py==0.15.0
albumentations==1.1.0
appdirs==1.4.3
asn1crypto==0.24.0
astor==0.8.1
astroid==2.1.0
asttokens==1.1.13
astunparse==1.6.3
automationhat==0.2.0
beautifulsoup4==4.7.1
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
cached-property==1.5.2
cachetools==4.2.4
Cap1xxx==0.1.3
certifi==2018.8.24
chardet==3.0.4
click==8.1.3
cmake==3.22.4
colorama==0.3.7
colorzero==1.1
cookies==2.2.1
cryptography==2.6.1
cupshelpers==1.0
cycler==0.10.0
Cython==0.29.28
decorator==4.3.0
deepface==0.0.74
dlib==19.23.99
docutils==0.14
drumhat==0.1.0
entrypoints==0.3
envirophat==1.0.0
ExplorerHAT==0.4.2
filelock==3.6.0
Flask==2.1.2
flatbuffers==1.12
fourletterphat==0.1.0
gast==0.3.3
gdown==4.4.0
google-auth==1.35.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
gpiozero==1.6.2
grpcio==1.32.0
guizero==0.6.0
h5py==2.10.0
html5lib==1.0.1
idna==2.6
imageio==2.19.0
importlib-metadata==4.11.3
ipykernel==4.9.0
ipython==5.8.0
ipython_genutils==0.2.0
isort==4.3.4
itsdangerous==2.1.2
jedi==0.13.2
Jinja2==3.1.2
joblib==1.1.0
jupyter-client==5.2.3
jupyter-core==4.4.0
Keras==2.4.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
keyring==17.1.1
keyrings.alt==3.1.1
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
libutils==0.0.1
logilab-common==1.4.2
lxml==4.3.2
Markdown==3.3.6
MarkupSafe==2.1.1
matplotlib==3.0.2
mccabe==0.6.1
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.3
mtcnn==0.1.1
mypy==0.670
mypy-extensions==0.4.1
networkx==2.6.3
nudatus==0.0.4
numpy==1.21.6
oauthlib==2.1.0
olefile==0.46
opencv-python==4.5.5.64
opencv-python-headless==4.5.5.64
opt-einsum==3.3.0
packaging==21.3
pandas==1.3.5
pantilthat==0.0.7
parso==0.3.1
pexpect==4.6.0
pgzero==1.2
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
pickleshare==0.7.5
picraft==1.0
piglow==1.2.5
pigpio==1.78
Pillow==9.1.0
pipdeptree==2.2.1
prettytable==3.2.0
prompt-toolkit==1.0.15
protobuf==3.13.0
psutil==5.5.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycairo==1.16.2
pycodestyle==2.4.0
pycrypto==2.6.1
pycups==1.9.73
pyflakes==2.0.0
pygame==1.9.4.post1
Pygments==2.3.1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pylint==2.2.2
pyOpenSSL==19.0.0
pyparsing==2.2.0
pyserial==3.4
pysmbc==1.0.15.6
PySocks==1.7.1
python-apt==1.8.4.3
python-dateutil==2.7.3
pytz==2022.1
PyWavelets==1.3.0
pyxdg==0.25
PyYAML==6.0
pyzmq==17.1.2
qtconsole==4.3.1
qudida==0.0.4
rainbowhat==0.1.0
reportlab==3.5.13
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
retina-face==0.0.10
roman==2.0.0
RPi.GPIO==0.7.0
rsa==4.8
RTIMULib==7.2.1
scikit-image==0.19.2
scikit-learn==1.0.2
scipy==1.7.3
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
semver==2.0.1
Send2Trash==1.5.0
sense-emu==1.2
sense-hat==2.2.0
simplegeneric==0.8.1
simplejson==3.16.0
six==1.15.0
skywriter==0.0.7
sn3218==1.2.7
soupsieve==1.8
spidev==3.5
ssh-import-id==5.7
tensorboard==2.9.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow @ https://github.com/bitsy-ai/tensorflow-arm-bin/releases/download/v2.4.0/tensorflow-2.4.0-cp37-none-linux_armv7l.whl
tensorflow-estimator==2.4.0
termcolor==1.1.0
thonny==3.3.10
threadpoolctl==3.1.0
tifffile==2021.11.2
tornado==5.1.1
touchphat==0.0.1
tqdm==4.64.0
traitlets==4.3.2
twython==3.7.0
typed-ast==1.3.1
typing-extensions==3.7.4.3
uflash==1.2.4
unicornhathd==0.0.4
urllib3==1.24.1
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==2.1.2
wrapt==1.12.1
zipp==3.8.0

The script I'm currently trying to run (I know it's a single line, but just to be sure I'm doing anything correctly):

from deepface import DeepFace

DeepFace.stream()

The terminal output as I try to run my code:

Detector backend is  opencv
WARNING: There is no image in this path (   ) . Face recognition will not be performed.
Emotion model loaded
Killed
serengil commented 2 years ago

your memory device seems not enough to run this model obviously.