m93 commited on
Commit
12e8a63
·
verified ·
1 Parent(s): f231793

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +66 -11
  2. requirements.txt +6 -0
README.md CHANGED
@@ -1,11 +1,66 @@
1
- ---
2
- title: Sentiment.api
3
- emoji: 🏆
4
- colorFrom: gray
5
- colorTo: green
6
- sdk: docker
7
- pinned: false
8
- license: apache-2.0
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Sentiment Analysis API
3
+ emoji: 🎭
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ # Sentiment Analysis API
11
+
12
+ This Space provides a REST API for sentiment analysis using a fine-tuned transformer model.
13
+
14
+ ## API Endpoints
15
+
16
+ - `GET /` - API information
17
+ - `GET /health` - Health check
18
+ - `POST /predict` - Analyze sentiment
19
+ - `GET /docs` - Interactive API documentation (Swagger UI)
20
+
21
+ ## Usage Example
22
+
23
+ ```bash
24
+ curl -X POST "https://YOUR-USERNAME-sentiment-api.hf.space/predict" \
25
+ -H "Content-Type: application/json" \
26
+ -d '{"text": "I love this product!"}'
27
+ ```
28
+
29
+ Response:
30
+ ```json
31
+ {
32
+ "sentiment": "positive",
33
+ "confidence": 0.9234
34
+ }
35
+ ```
36
+
37
+ ## Model
38
+
39
+ This API uses a sentiment classification model trained on [describe your dataset].
40
+ Model repository: [link to your model repo]
41
+
42
+ ## Integration
43
+
44
+ You can call this API from any application:
45
+
46
+ ```javascript
47
+ // JavaScript/TypeScript
48
+ fetch('https://YOUR-USERNAME-sentiment-api.hf.space/predict', {
49
+ method: 'POST',
50
+ headers: {'Content-Type': 'application/json'},
51
+ body: JSON.stringify({text: 'Hello world'})
52
+ })
53
+ .then(r => r.json())
54
+ .then(data => console.log(data));
55
+ ```
56
+
57
+ ```python
58
+ # Python
59
+ import requests
60
+
61
+ response = requests.post(
62
+ 'https://YOUR-USERNAME-sentiment-api.hf.space/predict',
63
+ json={'text': 'Hello world'}
64
+ )
65
+ print(response.json())
66
+ ```
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn[standard]
3
+ torch
4
+ transformers
5
+ huggingface_hub
6
+ pydantic