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.
Upload an image and get instant emotion probabilities across 8 different categories with detailed visual feedback.
Utilize your device's camera for live emotion detection and continuous tracking of emotional shifts in real-time.
An LSTM model learns from your emotional history to predict likely future emotional states - a unique feature that sets this apart!
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
Detects and predicts: amusement ๐ | anger ๐ | awe ๐ฒ | contentment ๐ | disgust ๐คข | excitement ๐คฉ | fear ๐จ | sadness ๐ข
- ๐งน Clearable History: Reset all collected emotion data
- ๐พ Downloadable Data: Export emotional history as CSV for further analysis
| Technology | Purpose | Badge |
|---|---|---|
| Streamlit | Interactive web application | |
| PyTorch | Deep learning framework | |
| Hugging Face | Vision Transformer model | |
| OpenCV | Webcam integration | |
| Plotly | Interactive visualizations |
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]
-
๐ฏ 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.
-
๐ Emotional History Tracking: Detected emotion probabilities are logged with timestamps, creating a continuous emotional timeline.
-
๐ฎ Future Prediction (LSTM): An LSTM neural network continuously updates with emotional history, learning sequences and patterns to predict future emotional states.
-
๐ Interactive Visualization: Streamlit and Plotly present current emotions, predicted future emotions, and historical trends through various interactive charts.
- Python 3.8+
- Webcam (for real-time analysis)
- Internet connection (for model downloads)
-
๐ฅ Clone the Repository:
git clone https://github.com/HackWGaveesh/emotion-ai-app.git cd emotion-ai-app -
๐ Create a Virtual Environment (Recommended):
python -m venv venv # On Windows .\venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
๐ฆ Install Dependencies:
pip install -r requirements.txt
-
๐ค Download Pre-trained Models:
emotion_vit_finetuned.pth: Fine-tuned ViT model weightssaved_model/: ViT image processor directory
Ensure these files are in the root directory and
saved_modeldirectory respectively. -
๐ Run the Streamlit App:
streamlit run app.py
๐ The application will open in your default web browser!
๐ 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
- Navigate to the "Image Analysis" tab
- Click "Choose an image with a face..." to upload
- View instant emotion analysis with detailed breakdown and radar chart
- Get future emotion predictions (when sufficient history is available)
- Go to the "Real-time Webcam" tab
- Click "
โถ๏ธ Start Camera" to activate webcam - Watch real-time emotion analysis and predictions
- Use "โน๏ธ Stop Camera" to halt feed
- "๐งน Clear History" to reset webcam data
- Visit the "Analytics Dashboard" tab
- Explore comprehensive emotional data visualization
- View interactive charts of your emotional journey
- Download raw data as CSV
- Option to clear all historical data
We welcome contributions! ๐ Here's how you can help:
- ๐ด Fork the repository
- ๐ Create a feature branch (
git checkout -b feature/AmazingFeature) - ๐พ Commit your changes (
git commit -m 'Add some AmazingFeature') - ๐ค Push to the branch (
git push origin feature/AmazingFeature) - ๐ Open a Pull Request
- ๐จ UI/UX improvements
- ๐ง Additional emotion categories
- ๐ New visualization types
- ๐ง Performance optimizations
- ๐ Documentation enhancements
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ค Hugging Face for the Vision Transformer models
- ๐จ Streamlit team for the amazing framework
- ๐ง PyTorch community for deep learning tools
- ๐ Plotly for interactive visualizations
Have questions, suggestions, or just want to chat about AI and emotions?
โญ 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" ๐
