mindtrack-backend / model /mood_predict.py
Shivenduu's picture
Initial commit for Flask Docker Space
b20cbbf
raw
history blame contribute delete
368 Bytes
from transformers import pipeline
# Load a BERT emotion classifier
emotion_classifier = pipeline(
"text-classification",
model="j-hartmann/emotion-english-distilroberta-base",
return_all_scores=False,
top_k = 1
)
def mood_predict(text: str):
preds = emotion_classifier(text)[0]
print(preds)
return preds[0] # return dict like content