{"id":13993802,"url":"https://github.com/atulapra/Emotion-detection","last_synced_at":"2025-07-22T18:31:41.790Z","repository":{"id":23625308,"uuid":"99468636","full_name":"atulapra/Emotion-detection","owner":"atulapra","description":"Real-time Facial Emotion Detection using deep learning","archived":false,"fork":false,"pushed_at":"2024-08-30T23:52:21.000Z","size":16467,"stargazers_count":1189,"open_issues_count":14,"forks_count":487,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-11-28T15:02:11.302Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atulapra.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":"2017-08-06T06:28:56.000Z","updated_at":"2024-11-27T08:21:44.000Z","dependencies_parsed_at":"2024-01-18T04:18:21.914Z","dependency_job_id":"36312896-5d33-4896-a5b1-ab9876752d2e","html_url":"https://github.com/atulapra/Emotion-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulapra%2FEmotion-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulapra%2FEmotion-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulapra%2FEmotion-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulapra%2FEmotion-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulapra","download_url":"https://codeload.github.com/atulapra/Emotion-detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227156333,"owners_count":17739280,"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-08-09T14:02:33.900Z","updated_at":"2024-11-29T15:31:12.759Z","avatar_url":"https://github.com/atulapra.png","language":"Python","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","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulapra%2FEmotion-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulapra%2FEmotion-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulapra%2FEmotion-detection/lists"}