File size: 2,173 Bytes
b646cf8 | 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# Sentiment Checker (Docker + Hugging Face Spaces)
A minimal interactive web app that performs sentiment analysis using a Hugging Face model.
Users can type text, click a button, and instantly receive a prediction.
---
## π Live Concept
- Type text into a box
- Click **Check**
- Get sentiment (POSITIVE / NEGATIVE)
---
## π§ Why This Project Exists
Machine learning apps often fail to run across different environments due to:
- dependency conflicts
- mismatched library versions
- complex setup requirements
This project demonstrates how Docker solves these issues and enables seamless deployment on Hugging Face Spaces.
---
## π§° Tech Stack
- Python
- FastAPI
- Transformers (by Hugging Face)
- Docker
---
## π Project Structure
```
.
βββ app.py
βββ requirements.txt
βββ Dockerfile
````
---
## βοΈ How It Works
1. The frontend is a simple HTML page served by FastAPI
2. User input is sent to the `/predict` endpoint
3. A pre-trained sentiment model processes the text
4. The result is returned and displayed instantly
---
## π³ Docker Setup
### Build the image
```bash
docker build -t sentiment-app .
````
### Run the container
```bash
docker run -p 7860:7860 sentiment-app
```
Then open: [http://localhost:7860](http://localhost:7860)
---
## π€ Deployment (Hugging Face Spaces)
This app is designed to run on Hugging Face Spaces using Docker.
Steps:
1. Create a new Space
2. Select **Docker** as the SDK
3. Upload project files
4. The app will automatically build and deploy
---
## π‘ Why Docker Matters
Without Docker:
* Manual installation of dependencies
* Version conflicts (e.g., Torch, Transformers)
* Inconsistent results across machines
With Docker:
* Reproducible environment
* One-step deployment
* Works the same everywhere
---
## β οΈ Notes
* The first run may take longer due to model download
* Subsequent requests are much faster
---
## β
Key Takeaway
Docker enables reliable, reproducible deployment of machine learning applications, making it easy to share and run apps on platforms like Hugging Face Spaces without additional setup.
```
|