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
10.85k stars 1.91k forks source link

[BUG]: Age of children detected wrong #1219

Closed SandeepaDevin closed 2 months ago

SandeepaDevin commented 2 months ago

Before You Report a Bug, Please Confirm You Have Done The Following...

DeepFace's version

0.0.90

Python version

3.9

Operating System

ubuntu 20.04

Dependencies

absl-py==2.1.0 anyio==4.3.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 astunparse==1.6.3 async-lru==2.0.4 attrs==23.2.0 Babel==2.14.0 bash_kernel==0.9.3 beautifulsoup4==4.12.3 bleach==6.1.0 blinker==1.7.0 certifi==2024.2.2 cffi==1.16.0 charset-normalizer==3.3.2 click==8.1.7 comm==0.2.2 contourpy==1.2.1 cycler==0.12.1 debugpy==1.8.1 decorator==5.1.1 deepface==0.0.90 defusedxml==0.7.1 exceptiongroup==1.2.1 executing==2.0.1 fastjsonschema==2.19.1 filelock==3.13.4 fire==0.6.0 Flask==3.0.3 flatbuffers==24.3.25 fonttools==4.51.0 fqdn==1.5.1 gast==0.5.4 gdown==5.1.0 google-pasta==0.2.0 grpcio==1.62.2 gunicorn==22.0.0 h11==0.14.0 h5py==3.11.0 httpcore==1.0.5 httpx==0.27.0 idna==3.7 importlib_metadata==7.1.0 importlib_resources==6.4.0 ipykernel==6.29.4 ipython==8.18.1 ipywidgets==8.1.2 isoduration==20.11.0 itsdangerous==2.2.0 jedi==0.19.1 Jinja2==3.1.3 json5==0.9.25 jsonpointer==2.4 jsonschema==4.21.1 jsonschema-specifications==2023.12.1 jupyter==1.0.0 jupyter-console==6.6.3 jupyter-events==0.10.0 jupyter-lsp==2.2.5 jupyter_client==8.6.1 jupyter_core==5.7.2 jupyter_server==2.14.0 jupyter_server_terminals==0.5.3 jupyterlab==4.1.7 jupyterlab_pygments==0.3.0 jupyterlab_server==2.27.1 jupyterlab_widgets==3.0.10 keras==3.3.2 kiwisolver==1.4.5 libclang==18.1.1 Markdown==3.6 markdown-it-py==3.0.0 MarkupSafe==2.1.5 matplotlib==3.8.4 matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 ml-dtypes==0.3.2 mtcnn==0.1.1 namex==0.0.8 nbclient==0.10.0 nbconvert==7.16.3 nbformat==5.10.4 nest-asyncio==1.6.0 notebook==7.1.3 notebook_shim==0.2.4 numpy==1.26.4 opencv-python==4.9.0.80 opt-einsum==3.3.0 optree==0.11.0 overrides==7.7.0 packaging==24.0 pandas==2.2.2 pandocfilters==1.5.1 parso==0.8.4 pexpect==4.9.0 pillow==10.3.0 platformdirs==4.2.1 prometheus_client==0.20.0 prompt-toolkit==3.0.43 protobuf==4.25.3 psutil==5.9.8 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.22 Pygments==2.17.2 pyparsing==3.1.2 PySocks==1.7.1 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 pytz==2024.1 PyYAML==6.0.1 pyzmq==26.0.2 qtconsole==5.5.1 QtPy==2.4.1 referencing==0.35.0 requests==2.31.0 retina-face==0.0.17 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.7.1 rpds-py==0.18.0 Send2Trash==1.8.3 six==1.16.0 sniffio==1.3.1 soupsieve==2.5 stack-data==0.6.3 tensorboard==2.16.2 tensorboard-data-server==0.7.2 tensorflow==2.16.1 tensorflow-io-gcs-filesystem==0.36.0 termcolor==2.4.0 terminado==0.18.1 tf_keras==2.16.0 tinycss2==1.3.0 tomli==2.0.1 tornado==6.4 tqdm==4.66.2 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 typing_extensions==4.11.0 tzdata==2024.1 uri-template==1.3.0 urllib3==2.2.1 wcwidth==0.2.13 webcolors==1.13 webencodings==0.5.1 websocket-client==1.8.0 Werkzeug==3.0.2 widgetsnbextension==4.0.10 wrapt==1.16.0 zipp==3.18.1

Reproducible example

image_path3 = r"/mnt/c/Users/admin/Documents/Dev/face_recognition/src/child2.jpeg"
analysis = DeepFace.analyze(img_path=image_path3, actions=["age", "gender", "emotion"])
print(analysis)

Relevant Log Output

[{'age': 30, 'region': {'x': 296, 'y': 86, 'w': 102, 'h': 102, 'left_eye': (365, 125), 'right_eye': (326, 127)}, 'face_confidence': 0.92, 'gender': {'Woman': 99.93638396263123, 'Man': 0.06362100830301642}, 'dominant_gender': 'Woman', 'emotion': {'angry': 4.3069964226817414e-10, 'disgust': 5.720243062957426e-20, 'fear': 2.194684858819111e-11, 'happy': 99.93439912405009, 'sad': 1.0998445477111201e-06, 'surprise': 0.0003568662108478602, 'neutral': 0.06524227599194801}, 'dominant_emotion': 'happy'}]

Expected Result

[{'age': 13, 'region': {'x': 296, 'y': 86, 'w': 102, 'h': 102, 'left_eye': (365, 125), 'right_eye': (326, 127)}, 'face_confidence': 0.92, 'gender': {'Woman': 99.93638396263123, 'Man': 0.06362100830301642}, 'dominant_gender': 'Woman', 'emotion': {'angry': 4.3069964226817414e-10, 'disgust': 5.720243062957426e-20, 'fear': 2.194684858819111e-11, 'happy': 99.93439912405009, 'sad': 1.0998445477111201e-06, 'surprise': 0.0003568662108478602, 'neutral': 0.06524227599194801}, 'dominant_emotion': 'happy'}]

What happened instead?

The age of children under analyse is very wrong. It often gives adult ages for young children.

Additional Info

No response

serengil commented 2 months ago

As mentioned in read me, age model comes with plus and minus 4 years error averagely. Single errors do not make a model incorrect or that is not a bug.

If you follow its technical tutorial, trainset has less count of instances for children. This is a known thing - not an issue.