Back to Projects

sentiments_analysis

Sentiment Analysis with FastAPI and Transformers Description

December 21, 2025
sentiments_analysis

Tech Stack

pythonfastApiTransformersStreamlit

Sentiment Analysis with FastAPI and Transformers

Description

This project uses FastAPI to create a sentiment classification API based on Hugging Face's Transformers model. A front-end is developed with Streamlit to interact with the API.

Table of Contents

  1. Installation
  2. Interface
  3. Usage

Installation

Prerequisites

  • Python 3.6 or higher

Steps

  1. Clone the repository:
git clone https://github.com/chrfsa/sentiments_analysis.git
cd sentiments_analysis
  1. Create a virtual environment and activate it:
python -m venv venv
# On Windows
.\venv\Scripts\activate
# On macOS and Linux
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Launch the FastAPI server:

    # with uvicorn
    uvicorn api:app --reload
    # with fastapi
    fastapi dev api.py
    
  2. Launch the Streamlit application:

    streamlit run app.py
    

Usage

API

The FastAPI API exposes a /analysis endpoint for sentiment analysis. Send a POST request with JSON containing the text to be analyzed:

{
    “prompts”: “your text here”
}