facial-analysis

Face Analysis (ONNX models)

Downloads GitHub Repository

This repository contains functionalities for face detection, age and gender classification, face recognition, and facial landmark detection. It supports inference from an image or webcam/video sources.

Features

Installation

  1. Clone the repository:
git clone https://github.com/yakyo/facial-analysis.git
cd facial-analysis
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Download weight files:

    a) Download weights from the following links:

    Model Weights Size
    ArcFace w600k_r50.onnx 166 MB
    SCRFD det_2.5g.onnx 3.14 MB
    SCRFD det_500m.onnx 2.41 MB
    SCRFD(default) det_10g.onnx 16.1 MB
    GenderAge genderage.onnx 1.26 MB

    b) Run the command below to download weights to the weights directory (Linux):

    sh download.sh
    

Usage

python main.py --source assets/in_video.mp4
                        assets/in_image.jpg
                        0 # for webcam

main.py arguments:

usage: main.py [-h] [--detection-weights DETECTION_WEIGHTS] [--attribute-weights ATTRIBUTE_WEIGHTS] [--source SOURCE] [--output OUTPUT]

Run face detection on an image or video

options:
  -h, --help            show this help message and exit
  --detection-weights DETECTION_WEIGHTS
                        Path to the detection model weights file
  --attribute-weights ATTRIBUTE_WEIGHTS
                        Path to the attribute model weights file
  --source SOURCE       Path to the input image or video file or camera index (0, 1, ...)
  --output OUTPUT       Path to save the output image or video

Reference

  1. https://github.com/deepinsight/insightface