Skip to main content

Facial Expression Recognition based on Keras

Project description

FER

Facial expression recognition.

https://github.com/justinshenk/fer/raw/master/result.jpg

INSTALLATION

Currently FER only supports Python3.4 onwards. It can be installed through pip:

$ pip3 install fer

This implementation requires OpenCV>=3.2 and Tensorflow>=1.7.0 installed in the system, with bindings for Python3.

They can be installed through pip (if pip version >= 9.0.1):

$ pip3 install tensorflow>=1.7 opencv-contrib-python==3.2.0.8

or compiled directly from sources (OpenCV3, Tensorflow).

Note that a tensorflow-gpu version can be used instead if a GPU device is available on the system, which will speedup the results. It can be installed with pip:

$ pip3 install tensorflow-gpu\>=1.7.0

USAGE

The following example illustrates the ease of use of this package:

>>> from fer.fer import FER
>>> import cv2
>>>
>>> img = cv2.imread("justin.jpg")
>>> detector = FER()
>>> print(detector.detect_emotions(img))
[{'box': [277, 90, 48, 63], 'emotions': {'angry': 0.02, 'disgust': 0.0, 'fear': 0.05, 'happy': 0.16, 'neutral': 0.09, 'sad': 0.27, 'surprise': 0.41}]

The detector returns a list of JSON objects. Each JSON object contains two keys: ‘box’ and ‘emotions’:

  • The bounding box is formatted as [x, y, width, height] under the key ‘box’.

  • The emotions are formatted into a JSON object with the keys ‘anger’, ‘disgust’, ‘fear’, ‘happy’, ‘sad’, surprise’, and ‘neutral’.

Other good examples of usage can be found in the files “example.py.” and “video-example.py.” located in the root of this repository.

MODEL

By default the FER bundles a face detection Keras model.

The model is a convolutional neural network with weights saved to HDF5 file in the ‘data’ folder relative to the module’s path. It can be overriden by injecting it into the FER() constructor during instantiation with emotion_model parameter.

LICENSE

MIT License.

CREDIT

This code includes methods and package structure copied or derived from Iván de Paz Centeno’s implementation<https://github.com/ipazc/mtcnn/>_ of MTCNN and Octavia Arriaga’s facial expression recognition repo<https://github.com/oarriaga/face_classification/>_.

REFERENCE

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

fer-0.0.1.tar.gz (800.6 kB view details)

Uploaded Source

Built Distribution

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

fer-0.0.1-py3-none-any.whl (805.4 kB view details)

Uploaded Python 3

File details

Details for the file fer-0.0.1.tar.gz.

File metadata

  • Download URL: fer-0.0.1.tar.gz
  • Upload date:
  • Size: 800.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for fer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9ace189255f4e7bfdd3bdb427548f815c17cd0eadc96b3a9992c332e9100a0e2
MD5 97c9556f4b089de0108b2bcd384ac44f
BLAKE2b-256 1164ba4a2ae6ee2fa30ca29637932b2f554acdf7664dc7beb4ca1709d4238e14

See more details on using hashes here.

File details

Details for the file fer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 805.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for fer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87ede6be2e5bdec8f4fe08a20ea6e3602c6dd9e00f66617029e3f8ea0c7f950c
MD5 0fa72ebc7ece53d12adc76231f53adef
BLAKE2b-256 d622bbcc42073190ec753656b92c0b6ca6708bbb09d46911d18d5b3f1cf4c5c9

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