fer

Facial Expression Recognition with a deep neural network as a PyPI package

https://github.com/justinshenk/fer

Science Score: 51.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org, zenodo.org
  • Committers with academic emails
    2 of 11 committers (18.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary

Keywords

emotion-detection emotion-recognition facial-expression-recognition fer2013 python tensorflow
Last synced: 4 months ago · JSON representation ·

Repository

Facial Expression Recognition with a deep neural network as a PyPI package

Basic Info
  • Host: GitHub
  • Owner: JustinShenk
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 4.16 MB
Statistics
  • Stars: 384
  • Watchers: 7
  • Forks: 83
  • Open Issues: 24
  • Releases: 2
Topics
emotion-detection emotion-recognition facial-expression-recognition fer2013 python tensorflow
Created over 7 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Citation Authors

README.md

FER

Facial expression recognition.

image

PyPI version Build Status Downloads

Open In Colab

DOI

INSTALLATION

Currently FER only supports Python 3.6 onwards. It can be installed through pip:

bash $ pip 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):

bash $ pip install tensorflow>=1.7 opencv-contrib-python==3.3.0.9

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:

bash $ pip install tensorflow-gpu\>=1.7.0 To extract videos that includes sound, ffmpeg and moviepy packages must be installed with pip:

bash $ pip install ffmpeg moviepy

USAGE

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

```python from fer import FER import cv2

img = cv2.imread("justin.jpg") detector = FER() detector.detect_emotions(img) ```

Sample output: [{'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}]

Pretty print it with import pprint; pprint.pprint(result).

Just want the top emotion? Try:

python emotion, score = detector.top_emotion(img) # 'happy', 0.99

MTCNN Facial Recognition

Faces by default are detected using OpenCV's Haar Cascade classifier. To use the more accurate MTCNN network, add the parameter:

python detector = FER(mtcnn=True)

Video

For recognizing facial expressions in video, the Video class splits video into frames. It can use a local Keras model (default) or Peltarion API for the backend:

```python from fer import Video from fer import FER

videofilename = "tests/woman2.mp4" video = Video(videofilename)

Analyze video, displaying the output

detector = FER(mtcnn=True) rawdata = video.analyze(detector, display=True) df = video.topandas(raw_data) ```

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 demo.py located in the root of this repository.

To run the examples, install click for command line with pip install click and enter python demo.py [image|video|webcam] --help.

TF-SERVING

Support running with online TF Serving docker image.

To use: Run docker-compose up and initialize FER with FER(..., tfserving=True).

MODEL

FER bundles a 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 the 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 of MTCNN and Octavio Arriaga's facial expression recognition repo.

REFERENCE

FER 2013 dataset curated by Pierre Luc Carrier and Aaron Courville, described in:

"Challenges in Representation Learning: A report on three machine learning contests," by Ian J. Goodfellow, Dumitru Erhan, Pierre Luc Carrier, Aaron Courville, Mehdi Mirza, Ben Hamner, Will Cukierski, Yichuan Tang, David Thaler, Dong-Hyun Lee, Yingbo Zhou, Chetan Ramaiah, Fangxiang Feng, Ruifan Li, Xiaojie Wang, Dimitris Athanasakis, John Shawe-Taylor, Maxim Milakov, John Park, Radu Ionescu, Marius Popescu, Cristian Grozea, James Bergstra, Jingjing Xie, Lukasz Romaszko, Bing Xu, Zhang Chuang, and Yoshua Bengio, arXiv:1307.0414.

Owner

  • Name: Justin Shenk
  • Login: JustinShenk
  • Kind: user
  • Location: Berlin, Germany
  • Company: @SimerseTeam

Founder of @VisioLab, @traja-team and @delve-team

Citation (CITATION)

@software{justin_shenk_2021_5362356,
  author       = {Justin Shenk and
                  Aaron CG and
                  Octavio Arriaga and
                  Owlwasrowk},
  title        = {justinshenk/fer: Zenodo},
  month        = sep,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {zenodo},
  doi          = {10.5281/zenodo.5362356},
  url          = {https://doi.org/10.5281/zenodo.5362356}
}

GitHub Events

Total
  • Watch event: 37
  • Fork event: 4
Last Year
  • Watch event: 37
  • Fork event: 4

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 222
  • Total Committers: 11
  • Avg Commits per committer: 20.182
  • Development Distribution Score (DDS): 0.261
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Justin Shenk s****n@g****m 164
Tharun-Anand 8****d 39
Fethi Tekyaygil f****i@g****m 8
julia-imlauer 1****r 2
Aaron a****x@g****m 2
Evan Jones e****s@a****m 2
Simon Wilhelm s****m@p****e 1
Shubham Gupta g****3@g****m 1
Octavio Arriaga o****a@d****e 1
Habeeb Rahman K T h****2@g****m 1
Aaron a****7@i****x 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 46
  • Total pull requests: 19
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 3 days
  • Total issue authors: 43
  • Total pull request authors: 10
  • Average comments per issue: 2.89
  • Average comments per pull request: 1.58
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zhouhao-learning (2)
  • AbinJilson (2)
  • linguist89 (2)
  • justinshenk (1)
  • osfa (1)
  • etjones (1)
  • Philip-Leron (1)
  • ghost (1)
  • Fqlox (1)
  • Roiinbarr (1)
  • agnivg (1)
  • ledermauss (1)
  • Nandu-Louro (1)
  • Owlwasrowk (1)
  • rishab-sharma (1)
Pull Request Authors
  • HabeebRahmanKT (6)
  • Tharun-Anand (4)
  • TekyaygilFethi (3)
  • aHardReset (2)
  • etjones (2)
  • oarriaga (1)
  • gshubham533 (1)
  • julia-imlauer (1)
  • justinshenk (1)
  • Owlwasrowk (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 19,139 last-month
  • Total docker downloads: 28
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 34
    (may contain duplicates)
  • Total versions: 72
  • Total maintainers: 1
pypi.org: fer

Facial expression recognition from images

  • Versions: 48
  • Dependent Packages: 3
  • Dependent Repositories: 34
  • Downloads: 19,139 Last month
  • Docker Downloads: 28
Rankings
Dependent repos count: 2.5%
Dependent packages count: 3.3%
Docker downloads count: 3.4%
Stargazers count: 3.7%
Average: 3.9%
Forks count: 5.0%
Downloads: 5.6%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/justinshenk/fer
  • Versions: 24
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 2.8%
Stargazers count: 3.1%
Average: 6.2%
Dependent packages count: 8.4%
Dependent repos count: 10.6%
Last synced: 4 months ago

Dependencies

requirements.txt pypi
  • Pillow *
  • ffmpeg ==1.4
  • keras >=2.0.0
  • matplotlib *
  • moviepy ==1.0.3
  • mtcnn >=0.1.1
  • opencv-contrib-python *
  • opencv-python *
  • pandas *
  • requests *
  • tqdm >=4.62.1
.github/workflows/tests.yaml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite
Dockerfile docker
  • python 3.7-slim build
docker-compose.yml docker
  • justinshenk/emotion_serving latest
setup.py pypi
environment.yml pypi
  • absl-py ==0.14.0
  • astunparse ==1.6.3
  • cachetools ==4.2.2
  • certifi ==2021.5.30
  • charset-normalizer ==2.0.6
  • clang ==5.0
  • cycler ==0.10.0
  • flatbuffers ==1.12
  • gast ==0.4.0
  • google-auth ==1.35.0
  • google-auth-oauthlib ==0.4.6
  • google-pasta ==0.2.0
  • grpcio ==1.40.0
  • h5py ==3.1.0
  • idna ==3.2
  • keras ==2.6.0
  • keras-preprocessing ==1.1.2
  • kiwisolver ==1.3.2
  • markdown ==3.3.4
  • matplotlib ==3.4.3
  • numpy ==1.19.5
  • oauthlib ==3.1.1
  • opencv-contrib-python ==4.5.3.56
  • opencv-python ==4.5.3.56
  • opt-einsum ==3.3.0
  • pandas ==1.3.3
  • pillow ==8.3.2
  • protobuf ==3.18.0
  • pyasn1 ==0.4.8
  • pyasn1-modules ==0.2.8
  • pyparsing ==2.4.7
  • python-dateutil ==2.8.2
  • pytz ==2021.1
  • requests ==2.26.0
  • requests-oauthlib ==1.3.0
  • rsa ==4.7.2
  • six ==1.15.0
  • tensorboard ==2.6.0
  • tensorboard-data-server ==0.6.1
  • tensorboard-plugin-wit ==1.8.0
  • tensorflow ==2.6.0
  • tensorflow-estimator ==2.6.0
  • termcolor ==1.1.0
  • tqdm ==4.62.3
  • typing-extensions ==3.7.4.3
  • urllib3 ==1.26.6
  • werkzeug ==2.0.1
  • wrapt ==1.12.1