Spaces:
Sleeping
Sleeping
| title: Emoji AI Avatar | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: gradio | |
| sdk_version: "6.0.0" | |
| python_version: "3.10" | |
| app_file: app.py | |
| pinned: false | |
| suggested_hardware: "cpu-basic" | |
| short_description: Real-time emoji sentiment avatars for chat | |
| tags: | |
| - mcp-in-action-track-enterprise | |
| - mcp-in-action-track-consumer | |
| - mcp-in-action-track-creative | |
| - Google-Gemini-API | |
| - sentiment-analysis | |
| - emoji | |
| - chatbot | |
| - gradio | |
| - transformer | |
| - distilbert | |
| # π Emoji AI Avatar π€ | |
| **Real-time emoji avatars that reflect the sentiment of your conversation!** | |
| Watch as both your emoji and the AI's emoji change dynamically based on the emotional tone of messages. | |
| ## β¨ Features | |
| - **Transformer-Based Sentiment Analysis**: Uses DistilBERT (91%+ accuracy) for precise emotion detection | |
| - **Real-time Updates**: Analyzes messages as you type and as AI responds | |
| - **Dual Emoji Avatars**: Separate emoji displays for user and AI | |
| - **Streaming Support**: AI emoji updates during response generation | |
| - **100+ Emotion States**: Comprehensive sentiment coverage from joy to despair | |
| - **Beautiful UI**: Modern, responsive Gradio interface | |
| - **Evaluation Framework**: CI/CD-ready testing with accuracy benchmarks | |
| ## π Quick Start | |
| ### Local Development | |
| ```bash | |
| # Clone the repository | |
| git clone https://github.com/NLarchive/Emoji-AI-Avatar.git | |
| cd emoji-ai-avatar | |
| # Create virtual environment | |
| python -m venv .venv | |
| source .venv/bin/activate # On Windows: .venv\Scripts\activate | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| # Run the app (uses mock AI by default) | |
| python app.py | |
| # Or with hot reload | |
| gradio app.py | |
| ``` | |
| ### With Gemini API | |
| ```bash | |
| # Set your API key | |
| export GEMINI_API_KEY='your-api-key-here' | |
| # Run the app | |
| python app.py | |
| ``` | |
| ## π Emoji Palette | |
| ### User Emotions (Based on Transformer Classification) | |
| | Emoji | Sentiment | Accuracy | | |
| |-------|-----------|----------| | |
| | π’ | Sadness/Negative | 100% | | |
| | π | Happiness/Positive | 100% | | |
| | π | Neutral | ~50% | | |
| The system detects **100+ specific emotions** (both transformer and multi-emotion models) including: | |
| - **Positive**: joy, happiness, excitement, enthusiasm, love, gratitude, etc. | |
| - **Negative**: sadness, anger, fear, anxiety, frustration, disgust, etc. | |
| - **Neutral**: thinking, uncertain, confused, etc. | |
| ## ποΈ Project Structure | |
| ``` | |
| emoji-ai-avatar/ | |
| βββ app.py # Main Gradio application | |
| βββ avatar/ # Sentiment analysis + utils | |
| β βββ __init__.py | |
| β βββ sentiment_transformer.py # DistilBERT-based binary analyzer | |
| β βββ sentiment_multi_emotion.py # Multi-emotion (RoBERTa) analyzer | |
| β βββ sentiment_emoji_map.py # Sentiment β Emoji mapping | |
| β βββ sentiment_keyword_map.py # Keywordβemotion mapping used by analyzer | |
| βββ llm-inference/ # LLM client module | |
| β βββ __init__.py | |
| β βββ gemini_client.py # Gemini API wrapper | |
| βββ mcp-client/ # MCP protocol client | |
| β βββ __init__.py | |
| β βββ mcp_client.py # MCP client implementation | |
| βββ evaluation/ # Testing & benchmarking + reports | |
| β βββ __init__.py | |
| β βββ emotion_test_suite.py # 100+ emotion test cases | |
| β βββ accuracy_benchmark.py # Speed/accuracy measurement | |
| β βββ live_stream_test.py # Transition testing | |
| β βββ report_generator.py # Markdown/JSON reports | |
| β βββ run_evaluation.py # Full evaluation runner | |
| β βββ reports/ # Generated reports | |
| βββ tests/ # Unit tests | |
| βββ requirements.txt # Python dependencies | |
| βββ README.md | |
| ``` | |
| ## π Evaluation Results | |
| Run the evaluation framework: | |
| ```bash | |
| python -m evaluation.run_evaluation | |
| ``` | |
| **Latest Results (approx):** | |
| - Weighted accuracy and wheel-aware evaluation results are recorded in evaluation/reports | |
| - Full test suites (V1, V2, V3) are available β expected overall accuracy ~90% depending on model and suite | |
| | Category | Count | Accuracy | | |
| |----------|-------|----------| | |
| | Positive Emotions | 40+ | 100% | | |
| | Negative Emotions | 50+ | 100% | | |
| | Neutral/Edge Cases | 10+ | ~40% | | |
| ## π§ͺ Testing | |
| ```bash | |
| # Run all tests | |
| python -m pytest avatar/tests/ -v | |
| # Run evaluation benchmark | |
| python -m evaluation.run_evaluation | |
| ``` | |
| ## π§ Configuration | |
| ### Environment Variables | |
| | Variable | Description | Required | | |
| |----------|-------------|----------| | |
| | `GEMINI_API_KEY` | Google Gemini API key | No (uses mock if not set) | | |
| ### Customization | |
| Edit `avatar/emoji_mapper.py` to customize emoji mappings: | |
| ```python | |
| mapper = EmojiMapper( | |
| custom_mappings={"excitement": "π", "love": "β€οΈ"} | |
| ) | |
| ``` | |
| ## π How It Works | |
| 1. **User Input**: When you type a message, it's analyzed by DistilBERT | |
| 2. **Sentiment Classification**: Model outputs positive/negative with confidence | |
| 3. **User Emoji Update**: Your avatar emoji changes to reflect your mood | |
| 4. **AI Processing**: The message is sent to Gemini (or mock) | |
| 5. **Streaming Response**: As AI generates a response, its emoji updates | |
| 6. **Final Analysis**: Both emojis settle on their final states | |
| ## π Deployment | |
| ### Hugging Face Spaces | |
| 1. Create a new Space on Hugging Face | |
| 2. Select "Gradio" as the SDK | |
| 3. Push this repository to the Space | |
| 4. Add `GEMINI_API_KEY` to Space Secrets | |
| 5. The app will auto-deploy! | |
| ### Docker | |
| ```dockerfile | |
| FROM python:3.10-slim | |
| WORKDIR /app | |
| COPY . . | |
| RUN pip install -r requirements.txt | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] | |
| ``` | |
| ## π€ Contributing | |
| Contributions are welcome! Please feel free to submit a Pull Request. | |
| ## π License | |
| MIT License β see LICENSE file. (Copyright Β© 2025 Nicolas Larenas) | |
| ## π Acknowledgments | |
| - [Gradio](https://gradio.app/) - For the amazing UI framework | |
| - [Google Gemini](https://ai.google.dev/) - For the AI capabilities | |
| - [Hugging Face](https://huggingface.co/) - For hosting, deployment, and transformers | |
| - [DistilBERT](https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english) - For sentiment analysis | |