Face Analysis Kit
A Python package for analyzing faces in images to detect eye state, gaze direction, and facial expressions.
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. Install from PyPI
pip install face_analysis_kit
2. Build and install from source
- Clone the repo
git clone https://github.com/ahmedsalim3/face-analysis.git
cd face-analysis
- Create a virtual environment and install dependencies:
make install
This will:
- Install all dependencies using
uv - Set up pre-commit hooks for code quality
- Activate the environment:
source .venv/bin/activate
Optional: Install the package in editable mode pip install -e .
Usage Examples
Command Line Interface
The package provides several command-line tools for analyzing faces in images:
- Analyze a single image:
bash scripts/run_analysis.sh single input/test_1.png
- Analyze all images in a folder:
bash scripts/run_analysis.sh folder input/
- 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)
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)
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)
Repo Structure
project_root/
├── data/
├── input/
├── output/
├── scripts/
├── face_analysis/
│
├── LICENSE.txt
├── pyproject.toml
├── README.md
├── requirements.txt
├── uv.lock
└── Makefile
Contributing
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
make install # to setup environment and hooks
make test # to run tests before submitting
Metadata
Release files for face-analysis-kit 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| face_analysis_kit-1.0.0.tar.gz | 15.5 MB | Without provenance | Details for face_analysis_kit-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| face_analysis_kit-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for face_analysis_kit-1.0.0-py3-none-any.whl |
Total release size: 18.8 MB
Release files / face_analysis_kit-1.0.0.tar.gz
| Download URL | face_analysis_kit-1.0.0.tar.gz |
|---|---|
| Size | 15.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
614d838bdce6dd4f8da62d766d04676df750425010e7e5145398cfaca84564a2
|
|
BLAKE2b-256 checksum How to use checksums |
aa43e0ce3e5d46c6d427237e8dbdd7899e556426e29114ff984b4b6bbdd08e68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / face_analysis_kit-1.0.0-py3-none-any.whl
| Download URL | face_analysis_kit-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4eb5918057a503a07954839073da1752afac280f19c1ce8556e8e940fd5f84b
|
|
BLAKE2b-256 checksum How to use checksums |
37ec057c16c165886400ebc740960325c85cd866164adfcf27fa3eb9195f2bef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Security for face-analysis-kit 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.