Simple / readthis.md
Keira
Add application file
b646cf8

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

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:

  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.