File size: 465 Bytes
c31051c
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
from transformers import AutoModel

if __name__ == "__main__":
    tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
    model = AutoModel.from_pretrained("sabersol/bert-base-uncased-emotion")
    pred = transformers.pipeline("text-classification", model=model, tokenizer=tokenizer, device=0, return_all_scores=True)
   
    example = "The music I am listening to is so energetic and makes me motivated."
    results = pred(example)
    print(results)