|
|
| # 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. |
|
|
| ``` |
| |
| |