{"id":16323777,"url":"https://github.com/im-rises/emotion_recognition_cnn","last_synced_at":"2025-10-25T20:31:26.357Z","repository":{"id":37895286,"uuid":"467505456","full_name":"Im-Rises/emotion_recognition_cnn","owner":"Im-Rises","description":"AI deep learning app to recognize facial emotions from a picture.","archived":false,"fork":false,"pushed_at":"2023-02-19T19:31:48.000Z","size":499623,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-31T10:22:38.686Z","etag":null,"topics":["ai","cnn","convolutional-neural-networks","deep-learning","image-classification","images","neural-network","opencv","python","tensorflow","videos"],"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/Im-Rises.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}},"created_at":"2022-03-08T12:36:48.000Z","updated_at":"2024-05-20T03:46:37.000Z","dependencies_parsed_at":"2023-02-08T03:01:21.785Z","dependency_job_id":null,"html_url":"https://github.com/Im-Rises/emotion_recognition_cnn","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/Im-Rises%2Femotion_recognition_cnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Femotion_recognition_cnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Femotion_recognition_cnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Femotion_recognition_cnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Im-Rises","download_url":"https://codeload.github.com/Im-Rises/emotion_recognition_cnn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238207641,"owners_count":19434095,"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":["ai","cnn","convolutional-neural-networks","deep-learning","image-classification","images","neural-network","opencv","python","tensorflow","videos"],"created_at":"2024-10-10T22:55:38.958Z","updated_at":"2025-10-25T20:31:16.346Z","avatar_url":"https://github.com/Im-Rises.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# emotion_recognition_cnn\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Python-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white\" alt=\"pythonLogo\" style=\"height:50px\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/169644815-7c59a948-09a4-4cd5-9a7d-d06d5dcd3ce1.svg\" alt=\"tensorflowLogo\" style=\"height:50px;\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/169644811-109bf300-c795-44c4-8bab-f6900f97c422.png\" alt=\"kerasLogo\" style=\"height:50px;\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/172961027-fd9185a5-da77-46e3-97b1-54e99e242822.png\" alt=\"opencvLogo\" style=\"height:50px;\"\u003e\n\u003c/p\u003e\n\n## Description\n\nDeep Learning AI Emotion recognition made in python with Tensorflow/Keras and OpenCV.\n\n✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n\n[➡️➡️➡️Try the AI directly in your Browser !!⬅️⬅️⬅️](https://im-rises.github.io/emotion-recognition-website)\n\n✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n\n## Table of Contents\n\n1. [Expression Recognition](#expression-recognition)\n    1. [Features](#features)\n2. [Videos](#videos)\n3. [Report and Jupyter Notebook](#report-and-jupyter-notebook)\n4. [Installation](#installation)\n    1. [Quickstart Browser Version](#quickstart-browser-version)\n    2. [Quickstart Computer Version](#quickstart-computer-version)\n        1. [Requirements](#1-requirements)\n        2. [Cuda and cuDNN installation (only if you want to train your own model on your own NVidia GPU)](#2-cuda-and-cudnn-installation--only-if-you-want-to-train-your-own-model-)\n            1. [Windows](#windows)\n            2. [Linux](#linux)\n        3. [Train a model and use it](#3-train-a-model-and-use-it)\n5. [Databases](#databases)\n6. [GitHub Actions](#github-actions)\n7. [Libraries](#libraries)\n8. [Documentations](#documentations)\n9. [Bibliography](#bibliography)\n10. [Contributors](#contributors)\n\n## Expression recognition\n\nThe app is able to analyse facial expressions directly by analysing one image or by analysing frame by frame a video.  \nIt finds a visible face on an image and shows the current emotion state of it based on the 7 main facial expressions :\n\n- Neutral/Normal\n- Sadness\n- Happiness\n- Fear\n- Anger\n- Surprise\n- Disgust\n\nThe app is using the CNN (Convolutional neural network) with the ResNet50 Architecture via Transfer Learning.\nThe AI is trained with the FER-2013 and FERPLUS datasets allowing it to understand how to analyse a person's emotion\nfrom a picture.\n\n\u003e **Note**\n\u003e The project is focused on the emotion recognition from face images.\n\u003e To find faces in a video, we use OpenCV that allow us to transform face in a video to croped images allowing us to\n\u003e predict the emotions.\n\n### Features\n\nThe app features :\n\n- UI\n- Handle face detection\n- Analyse emotions of a person\n\n## Videos\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/172060165-98d48d66-48cc-4d62-9529-2137907c621b.gif\" alt=\"quentinVid\"/\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/172060168-c282b57d-6d77-4a51-b44b-4088768a8022.gif\" alt=\"clementVid\"/\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/59691442/172060174-c7550108-bac5-4bdf-9661-69f7c7c88e52.gif\" alt=\"yohanVid\"/\u003e\n\u003c/p\u003e\n\n## Report and Jupyter Notebook\n\nA report is available, but it is only in French.\n\n[Pdf Report Link](./report/reconnaissance_emotions_faciales_clement_reiffers_quentin_morel_yohan_cohen-solal.pdf)\n\nThere is also a Jupyter Notebook named `demo.ipynb` at the root folder of the project which shows you an example of how\nwe trained our AI.\n\n## Installation\n\nThere is two versions of the project. One which you can test online by going to the `Quickstart Browser Version` section\nand the other for your computer in section `Quickstart Computer Version`.\n\n\u003e **Note**\n\u003e If you juste want to test the app, go on to the browser version, you need nothing except a browser to test it.\n\nThe other version can be used if you want to test on your computer, train/change the model etc...\n\n### Quickstart Browser Version\n\nFollow the link below if you want to try a version with the browser of our app.\n\nNo installations nor any libs to download and install.\n\nRepository :  \n\u003chttps://github.com/Im-Rises/emotion-recognition-website\u003e\n\nWebsite emotion_recognition version :  \n\u003chttps://im-rises.github.io/emotion-recognition-website/\u003e\n\n### Quickstart Computer Version\n\nFirstly you need to install python. We recommend you python 3.6 to 3.9 because certain libraries weren't available to\nversion above 3.9.\n\nIf you just want to start the UI app, then just follow the [Requirements](#1-requirements) instructions just below.\n\nIn the case you want to test the models and train them. We would advise you to follow\nthe [Requirements](#1-requirements)\ninstructions below and the second set of instructions\n[2. CUDA and cuDNN installation (only if you want to train your own AI)](#2-cuda-and-cudnn-installation--only-if-you-want-to-train-your-own-model-).\n\n\u003e **Note**\n\u003e **You will need a good GPU to train the models** if you don't want the training to take more than 2 hours.\n\nOnce everything is installed, go to part [3. Train a model and use it](#3-train-a-model-and-use-it) to train a model\nand test it.\n\n#### 1. Requirements\n\nTo use the program, you need to install [python](https://www.python.org) first (version 3.8 advised).\n\nYou can then install the required python packages. They are all listed in the requirements.txt file.\nTo directly install them all, type the following command:\n\n```terminal\npip install -r requirements.txt\n```\n\nWith all the packages installed you'll be able to start the `app.py` file at the root of the project,\nit will start the HIM shown in the readme. Once the HIM is started go in your browser to this address\n`http://localhost:3134`, wait a minute to let the backend start, and have fun !\n\nN.B. you can run `app.py` by typing in the terminal the following commands :\n\n```bash\nflask run\n```\n\nor\n\n```bash\npy app.py\n```\n\nIf you don't want to use the [browser UI version](#quickstart-browser-version), you can use the \n[python](https://www.python.org) UI version in `emotion_recognition/prediction.py`.\nIt works with [open-cv](https://opencv.org) and shows emotions directly in the terminal.\n\n#### 2. CUDA and cuDNN installation (only if you want to train your own model)\n\nBefore using the program, you should install [CUDA](https://developer.nvidia.com/cuda-downloads) and SDK to allow \nthe program to run with the GPU and not the CPU.\nThe app needs a lot of processing, so to speed it we use the GPU instead of the CPU.\n\n\u003e **Warning**\n\u003e While programming we used different versions of tensorflow, CUDA etc... To know which version of Tensorflow use with\nyour version of CUDA, cudNN etc... check this [link](https://www.tensorflow.org/install/source#gpu)\n\n##### Windows\n\nFollow this tutorial from Tensorflow :  \n\u003chttps://www.tensorflow.org/install/source_windows#install_gpu_support_optional\u003e\n\nVisual Studio or redistributable :  \n\u003chttps://visualstudio.microsoft.com/fr/downloads/\u003e  \n\u003chttps://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170\u003e\n\nCUDA :  \n\u003chttps://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/\u003e\n\ncuDNN :  \n\u003chttps://developer.nvidia.com/cudnn\u003e\n\nTensorflow :  \n\u003chttps://www.tensorflow.org/install/gpu\u003e\n\nFollow this video steps if you have difficulties \u003chttps://www.youtube.com/watch?v=hHWkvEcDBO0\u0026list=LL\u003e.  \nIf you are unable to install CUDA and CuDNN, I would advise you to use a TPU, by using Google Collab.\n\u003chttps://colab.research.google.com\u003e\n\nOnce you have installed the necessary packages, app, SDK, etc... You need to download the FER-13 dataset in the\n`3. Download the FER-13 database` section, then you'll be able to train your own AI.\n\n##### Linux\n\nFollow this tutorial from Tensorflow :  \n\u003chttps://www.tensorflow.org/install/source#install_gpu_support_optional_linux_only\u003e\n\nOnce you have installed the necessary packages, app, SDK, etc... You need to download the FER-13 dataset in the\n`3. Train a model and use it` section, then you'll be able to train your own AI.\n\n#### 3. Train a model and use it\n\nOnce everything is installed you can run the script `emotion_recognition/Models/training.py`.\nThere you can select which model you want to train by transfer learning between :\n\n1. resnet50\n2. vgg16\n3. xception\n4. inception_resnet_v2\n5. inception_v3\n6. resnet50v2\n7. resnet101\n\nIf you want to use another model for the UIs, save your model when asked by the script `training.py` (it happens at\nthe end of a training session). Then, you can change the model in `app.py` or `prediction.py`, in the\nfunction `load_weights` or `load_model`. By default, all saved models are stored\nin `emotion_recognition/Models/trained_models/` directory.\n\nThe function `load_weights` works only with `.h5` files while `load_model` works by giving him the path to a directory\nwhich contain a complete model.\n\nYou can also change the database on which you're training. By default, the AI is set to be trained on FER-2013 dataset\nthat you need to download first.\n\nIf you want to use FERPlus for better performances, you will need to download FERPLUS and FER-2013. Extract them in the\ndatabases' folder next to the `datasets.txt` file as two folder FER-2013 (containing train, test folders and\nfer2013.csv)\nand FERPlus folder containing all the FERPlus's Microsoft repository.\nLast step is to start the `remake_dataset.py` that will concatenate all FERPlus images inside the FER-2013 folder.\n\n\u003e **Note**\n\u003e All datasets can be downloaded below!!!\n\n---\n\n## Databases\n\n[FER-2013](https://www.kaggle.com/msambare/fer2013)  \n[FERPLUS](https://github.com/microsoft/FERPlus)\n\n## GitHub Actions\n\n[![CodeQL](https://github.com/Im-Rises/emotion_recognition_cnn/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/Im-Rises/emotion_recognition_cnn/actions/workflows/codeql.yml)\n[![Python application](https://github.com/Im-Rises/emotion_recognition_cnn/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/Im-Rises/emotion_recognition_cnn/actions/workflows/python-app.yml)\n\nThe project is set with a set of different scripts that do the following tasks:\n- CodeQl : Evaluate the quality of the code with the CodeQl tool.\n- Python application : Run the application with the Python application tool.\n\n## Libraries\n\n- [Python](https://www.python.org)\n- [Tensorflow/Keras](https://www.tensorflow.org)\n- [OpenCV](https://opencv.org)\n- [OpenCV weights](https://github.com/opencv/opencv/blob/4.x/data/haarcascades/haarcascade_frontalface_default.xml)\n- [Flask](https://flask.palletsprojects.com/en/2.1.x/)\n- [emojize](https://pypi.org/project/emoji/)\n\n## Documentations\n\nCNN, ANN, RNN presentation :  \n\u003chttps://www.youtube.com/watch?v=u7obuspdQu4\u003e\n\nHow to elaborate a CNN :  \n\u003chttps://www.analyticsvidhya.com/blog/2021/11/facial-emotion-detection-using-cnn/\u003e  \n\u003chttps://machinelearningmastery.com/how-to-develop-a-cnn-from-scratch-for-cifar-10-photo-classification/\u003e\n\nTransfert learning :  \n\u003chttps://www.datacorner.fr/vgg-transfer-learning/\u003e\n\nOpenCV :  \n\u003chttps://www.datacorner.fr/reco-faciale-opencv/\u003e  \n\u003chttps://www.datacorner.fr/reco-faciale-opencv-2/\u003e\n\n## Bibliography\n\nFERPLUS :  \nBarsoum, E., Zhang, C., Canton Ferrer, C., \u0026 Zhang, Z. (2016). Training Deep Networks for Facial Expression Recognition\nwith Crowd-Sourced Label Distribution. In ACM International Conference on Multimodal Interaction (ICMI).\n\n\u003c!--\n@inproceedings{BarsoumICMI2016,\ntitle={Training Deep Networks for Facial Expression Recognition with Crowd-Sourced Label Distribution},\nauthor={Barsoum, Emad and Zhang, Cha and Canton Ferrer, Cristian and Zhang, Zhengyou},\nbooktitle={ACM International Conference on Multimodal Interaction (ICMI)},\nyear={2016}\n}\n--\u003e\n\n## Contributors\n\nQuentin MOREL :\n\n- @Im-Rises\n- \u003chttps://github.com/Im-Rises\u003e\n\nClément REIFFERS :\n\n- @clementreiffers\n- \u003chttps://github.com/clementreiffers\u003e\n\nYohan COHEN-SOLAL :\n\n- @YohanCohen-Solal\n- \u003chttps://github.com/YohanCohen-Solal\u003e\n\n[![GitHub contributors](https://contrib.rocks/image?repo=Im-Rises/emotion_recognition_cnn\u0026max=3)](https://github.com/Im-Rises/emotion_recognition_cnn/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Femotion_recognition_cnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-rises%2Femotion_recognition_cnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Femotion_recognition_cnn/lists"}