{"id":31671335,"url":"https://github.com/jonas-is-coding/emotion-recognition","last_synced_at":"2025-10-08T02:32:11.355Z","repository":{"id":316022807,"uuid":"916697695","full_name":"jonas-is-coding/emotion-recognition","owner":"jonas-is-coding","description":"A fast and accurate emotion recognition model for your laptop's webcam.","archived":false,"fork":false,"pushed_at":"2025-09-22T07:03:54.000Z","size":8633,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-22T09:22:07.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonas-is-coding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-14T15:47:15.000Z","updated_at":"2025-09-22T07:03:58.000Z","dependencies_parsed_at":"2025-09-22T09:32:28.558Z","dependency_job_id":null,"html_url":"https://github.com/jonas-is-coding/emotion-recognition","commit_stats":null,"previous_names":["jonas-is-coding/emotion-recognition"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jonas-is-coding/emotion-recognition","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-is-coding%2Femotion-recognition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-is-coding%2Femotion-recognition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-is-coding%2Femotion-recognition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-is-coding%2Femotion-recognition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonas-is-coding","download_url":"https://codeload.github.com/jonas-is-coding/emotion-recognition/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-is-coding%2Femotion-recognition/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877727,"owners_count":26061503,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-08T02:30:19.493Z","updated_at":"2025-10-08T02:32:11.350Z","avatar_url":"https://github.com/jonas-is-coding.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emotion Recognition with Webcam\n\nThis project uses a Convolutional Neural Network (CNN) to recognize emotions from webcam images in real-time. It is trained on the FER-2013 dataset, which includes seven emotions: Angry, Disgust, Fear, Happy, Sad, Surprise, and Neutral. The model is tested with OpenCV to perform real-time emotion recognition via the webcam.\n\n## Prerequisites\n\nMake sure you have the following libraries installed:\n\n- TensorFlow\n- OpenCV\n- NumPy\n\nYou can install the required libraries with the following commands:\n\n```bash\npip install tensorflow opencv-python numpy\n```\n\n## Project Structure\n- train.py: Script for training the emotion recognition model.\n- main.py: Script for real-time emotion recognition using the webcam.\n- model: Folder where the trained model is saved (e.g., emotion_detection_model.h5).\n\n## How to Train the Model\n1. Prepare the data: The FER-2013 dataset is automatically loaded via the datasets library. This dataset contains images and their associated emotion labels.\n2. Train the model: Use the train.py script to train the model. The dataset consists of 48x48 grayscale images, which the model uses for emotion prediction.\n\nExample:\n```bash\npython train.py\n```\n\nAfter training, the model is saved as an .h5 file, e.g., emotion_detection_model.h5.\n\n## How to Test the Model with the Webcam\n1. Start the webcam script: Open the main.py script to test the model in real-time. The script uses OpenCV to access the webcam and predict emotions from detected faces in real-time.\n2. Run the test:\n```bash\npython main.py\n```\nThis opens a window where the camera is streamed, and each detected face has its predicted emotion displayed above it. You can exit the application by pressing q.\n\n## Code Explanation\n\ntrain.py\n- Loading the dataset: The FER-2013 dataset is loaded using the datasets library.\n- Model Architecture: A simple Convolutional Neural Network (CNN) is created with Keras, specifically designed for emotion image classification.\n- Training the model: The model is trained with the training data and validated on the test data.\n\nmain.py\n- Webcam streaming: OpenCV is used to start the webcam and read frames continuously.\n- Face detection: OpenCV’s pre-trained Haar cascades are used to detect faces in the image.\n- Emotion recognition: Each detected face is preprocessed and passed to the trained model for emotion prediction.\n- Displaying results: The predicted emotion is displayed on the webcam feed.\n\n## Emotions in the FER-2013 Dataset\n\nThe model recognizes the following seven emotions:\n1. Angry\n2. Disgust\n3. Fear\n4. Happy\n5. Sad\n6. Surprise\n7. Neutral\n\n## Example Output\n\nThe application displays the webcam image with a green rectangle around the detected face. The predicted emotion is shown above the face:\n```\n[Happy]        [Sad]        [Neutral]\n  ██████         ██████         ██████\n```\n\n## Notes\n- The accuracy of emotion recognition may vary depending on facial expressions, lighting conditions, and camera quality.\n- For better performance in face detection or emotion recognition, additional data preprocessing or a different face detection model may be useful.\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonas-is-coding%2Femotion-recognition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonas-is-coding%2Femotion-recognition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonas-is-coding%2Femotion-recognition/lists"}