facex

Facex: Lightweight, High-Performance Facial Expression Classifier

facex is a Python library for detecting faces and classifying emotions in images lightweight, efficient threading and object pooling for concurrent processing making it suitable for high-performance applications.

NOTE: The model was trained some time ago. While it performs well, newer advancements in the field may offer improved results

Features

NOTE: The model was trained some time ago. While it performs well, newer advancements in the field may offer improved results.

Alt Text

Testing on RaspberryPi

Installation

Install the library via pip:

pip install facex

Prerequisites

Make sure you have the following:

Additionally, ensure the assets directory contains the following files:

Usage

Example Code

import cv2
import facex

# Initialize the PoolManager
pool_manager = facex.PoolManager(pool_size=3)

# Load a test image
image = cv2.imread("test_image.jpg")

# Predict emotions
predictions = pool_manager.predict(image)

# Display results
for prediction in predictions:
    print(f"Face: {prediction['bbox']}, Emotion: {prediction['emot']}")

# Shutdown the pool manager when done
pool_manager.shutdown()

Key Classes and Methods

facex.EmotionClassifier

A class responsible for detecting faces and classifying emotions in images.

facex.PoolManager

A class for managing a pool of EmotionClassifier instances, enabling thread-safe predictions.

License

facex is licensed under the MIT License. See the LICENSE file for details.

References

  1. Coordinated Multi-Agent Imitation Learning
    Hendra Kusuma, Muhammad Attamimi, Hasby Fahrudin (2020). Deep learning based facial expressions recognition system for assisting visually impaired persons. Retrieved from link

Support

If you encounter any issues, feel free to open an issue or reach out via email.