Views
No views yet
1from transformers import pipeline
2
3pipe = pipeline("text-classification", model="Subhra-123/distilbert-base-emotion", return_all_scores=True)
4text = "I love my friends!"
5pred = pipe(text)[0]
6emotion = max(pred, key=lambda x: x['score'])
7print(f"{text} → {emotion['label']} ({emotion['score']:.2f})")