Skip to main content

A package for analyzing faces in images to detect eye state, gaze direction, and facial expressions

Project description

Face Analysis

A package for analyzing faces in images to detect eye state, gaze direction, and facial expressions.

demo

Features

  • Gaze Detection: Determine gaze direction using ResNet models
  • Eye State Classification: Detect whether eyes are open or closed
  • Emotion Recognition: Identify facial expressions and emotions

How to install:

  1. Create a virtual environment and install dependencies:
make install

This will:

  • Install all dependencies using uv
  • Set up pre-commit hooks for code quality
  1. Activate the environment:
source .venv/bin/activate

Usage Examples

Command Line Interface

The package provides several command-line tools for analyzing faces in images:

  1. Analyze a single image:
bash scripts/run_analysis.sh single input/test_1.png
  1. Analyze all images in a folder:
bash scripts/run_analysis.sh folder input/
  1. Select the best image from a folder:
bash scripts/run_analysis.sh best input/

Output will be saved to output/<command>/ directory.

Python API

Gaze Detection

from face_analysis.gazes import Pipeline as GazesPipeline
from face_analysis.gazes import render as GazesRender

gaze_pipeline = GazesPipeline(
    arch='ResNet50',  # Options: "ResNet18", "ResNet34", "ResNet101", "ResNet152"
    detector="retinaface",  # Options: "mtcnn"
    device="cuda",  # or "cpu"
)

img_in = cv2.imread("input/test_1.png")
results = gaze_pipeline.step(img_in)
img_out = GazesRender(img_in, results)
input output

Eye State Detection

from face_analysis.eyes import Pipeline as EyesPipeline
from face_analysis.eyes import render as eyes_render

eye_pipeline = EyesPipeline(
    detector="retinaface", # or "dlib"
    device="cpu", # or "cuda"
)

img_in = cv2.imread(img_path)
results = eye_pipeline.step(img_in)
img_out = eyes_render(img_in, results)
input output

Emotion Detection

from face_analysis.emotions import Pipeline as EmotionsPipeline
from face_analysis.emotions import render as emotions_render

emotion_pipeline = EmotionsPipeline(
    detector= "retinaface", # or "mtcnn", or "cascade"
    device= "cpu",
)

img_in = cv2.imread(img_path)
results = emotion_pipeline.step(img_in)
img_out = emotions_render(img_in, results)
input output

Repo Structure

project_root/
├── data/       
├── input/
├── output/
├── scripts/
├── face_analysis/                 
│
├── LICENSE.txt
├── pyproject.toml
├── README.md
├── requirements.txt
├── uv.lock
└── Makefile

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

face_analysis_kit-0.1.0.tar.gz (13.7 MB view details)

Uploaded Source

Built Distribution

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

face_analysis_kit-0.1.0-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file face_analysis_kit-0.1.0.tar.gz.

File metadata

  • Download URL: face_analysis_kit-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for face_analysis_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 983bfd98f95af48ac8b93631957120f6e9715b530acb9a9e5e70443d60d8c6aa
MD5 0d422e2a40184a4d6dededed4cc9e304
BLAKE2b-256 8c727da799715416a59cec94ca0c95e0ebd32bc56b28d194912cabe5e5bdc9e2

See more details on using hashes here.

File details

Details for the file face_analysis_kit-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for face_analysis_kit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b80fbe1f737007a3e992c53424cdbb66f76efe6a436629ad1e031ab1ae8f9e2
MD5 bee13e8f0708fc19137b287b1e26f16b
BLAKE2b-256 01fea34be7fe6bed72d659ec70f8d9ffe9a84d293e3a6961ef0ff7871f26f7e5

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