ikshit2004 commited on
Commit
5bad8d0
·
verified ·
1 Parent(s): 3db05ab

Upload 2 files

Browse files
Files changed (2) hide show
  1. emotion_api.py +21 -0
  2. emotion_classifier_pipe_lr.pkl +3 -0
emotion_api.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ from fastapi import FastAPI
4
+ from pydantic import BaseModel
5
+ import joblib
6
+
7
+ app = FastAPI()
8
+
9
+ # Load your model once when the server starts
10
+ model = joblib.load("./models/emotion_classifier_pipe_lr.pkl")
11
+
12
+ class TextRequest(BaseModel):
13
+ text: str
14
+
15
+ class PredictionResponse(BaseModel):
16
+ emotion: str
17
+
18
+ @app.post("/predict", response_model=PredictionResponse)
19
+ def predict_emotion(req: TextRequest):
20
+ prediction = model.predict([req.text])[0]
21
+ return {"emotion": prediction}
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