← Prev

Emotion Analyzer

2 min read

View on GitHub
Contents

Overview

Emotion Analyzer is a small Streamlit application for exploring sentiment and emotion signals in text. It wraps pretrained Hugging Face models in a user-facing workflow with text input, .txt upload, confidence thresholds, Plotly visualizations, and per-session analysis history.

The project is intentionally focused: it is not a production moderation system or a mental-health tool. It is a practical ML interface that shows how to move from raw transformer outputs to something a user can interpret.

Capabilities

  • Multi-label emotion detection using SamLowe/roberta-base_go_emotions.
  • Sentiment scoring using nlptown/bert-base-multilingual-uncased-sentiment.
  • Local model caching after the first download.
  • Input validation with length limits.
  • Adjustable emotion confidence threshold.
  • Bar and radar charts for visual review.
  • Session history for comparing recent analyses.

Technical Shape

The project separates the model layer from the UI:

Area Responsibility
emotion_analyzer.py Model loading, validation, inference, sentiment normalization
streamlit_app.py UI flow, examples, charts, upload handling, session history
static/style.css Streamlit styling

The application uses PyTorch device detection, so it can run on CPU or use CUDA when available. Models are cached locally to avoid repeated downloads and reduce startup cost after the first run.

Why It Matters

This project demonstrates the product work around ML: not just calling a model, but shaping the results into clear UI states, readable labels, visual confidence scores, and useful guardrails. That is the part that often determines whether an ML prototype feels usable or confusing.

Lessons Learned

The biggest challenge was balancing model complexity with a lightweight user experience. Transformer models are powerful but heavy, so caching, input limits, and simple error handling were important to keep the app predictable.