{"id":23920499,"url":"https://github.com/justinshenk/fer","last_synced_at":"2025-05-16T08:02:50.296Z","repository":{"id":41390185,"uuid":"150107943","full_name":"JustinShenk/fer","owner":"JustinShenk","description":"Facial Expression Recognition with a deep neural network as a PyPI package","archived":false,"fork":false,"pushed_at":"2024-03-22T20:59:08.000Z","size":4365,"stargazers_count":369,"open_issues_count":24,"forks_count":82,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-08T18:18:18.829Z","etag":null,"topics":["emotion-detection","emotion-recognition","facial-expression-recognition","fer2013","python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JustinShenk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-24T13:35:52.000Z","updated_at":"2025-04-08T17:43:23.000Z","dependencies_parsed_at":"2024-06-18T17:03:33.885Z","dependency_job_id":"65e1e89a-dbbd-4f72-9e35-e5755e2587ea","html_url":"https://github.com/JustinShenk/fer","commit_stats":{"total_commits":217,"total_committers":10,"mean_commits":21.7,"dds":"0.35944700460829493","last_synced_commit":"4e271da77a72ab17538039fc7fc79b5682a5ee7a"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinShenk%2Ffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinShenk%2Ffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinShenk%2Ffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinShenk%2Ffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JustinShenk","download_url":"https://codeload.github.com/JustinShenk/fer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493382,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emotion-detection","emotion-recognition","facial-expression-recognition","fer2013","python","tensorflow"],"created_at":"2025-01-05T15:49:40.657Z","updated_at":"2025-05-16T08:02:50.270Z","avatar_url":"https://github.com/JustinShenk.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"FER\n===\n\nFacial expression recognition.\n\n![image](https://github.com/justinshenk/fer/raw/master/result.jpg)\n\n[![PyPI version](https://badge.fury.io/py/fer.svg)](https://badge.fury.io/py/fer) [![Build Status](https://travis-ci.org/justinshenk/fer.svg?branch=master)](https://travis-ci.org/justinshenk/fer) [![Downloads](https://pepy.tech/badge/fer)](https://pepy.tech/project/fer)\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/justinshenk/fer/blob/master/fer-video-demo.ipynb)\n\n[![DOI](https://zenodo.org/badge/150107943.svg)](https://zenodo.org/badge/latestdoi/150107943)\n\n\nINSTALLATION\n============\n\nCurrently FER only supports Python 3.6 onwards. It can be installed\nthrough pip:\n\n```bash\n$ pip install fer\n```\n\nThis implementation requires OpenCV\\\u003e=3.2 and Tensorflow\\\u003e=1.7.0\ninstalled in the system, with bindings for Python3.\n\nThey can be installed through pip (if pip version \\\u003e= 9.0.1):\n\n```bash\n$ pip install tensorflow\u003e=1.7 opencv-contrib-python==3.3.0.9\n```\n\nor compiled directly from sources\n([OpenCV3](https://github.com/opencv/opencv/archive/3.4.0.zip),\n[Tensorflow](https://www.tensorflow.org/install/install_sources)).\n\nNote that a tensorflow-gpu version can be used instead if a GPU device\nis available on the system, which will speedup the results. It can be\ninstalled with pip:\n\n```bash\n$ pip install tensorflow-gpu\\\u003e=1.7.0\n```\nTo extract videos that includes sound, ffmpeg and moviepy packages must be installed with pip:\n\n```bash\n$ pip install ffmpeg moviepy \n```\n\nUSAGE\n=====\n\nThe following example illustrates the ease of use of this package:\n\n```python\nfrom fer import FER\nimport cv2\n\nimg = cv2.imread(\"justin.jpg\")\ndetector = FER()\ndetector.detect_emotions(img)\n```\n\nSample output:\n```\n[{'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}]\n```\n\nPretty print it with `import pprint; pprint.pprint(result)`.\n\nJust want the top emotion? Try:\n\n```python\nemotion, score = detector.top_emotion(img) # 'happy', 0.99\n```\n\n#### MTCNN Facial Recognition\n\nFaces by default are detected using OpenCV's Haar Cascade classifier. To use the more accurate MTCNN network,\nadd the parameter:\n\n```python\ndetector = FER(mtcnn=True)\n```\n\n#### Video\nFor 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:\n\n```python\nfrom fer import Video\nfrom fer import FER\n\nvideo_filename = \"tests/woman2.mp4\"\nvideo = Video(video_filename)\n\n# Analyze video, displaying the output\ndetector = FER(mtcnn=True)\nraw_data = video.analyze(detector, display=True)\ndf = video.to_pandas(raw_data)\n```\n\nThe detector returns a list of JSON objects. Each JSON object contains\ntwo keys: 'box' and 'emotions':\n\n-   The bounding box is formatted as [x, y, width, height] under the key\n    'box'.\n-   The emotions are formatted into a JSON object with the keys 'anger',\n    'disgust', 'fear', 'happy', 'sad', surprise', and 'neutral'.\n\nOther good examples of usage can be found in the files\n[demo.py](demo.py) located in the root of this repository.\n\nTo run the examples, install click for command line with `pip install click` and enter `python demo.py [image|video|webcam]` --help.\n\nTF-SERVING\n==========\n\nSupport running with online TF Serving docker image.\n\nTo use: Run `docker-compose up` and initialize FER with `FER(..., tfserving=True)`.\n\nMODEL\n=====\n\nFER bundles a Keras model.\n\nThe model is a convolutional neural network with weights saved to HDF5\nfile in the `data` folder relative to the module's path. It can be\noverriden by injecting it into the `FER()` constructor during\ninstantiation with the `emotion_model` parameter.\n\nLICENSE\n=======\n\n[MIT License](LICENSE).\n\nCREDIT\n======\n\nThis code includes methods and package structure copied or derived from\nIván de Paz Centeno's [implementation](https://github.com/ipazc/mtcnn/)\nof MTCNN and Octavio Arriaga's [facial expression recognition\nrepo](https://github.com/oarriaga/face_classification/).\n\nREFERENCE\n---------\n\nFER 2013 dataset curated by Pierre Luc Carrier and Aaron Courville, described in:\n\n\"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](https://arxiv.org/abs/1307.0414).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinshenk%2Ffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinshenk%2Ffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinshenk%2Ffer/lists"}