Back to Projects
sentiments_analysis
Sentiment Analysis with FastAPI and Transformers Description
December 21, 2025

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
Installation
Prerequisites
- Python 3.6 or higher
Steps
- Clone the repository:
git clone https://github.com/chrfsa/sentiments_analysis.git
cd sentiments_analysis
- Create a virtual environment and activate it:
python -m venv venv
# On Windows
.\venv\Scripts\activate
# On macOS and Linux
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
-
Launch the FastAPI server:
# with uvicorn uvicorn api:app --reload # with fastapi fastapi dev api.py -
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”
}