Spaces:
Sleeping
Sleeping
File size: 1,770 Bytes
deda593 d0a31d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
---
title: Text Sentiment Classifier
emoji: π§
sdk: gradio
app_file: app.py
---
# Text-Sentiment-Classifier-API
This project is a simple REST API for sentiment analysis built with FastAPI and HuggingFace Transformers. It uses the distilbert-base-uncased-finetuned-sst-2-english model to classify English text as positive, negative or (rarely) neutral, and it returns a confidence score.
# π Features
- RESTful API with FastAPI
- Pre-trained BERT-based sentiment model
- JSON input and output
- Interactive Swagger UI at /docs
# π¦ Model
The API uses:
`` distilbert-base-uncased-finetuned-sst-2-english ``
A lightweight version of BERT fine-tuned on the SST-2 dataset for sentiment classification.
# Example
Request:
``
POST /predict
{
"text": "I absolutely love this product!"
}
``
Response:
``
{
"sentiment": "positive",
"confidence": 0.9981
}
``
# π File Structure
. </br>
βββ main.py # API implementation </br>
βββ requirements.txt # Python dependencies </br>
βββ README.md # Project documentation </br>
## π How to Use
1. Enter any English sentence in the input box
2. Click **Submit**
3. View the sentiment label and confidence
## π How to Deploy on Hugging Face Spaces
1. Create a Hugging Face account <br>
Sign up at https://huggingface.co/join
2. Create a new Space
Go to https://huggingface.co/spaces and click Create new Space
3. Fill out the form
- Space name: text-sentiment-api (or your choice)
- SDK: Gradio
- Visibility: Public or Private
4. Upload the files
- app.py
- requirements.txt
- README.md (this file)
5. Wait for the build
Hugging Face will automatically install dependencies and launch the app
6. Access your app
|