SHIROI-07 commited on
Commit
b8ee686
·
verified ·
1 Parent(s): 376ed8c

Create app.js

Browse files
Files changed (1) hide show
  1. app.js +16 -0
app.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from transformers import pipeline
4
+
5
+ # Load emotion model
6
+ classifier = pipeline("text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
7
+
8
+ app = FastAPI(title="Emotion Detection API")
9
+
10
+ class TextInput(BaseModel):
11
+ text: str
12
+
13
+ @app.post("/analyze")
14
+ def analyze_emotion(data: TextInput):
15
+ result = classifier(data.text)
16
+ return {"emotions": result}