{"id":18000211,"url":"https://github.com/gsudiro/emotion-detection","last_synced_at":"2026-04-28T11:02:58.655Z","repository":{"id":258715875,"uuid":"875286699","full_name":"gsudiro/Emotion-detection","owner":"gsudiro","description":"Emotion detection based on real-time facial recognition using deep learning.","archived":false,"fork":false,"pushed_at":"2024-11-18T03:45:43.000Z","size":215,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T07:43:59.530Z","etag":null,"topics":["computer-vision","deep-learning","emotion-detection","emotion-recognition","haar-cascade","opencv","opencv-python","tflearn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gsudiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-19T15:25:35.000Z","updated_at":"2024-10-19T15:42:40.000Z","dependencies_parsed_at":"2024-10-20T09:44:16.893Z","dependency_job_id":null,"html_url":"https://github.com/gsudiro/Emotion-detection","commit_stats":null,"previous_names":["gsudiro/emotion-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsudiro%2FEmotion-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsudiro%2FEmotion-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsudiro%2FEmotion-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsudiro%2FEmotion-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsudiro","download_url":"https://codeload.github.com/gsudiro/Emotion-detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142043,"owners_count":20890652,"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":["computer-vision","deep-learning","emotion-detection","emotion-recognition","haar-cascade","opencv","opencv-python","tflearn"],"created_at":"2024-10-29T23:10:33.239Z","updated_at":"2026-04-28T11:02:58.546Z","avatar_url":"https://github.com/gsudiro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emotion detection using deep learning\n\n## Introduction\n\nThis project aims to classify the emotion on a person's face into one of **seven categories**, using deep convolutional neural networks. The model is trained on the **FER-2013** dataset which was published on International Conference on Machine Learning (ICML). This dataset consists of 35887 grayscale, 48x48 sized face images with **seven emotions** - angry, disgusted, fearful, happy, neutral, sad and surprised.\n\n## Dependencies\n\n* Python 3, [OpenCV](https://opencv.org/), [Tensorflow](https://www.tensorflow.org/)\n* To install the required packages, run `pip install -r requirements.txt`.\n\n## Basic Usage\n\nThe repository is currently compatible with `tensorflow-2.0` and makes use of the Keras API using the `tensorflow.keras` library.\n\n* First, clone the repository and enter the folder\n\n```bash\ngit clone https://github.com/atulapra/Emotion-detection.git\ncd Emotion-detection\n```\n\n* Download the FER-2013 dataset inside the `src` folder.\n\n* If you want to train this model, use:  \n\n```bash\ncd src\npython emotions.py --mode train\n```\n\n* If you want to view the predictions without training again, you can download the pre-trained model from [here](https://drive.google.com/file/d/1FUn0XNOzf-nQV7QjbBPA6-8GLoHNNgv-/view?usp=sharing) and then run:  \n\n```bash\ncd src\npython emotions.py --mode display\n```\n\n* The folder structure is of the form:  \n  src:\n  * data (folder)\n  * `emotions.py` (file)\n  * `haarcascade_frontalface_default.xml` (file)\n  * `model.h5` (file)\n\n* This implementation by default detects emotions on all faces in the webcam feed. With a simple 4-layer CNN, the test accuracy reached 63.2% in 50 epochs.\n\n![Accuracy plot](imgs/accuracy.png)\n\n## Data Preparation (optional)\n\n* The [original FER2013 dataset in Kaggle](https://www.kaggle.com/deadskull7/fer2013) is available as a single csv file. I had converted into a dataset of images in the PNG format for training/testing.\n\n* In case you are looking to experiment with new datasets, you may have to deal with data in the csv format. I have provided the code I wrote for data preprocessing in the `dataset_prepare.py` file which can be used for reference.\n\n## Algorithm\n\n* First, the **haar cascade** method is used to detect faces in each frame of the webcam feed.\n\n* The region of image containing the face is resized to **48x48** and is passed as input to the CNN.\n\n* The network outputs a list of **softmax scores** for the seven classes of emotions.\n\n* The emotion with maximum score is displayed on the screen.\n\n## References\n\n* \"Challenges in Representation Learning: A report on three machine learning contests.\" I Goodfellow, D Erhan, PL Carrier, A Courville, M Mirza, B\n   Hamner, W Cukierski, Y Tang, DH Lee, Y Zhou, C Ramaiah, F Feng, R Li,  \n   X Wang, D Athanasakis, J Shawe-Taylor, M Milakov, J Park, R Ionescu,\n   M Popescu, C Grozea, J Bergstra, J Xie, L Romaszko, B Xu, Z Chuang, and\n   Y. Bengio. arXiv 2013.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsudiro%2Femotion-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsudiro%2Femotion-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsudiro%2Femotion-detection/lists"}