Skip to main content

Enhanced face analysis package with frontal face detection and filtering largest face / small faces

Project description

InsightFace-Rk

An enhanced face analysis package built on top of InsightFace, with additional features for frontal face detection, largest face filtering, and improved gender/age estimation.

Features

  • All features from InsightFace base package
  • Enhanced frontal face detection with angle validation
  • Automatic largest face filtering
  • Improved gender and age estimation
  • Configurable face size thresholds

Installation

pip install insightface-rk

Usage

from insightface.app import FaceAnalysis

# Initialize face analyzer with enhanced features
face_analyzer = FaceAnalysis(
    name='buffalo_l',
    root='.insightface',
    providers=['CUDAExecutionProvider', 'CPUExecutionProvider'],
    allowed_modules=['detection', 'recognition', 'genderage']
)

# Prepare the model with custom thresholds
face_analyzer.prepare(
    ctx_id=0,
    det_size=(960, 960),
    det_thresh=0.7
)

# Get faces with enhanced filtering
faces = face_analyzer.get(
    img,
    max_num=1,                    # Maximum number of faces to detect
    small_face_threshold=0.05,    # Minimum relative face size
    largest_face_only=True,       # Only return the largest face
    genderage=True               # Enable gender and age estimation
)

# Process detected faces
for face in faces:
    print(f"Age: {face.age}")
    print(f"Gender: {'Male' if face.gender == 1 else 'Female'}")
    print(f"Detection score: {face.det_score}")

Enhanced Features Explained

Frontal Face Detection

The package includes additional validation to ensure detected faces are sufficiently frontal-facing, improving the accuracy of subsequent recognition tasks.

Largest Face Filtering

When largest_face_only=True, the system will automatically select the largest detected face in the image, useful for processing portrait photos or when the main subject should be prioritized.

Face Size Thresholding

The small_face_threshold parameter allows filtering out faces that are too small relative to the image dimensions, helping to focus on the most relevant faces in the scene.

Credits

This package is built on top of InsightFace (v0.7.3), an excellent face analysis toolkit. We extend our gratitude to the InsightFace team for their foundational work.

License

This package is released under the MIT License. However, please note that the pretrained models from InsightFace are available for non-commercial research purposes only.

Requirements

  • Python >= 3.8
  • CUDA-compatible GPU (optional, but recommended for better performance)
  • See requirements.txt for full dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

insightface_rk-0.7.3rc1.tar.gz (478.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

insightface_rk-0.7.3rc1-cp312-cp312-win_amd64.whl (887.4 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file insightface_rk-0.7.3rc1.tar.gz.

File metadata

  • Download URL: insightface_rk-0.7.3rc1.tar.gz
  • Upload date:
  • Size: 478.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for insightface_rk-0.7.3rc1.tar.gz
Algorithm Hash digest
SHA256 9c7ba858237741a18b019c8cf4bcbf48c5f6999be379e3225524de7011e85010
MD5 9a42254950ccf45e8855dd48f0c3c497
BLAKE2b-256 a4628aecb902028fca4fedc4fc38b85971267510dc5a3fa9d75cef0c1a76f9ab

See more details on using hashes here.

File details

Details for the file insightface_rk-0.7.3rc1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for insightface_rk-0.7.3rc1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7cb9d4ddd31fdd734ea869041aea15f93324373f8bec86044eacde579d7dc1ff
MD5 6aeb2e70109886bc1684e2fa848e925e
BLAKE2b-256 222325b7a596959be16a2e03b09c3c5f614e45d6c06375c203135d4a44080f31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page