Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- Dockerfile +18 -0
- app/__init__.py +0 -0
- app/emotion_classifier_pipe_lr.pkl +3 -0
- app/main.py +16 -0
- requirements.txt +4 -0
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use official Python image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy requirement and install
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 10 |
+
|
| 11 |
+
# Copy app code
|
| 12 |
+
COPY app ./app
|
| 13 |
+
|
| 14 |
+
# Expose port (Hugging Face Spaces expects 7860)
|
| 15 |
+
EXPOSE 7860
|
| 16 |
+
|
| 17 |
+
# Start FastAPI with uvicorn
|
| 18 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/__init__.py
ADDED
|
File without changes
|
app/emotion_classifier_pipe_lr.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:faad44a2f2f17f9ce68314ec5785352ca76934cedba1fb641e7fa0bf44fdb8d8
|
| 3 |
+
size 2015652
|
app/main.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Load your model at startup
|
| 8 |
+
model = joblib.load("app/emotion_classifier_pipe_lr.pkl")
|
| 9 |
+
|
| 10 |
+
class Request(BaseModel):
|
| 11 |
+
text: str
|
| 12 |
+
|
| 13 |
+
@app.post("/predict")
|
| 14 |
+
async def predict_emotion(request: Request):
|
| 15 |
+
prediction = model.predict([request.text])[0]
|
| 16 |
+
return {"emotion": prediction}
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
scikit-learn
|
| 4 |
+
joblib
|