Observed since 20 Oct, 21:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Age and gender estimation from face images, with no compiler required.
Age and gender estimation from face images.
Pure Python install. No compiler, no model downloads.
This package uses pretrained models from dlib-models by Davis E. King. The age predictor and gender classifier were contributed to dlib-models by Cydral Technology. We are grateful to them for making these models freely available.
pip install age-and-gender
Requires Python 3.11+. Pretrained models are bundled with the package.
from PIL import Image
from age_and_gender import AgeAndGender
predictor = AgeAndGender()
image = Image.open("photo.jpg").convert("RGB")
print(predictor.predict(image))
[{'gender': {'value': 'female', 'confidence': 100},
'age': {'value': 26, 'confidence': 84},
'face': [419, 266, 506, 352]},
...]

The built-in detector is optional. Crop faces with any detector (OpenCV, MediaPipe,
RetinaFace, face_recognition, etc.) and pass each crop to predict_face():
from PIL import Image
from age_and_gender import AgeAndGender
predictor = AgeAndGender()
image = Image.open("photo.jpg").convert("RGB")
for left, top, right, bottom in detect_faces(image): # your detector
face = image.crop((left, top, right, bottom)) # cropped face only
print(predictor.predict_face(face))
{'gender': {'value': 'female', 'confidence': 100}, 'age': {'value': 25, 'confidence': 80}}
If you only need one attribute, gender() and age() each run a single model:
predictor.gender(face) # {'value': 'female', 'confidence': 100}
predictor.age(face) # {'value': 25, 'confidence': 80}
facecan also be an RGB NumPy array. Convert OpenCV (BGR) frames first withcv2.cvtColor(frame, cv2.COLOR_BGR2RGB).
| Method | Returns |
|---|---|
AgeAndGender() | Predictor using the bundled models |
predict(image, face_bounding_boxes=None) | list of {gender, age, face}, one per detected face |
predict_face(face) | {gender, age} for one cropped face |
gender(face) | {value, confidence} |
age(face) | {value, confidence} |
AgeAndGender.from_model_dir(path) | Predictor using a custom model bundle (manifest.json + models) |
image / face: RGB PIL.Image or [H, W, 3] uint8 NumPy array.face_bounding_boxes: optional (top, right, bottom, left) boxes. When given, detection is skipped.face in results: [left, top, right, bottom].confidence: integer percentage.The pretrained models come from davisking/dlib-models and are bundled with the package, so nothing needs to be downloaded.
| Model | Description | In this package |
|---|---|---|
| HOG face detector | dlib's built-in frontal face detector. Used only by predict() when no boxes are given. | built into dlib |
shape_predictor_5_face_landmarks.dat | 5-point landmark model (eye corners and bottom of the nose) used to align each face. Trained on 7,198 annotated faces. | unchanged |
dnn_age_predictor_v1.dat | ResNet-10 age predictor trained on about 110k labelled face images. Estimates ages from 0 to 80. | age-v1.onnx |
dnn_gender_classifier_v1.dat | Compact CNN gender classifier trained on about 200k face images. Around 97.3% accuracy on LFW. | gender-v1.onnx |
dnn_age_predictor_v1.dat and dnn_gender_classifier_v1.dat were converted to
ONNX so they run on ONNX Runtime and are easier to use from
Python. The weights are unchanged, and the outputs match the original dlib networks.
dlib-bin wheel.AgeAndGender() works immediately. The load_* calls are no
longer needed.predict_face(), gender() and age() accept cropped faces.The package is released under the MIT License. The bundled models are dedicated to the public domain under CC0 1.0.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 2.0.0 | 24 Sept 2026 | 8 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:75b24e31cda20acb96aa1342d70543139e3d2ea54f33bf8e99d052d81e3be660