Skip to content

HackWGaveesh/emotion-ai-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง โœจ Emotion AI: Real-time Emotion Recognition with Future Prediction

Emotion AI Logo

Streamlit App Python Contributions welcome License


๐ŸŒŸ Overview

Emotion AI is an advanced Streamlit web application that performs real-time emotion recognition from images and webcam feeds, and uniquely offers future emotion prediction capabilities. Leveraging a fine-tuned Vision Transformer (ViT) for accurate emotion detection and a Long Short-Term Memory (LSTM) neural network for forecasting emotional trends, this app provides comprehensive insights into emotional states.

โœจ Features

๐Ÿ“ธ Image-based Emotion Analysis

Upload an image and get instant emotion probabilities across 8 different categories with detailed visual feedback.

๐ŸŽฅ Real-time Webcam Analysis

Utilize your device's camera for live emotion detection and continuous tracking of emotional shifts in real-time.

๐Ÿ”ฎ Future Emotion Prediction

An LSTM model learns from your emotional history to predict likely future emotional states - a unique feature that sets this apart!

๐Ÿ“Š Interactive Analytics Dashboard

Visualize your emotional journey over time with detailed charts, including:

  • ๐Ÿ“ˆ Emotional Journey Timeline (Line Chart)
  • ๐Ÿ”ฅ Emotion Intensity Heatmap
  • ๐Ÿฅง Dominant Emotions Distribution (Pie Chart)
  • ๐ŸŽฏ Emotional State Radar Chart

๐ŸŽญ 8 Emotion Categories

Detects and predicts: amusement ๐Ÿ˜„ | anger ๐Ÿ˜  | awe ๐Ÿ˜ฒ | contentment ๐Ÿ˜Œ | disgust ๐Ÿคข | excitement ๐Ÿคฉ | fear ๐Ÿ˜จ | sadness ๐Ÿ˜ข

๐Ÿ”ง Additional Features

  • ๐Ÿงน Clearable History: Reset all collected emotion data
  • ๐Ÿ’พ Downloadable Data: Export emotional history as CSV for further analysis

๐Ÿ› ๏ธ Technologies Used

Technology Purpose Badge
Streamlit Interactive web application Streamlit
PyTorch Deep learning framework PyTorch
Hugging Face Vision Transformer model HuggingFace
OpenCV Webcam integration OpenCV
Plotly Interactive visualizations Plotly

๐Ÿš€ How it Works

graph TD
    A[๐Ÿ“ท Input Image/Webcam] --> B[๐Ÿง  Vision Transformer ViT]
    B --> C[๐ŸŽญ 8 Emotion Probabilities]
    C --> D[๐Ÿ“ Emotional History Log]
    D --> E[๐Ÿ”ฎ LSTM Future Prediction]
    E --> F[๐Ÿ“Š Interactive Dashboard]
    F --> G[๐Ÿ“ˆ Real-time Visualization]
Loading
  1. ๐ŸŽฏ Emotion Detection (ViT): A pre-trained Vision Transformer model, fine-tuned for facial emotion classification, processes input images or webcam frames, outputting probabilities for 8 distinct emotions.

  2. ๐Ÿ“‹ Emotional History Tracking: Detected emotion probabilities are logged with timestamps, creating a continuous emotional timeline.

  3. ๐Ÿ”ฎ Future Prediction (LSTM): An LSTM neural network continuously updates with emotional history, learning sequences and patterns to predict future emotional states.

  4. ๐Ÿ“Š Interactive Visualization: Streamlit and Plotly present current emotions, predicted future emotions, and historical trends through various interactive charts.


๐Ÿ’ป Setup and Installation

๐Ÿ“‹ Prerequisites

  • Python 3.8+
  • Webcam (for real-time analysis)
  • Internet connection (for model downloads)

๐Ÿ”ง Installation Steps

  1. ๐Ÿ“ฅ Clone the Repository:

    git clone https://github.com/HackWGaveesh/emotion-ai-app.git
    cd emotion-ai-app
  2. ๐Ÿ Create a Virtual Environment (Recommended):

    python -m venv venv
    
    # On Windows
    .\venv\Scripts\activate
    
    # On macOS/Linux
    source venv/bin/activate
  3. ๐Ÿ“ฆ Install Dependencies:

    pip install -r requirements.txt
  4. ๐Ÿค– Download Pre-trained Models:

    • emotion_vit_finetuned.pth: Fine-tuned ViT model weights
    • saved_model/: ViT image processor directory

    Ensure these files are in the root directory and saved_model directory respectively.

  5. ๐Ÿš€ Run the Streamlit App:

    streamlit run app.py

    ๐ŸŽ‰ The application will open in your default web browser!


๐Ÿ“ Project Structure

๐Ÿ“‚ emotion-ai-app/
โ”œโ”€โ”€ ๐Ÿณ .devcontainer/              # Development container config
โ”œโ”€โ”€ ๐Ÿค– saved_model/                # ViT Image Processor
โ”‚   โ””โ”€โ”€ (processor files)
โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ Default_image.png           # Demo image
โ”œโ”€โ”€ ๐ŸŽจ Logo.png                    # Application logo
โ”œโ”€โ”€ ๐Ÿš€ app.py                      # Main Streamlit application
โ”œโ”€โ”€ ๐Ÿง  emotion_vit_finetuned.pth   # Fine-tuned ViT weights
โ”œโ”€โ”€ ๐Ÿ“– readme.md                   # This README file
โ””โ”€โ”€ ๐Ÿ“‹ requirements.txt            # Python dependencies

๐ŸŽฎ Usage Guide

๐Ÿ“ธ Image Analysis Tab

  1. Navigate to the "Image Analysis" tab
  2. Click "Choose an image with a face..." to upload
  3. View instant emotion analysis with detailed breakdown and radar chart
  4. Get future emotion predictions (when sufficient history is available)

๐ŸŽฅ Real-time Webcam Tab

  1. Go to the "Real-time Webcam" tab
  2. Click "โ–ถ๏ธ Start Camera" to activate webcam
  3. Watch real-time emotion analysis and predictions
  4. Use "โน๏ธ Stop Camera" to halt feed
  5. "๐Ÿงน Clear History" to reset webcam data

๐Ÿ“Š Analytics Dashboard Tab

  1. Visit the "Analytics Dashboard" tab
  2. Explore comprehensive emotional data visualization
  3. View interactive charts of your emotional journey
  4. Download raw data as CSV
  5. Option to clear all historical data

๐Ÿค Contributing

We welcome contributions! ๐ŸŽ‰ Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒŸ Create a feature branch (git checkout -b feature/AmazingFeature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add some AmazingFeature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/AmazingFeature)
  5. ๐Ÿ”„ Open a Pull Request

๐Ÿ’ก Ideas for Contribution

  • ๐ŸŽจ UI/UX improvements
  • ๐Ÿง  Additional emotion categories
  • ๐Ÿ“Š New visualization types
  • ๐Ÿ”ง Performance optimizations
  • ๐Ÿ“š Documentation enhancements

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • ๐Ÿค— Hugging Face for the Vision Transformer models
  • ๐ŸŽจ Streamlit team for the amazing framework
  • ๐Ÿง  PyTorch community for deep learning tools
  • ๐Ÿ“Š Plotly for interactive visualizations

๐Ÿ’ฌ Get in Touch

Have questions, suggestions, or just want to chat about AI and emotions?

GitHub Email


โญ If you found this project helpful, please consider giving it a star! โญ

Created with โค๏ธ by HackWGaveesh

"Understanding emotions through AI - bridging the gap between technology and human feelings" ๐ŸŒˆ

About

A Streamlit application for emotion recognition using Fine Tuned Vision Transformer (ViT) and LSTM for future emotion prediction.

Resources

License

Stars

Watchers

Forks

Contributors

Languages