File size: 2,383 Bytes
531c353
 
 
 
 
 
 
 
 
 
 
5c50bbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Speak Your Mind Fastapi
emoji: 🔥
colorFrom: gray
colorTo: green
sdk: docker
pinned: false
license: mit
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# Speak Your Mind FastAPI 

**Speak Your Mind** is an **emotion detection API** built with **FastAPI**.  
It uses the **pre-trained RoBERTa model** [`cardiffnlp/twitter-roberta-base-emotion-latest`](https://huggingface.co/cardiffnlp/twitter-roberta-base-emotion-latest) to analyze emotions from text.

## Features
- **FastAPI-based REST API** running on **port 7860**.
- Uses **pre-trained RoBERTa model** for emotion classification.
- **Dockerized for easy deployment**.

## Model Information
This API uses the **`cardiffnlp/twitter-roberta-base-emotion-latest`** model without any additional training or fine-tuning.  
It predicts emotions such as **joy, sadness, optimism, and more**.

- **Model Source:** [Hugging Face Model Page](https://huggingface.co/cardiffnlp/twitter-roberta-base-emotion-latest)
- **No additional fine-tuning or training has been done**.
- **Supported Emotions:** Joy, Sadness, Optimism, etc.

## 🛠️ Installation & Usage

### ▶ Run Locally  
```bash
git clone https://huggingface.co/spaces/ADK09/speak-your-mind-fastapi
cd speak-your-mind-fastapi
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 7860
```
Access the API at `http://localhost:7860/docs`

### ▶ Run with Docker  
```bash
docker build -t speak-your-mind .
docker run -p 7860:7860 speak-your-mind
```

## API Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/` | Check if API is running |
| `POST` | `/classify-emotion` | Predict emotion from text |

### Example Request
```json
{
  "text": "I feel fantastic today!"
}
```
### Example Response
```json
{
  "predicted_emotion": "joy"
}
```

## Disclaimer
This API **only uses the pre-trained model** and does not modify or fine-tune it.  
Predictions are based on the **original model's training data**

## License
This project is licensed under the **MIT License**.

## Acknowledgments
This project **uses the RoBERTa model fine-tuned by Cardiff NLP**.  
Special thanks to the **Hugging Face** and **Cardiff NLP teams**.

- [`cardiffnlp/twitter-roberta-base-emotion-latest`](https://huggingface.co/cardiffnlp/twitter-roberta-base-emotion-latest)
```