Spaces:
Configuration error
Configuration error
File size: 1,543 Bytes
d85158b | 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 | # Text Sentiment Analyzer (Local)
A **simple local** Gradio app that classifies text sentiment using a Hugging Face Transformers pipeline
(`distilbert-base-uncased-finetuned-sst-2-english`). No remote APIs.
## Quickstart
```bash
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
python app.py
```
Open the printed local URL and paste any text. Use the **Neutral margin** slider to make the
classifier return **NEUTRAL** when POS vs NEG is too close to call.
## Why this fits Deliverable 2
- **Runs locally** on your hardware (no `InferenceClient`, no external API).
- Clear contrast vs. your API-based product from Deliverable 1.
- Includes **tests** and a **GitHub Action** that runs `pytest` on push/PR.
## Project layout
```
sentiment_local/
ββ app.py
ββ sentiment.py
ββ requirements.txt
ββ README.md
ββ tests/
β ββ test_sentiment.py
ββ .github/workflows/
ββ ci.yml
```
## Notes
- On the first run, Transformers will **download the model weights** to your machine
(cached under `~/.cache/huggingface/`). Subsequent runs are fully local.
- If you need strictly offline installs, pre-download the model:
```bash
python -c "from transformers import AutoTokenizer, AutoModelForSequenceClassification; \
AutoTokenizer.from_pretrained('distilbert-base-uncased-finetuned-sst-2-english'); \
AutoModelForSequenceClassification.from_pretrained('distilbert-base-uncased-finetuned-sst-2-english')"
```
|