File size: 372 Bytes
0fbe057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from pydantic import BaseModel
import joblib

app = FastAPI()

# Load your model at startup
model = joblib.load("app/emotion_classifier_pipe_lr.pkl")

class Request(BaseModel):
    text: str

@app.post("/predict")
async def predict_emotion(request: Request):
    prediction = model.predict([request.text])[0]
    return {"emotion": prediction}