Skip to content
/ EFace Public

Neural Network project for emotional face recognition

License

Notifications You must be signed in to change notification settings

andihys/EFace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EmotionalFaces Recognition App

Project Description

The main objective is to develop an Android application for emotion recognition using a Machine Learning model optimized for mobile devices via TensorFlow Lite. The app allows users to:

  1. Take a photo using the device's camera.
  2. Process the image through a TFLite model to determine the predominant emotion.
  3. Display the result directly on the user interface.

The model was trained using the FER2013 dataset with advanced deep learning techniques, and its optimized format ensures high performance on mobile devices.


Features

  • Image Capture: Utilizes CameraX to take photos using the front-facing camera.
  • Real-Time Inference: Processes images using a convolutional neural network model.
  • User-Friendly Interface: Displays results directly in the app's text area.
  • Mobile Optimization: Model optimized through quantization.

Requirements

For the Android App

  • Android Studio (version >= 2022.1.1)
  • Gradle (version >= 7.4)
  • Device with Android 6.0 (API 23) or higher

For Model Training

  • Python >= 3.8
  • TensorFlow >= 2.9
  • Additional libraries:
    • numpy
    • scikit-learn
    • pillow

Project structure

Main Directories

  • app/: Source code for the Android app.
    • src/main/assets: Optimized model in TFLite format (emotion_model.tflite).
    • res/layout: XML layouts for the user interface.
    • java/com/example/emotionalfaces: Application logic.
  • models/: Contains files generated during training, including:
    • best_emotion_model.keras: Trained model.
    • emotion_model.tflite: Optimized model for mobile devices.
  • datasets/: Dataset used for training (FER2013).

Key Files

  • MainActivity.java: Android app logic.
  • TFmodel.py: Script for training and converting the model.
  • FEdataset.py: Script for loading and preprocessing the FER2013 dataset.

Installation and Usage

1. Android App

Environment Setup

  1. Open the project in Android Studio.
  2. Synchronize the Gradle files.
  3. Add the emotion_model.tflite file to the app/src/main/assets directory (already included in the project).

Execution

  1. Connect an Android device or use an emulator.
  2. Press the Run button (green triangle) in Android Studio.
  3. Launch the app on the device and explore its features.

2. Model Training

Requirements

Ensure the following Python dependencies are installed:

pip install numpy scikit-learn pillow tensorflow

Model Training

  1. Download the FER2013 dataset and place it in the datasets/fer2013.zip directory.
  2. Run the TFmodel.py script:
    python TFmodel.py
  3. The trained model will be saved in .keras and .tflite formats in the models/ directory.

Technical Details

Machine Learning Model

  • Architecture: Convolutional Neural Network (CNN)
    • 3 convolutional blocks with batch normalization and dropout.
    • Fully connected layers with ReLU and softmax activation.
  • Input: Grayscale images, size 48x48.
  • Output: 7 emotion classes (angry, disgust, fear, happy, neutral, sad, surprise).

TFLite Quantization

  • Full-integer quantization for optimized performance.
  • Data representative configured to ensure high accuracy.

Dataset

  • Name: FER2013 (Facial Expression Recognition 2013)
  • Format: ZIP file organized into directories for emotion categories.
  • Preprocessing:
    • Conversion to grayscale.
    • Pixel normalization (0-1).
    • Split into training (80%) and testing (20%).

Conclusion

This project demonstrates the effectiveness of emotion recognition using convolutional neural networks and its integration on mobile devices. The combination of an intuitive Android app and an optimized TFLite model represents a step forward in real-world AI-based applications.


Example

Screenshot 1 Screenshot 2

License

This project is distributed under the MIT License. See the LICENSE file for more details.

About

Neural Network project for emotional face recognition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published