CoolFace
Apppublic

Priyam1105/Sentiment_analysis_pro

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
App README

๐ŸŽฏ Sentiment Analysis API

A production-ready FastAPI application for service review sentiment analysis powered by a fine-tuned DistilBERT model.

Model Details

  • โ€”Base Model: distilbert-base-uncased
  • โ€”Task: Sequence Classification (3 classes)
  • โ€”Labels: positive, neutral, negative
  • โ€”Training Data: Amazon service reviews + synthetic service review data

API Endpoints

MethodEndpointDescription
GET/Interactive Web UI
GET/healthHealth check
GET/docsSwagger API documentation
POST/predictSingle text prediction
POST/predict/batchBatch prediction (up to 50 texts)

Quick Start (Local)

bash
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 7860 --reload

Example API Usage

python
import requests

response = requests.post(
    "http://localhost:7860/predict",
    json={"text": "The plumber was very professional and on time"}
)
print(response.json())
# {"text": "...", "sentiment": "positive", "confidence": 0.98, "raw_label": "LABEL_2"}

Deploy to Hugging Face Spaces

  1. 1.Create a new Space on Hugging Face
  2. 2.Select Docker as the SDK
  3. 3.Push this entire repository to the Space
  4. 4.The app will build and deploy automatically

Tech Stack

  • โ€”FastAPI โ€” High-performance async API framework
  • โ€”Hugging Face Transformers โ€” DistilBERT model inference
  • โ€”PyTorch โ€” Deep learning backend
  • โ€”Pydantic โ€” Request/response validation