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.3.tar.gz (478.5 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.3-cp312-cp312-win_amd64.whl (887.3 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

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

File metadata

  • Download URL: insightface_rk-0.7.3.tar.gz
  • Upload date:
  • Size: 478.5 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.3.tar.gz
Algorithm Hash digest
SHA256 19f593ba06a919506320c3fe27b8bf558ee53a37415eabf6321249c8841442bd
MD5 08e223da6e0a403ed18ee2093f7bcce6
BLAKE2b-256 3ad1ad20f7fd7febbc9d055f292026933297126058c746ff90cc21063618e110

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for insightface_rk-0.7.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cb218bc49dbd8d52d23622056a23866882abcf37158351d4e18a4aa0fa8b2b6e
MD5 981292d754652f22935fa357dbfeafba
BLAKE2b-256 f2e757ca4b3c9f4ddae008cb663b805a476cee1f740570e54d71769dc64c563d

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