Skip to main content

Face Age & Gender detection tool

Simple opencv & tensorflow solution to estimate Age and Gender in your next project. Command line or Python DIY style.

Based on and forked from: https://github.com/yu4u/age-gender-estimation

Good enough for pet-projects and prototypes, but not ready for production real-life applications

How

pip3 install py-agender[cpu]  # for the cpu version of TensorFlow
pip3 install py-agender[gpu]  # for the gpu version of TensorFlow

Warning: ~190MB download (pretrained network is heavy).

CLI:

py-agender PATH_TO_IMAGE

Python:

from pyagender import PyAgender

agender = PyAgender() 
# see available options in __init__() src

faces = agender.detect_genders_ages(cv2.imread(MY_IMAGE))
# [
#   {left: 34, top: 11, right: 122, bottom: 232, width:(r-l), height: (b-t), gender: 0.67, age: 23.5},
#   ...
# ]

# Additional options & methods in PyAgender source

Don't forget to download pretrained weights if using source code DIY style.

TODO:

  • add options (like STDIN input, output formatters etc.) for useful commandline applications
  • add help output
  • train better network with higher image resolution
  • train another (more compact & precise) network architecture

Tests

python3 -m unittest 

Dependencies

  • Python 3.5, 3.6, 3.7
  • numpy ~> 1.15
  • Keras ~> 2.2
  • tensorflow or tensorflow-gpu ~> 1.10
  • opencv-python ~> 3.4.2+contrib

Tested on:

  • MacOS 10.13 high Sierra without GPU (you're welcome to update & contribute!)

Model

These weigts are from https://github.com/yu4u/age-gender-estimation on first console version run they are cached in ./pyagender.pretrained_models folder:

https://github.com/yu4u/age-gender-estimation/releases/download/v0.5/weights.28-3.73.hdf5

License

This project is released under the MIT license.

However, the IMDB-Wiki dataset used for pretrained network above is originally provided under the following conditions:

Please notice that this dataset is made available for academic research purpose only. All the images are collected from the Internet, and the copyright belongs to the original owners. If any of the images belongs to you and you would like it removed, please kindly inform us, we will remove it from our dataset immediately.

Refer to fresh IMDB-Wiki dataset License and act accordingly.

Metadata

Release files for py-agender 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-agender 0.0.9
File Size Uploaded
py-agender-0.0.9.tar.gz 188.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-agender 0.0.9
File Interpreter ABI Platform
py_agender-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 376.6 MB

Release files / py-agender-0.0.9.tar.gz

Download URL py-agender-0.0.9.tar.gz
Size 188.3 MB
Tags Source
SHA-256 checksum
How to use checksums
277277b7c9713e178d21536e28b502b7c6f5c55a496c645cd111696ec4131b90
BLAKE2b-256 checksum
How to use checksums
7e642018dcfcd6bc5c01686332ac6eb8a06632665407a3b70240ff58ce163d91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / py_agender-0.0.9-py3-none-any.whl

Download URL py_agender-0.0.9-py3-none-any.whl
Size 188.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f0317cc59d7493134704c3fb912a47b2308d14fc908751181d83d5a881317867
BLAKE2b-256 checksum
How to use checksums
86701d40c3bdfe83e9ce29a7780e5ca21c8da695aa3e20a0553586f66f1b2398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page