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
- The frontend is a simple HTML page served by FastAPI
- User input is sent to the
/predictendpoint - A pre-trained sentiment model processes the text
- The result is returned and displayed instantly
π³ Docker Setup
Build the image
docker build -t sentiment-app .
Run the container
docker run -p 7860:7860 sentiment-app
Then open: http://localhost:7860
π€ Deployment (Hugging Face Spaces)
This app is designed to run on Hugging Face Spaces using Docker.
Steps:
- Create a new Space
- Select Docker as the SDK
- Upload project files
- 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.