Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def get_top_emojis(text, top_n=TOP_N):
|
|
21 |
preprocessed = preprocess(text)
|
22 |
inputs = tokenizer(preprocessed, return_tensors="pt")
|
23 |
preds = model(**inputs).logits
|
24 |
-
scores = torch.nn.functional.softmax(preds,
|
25 |
ranking = np.argsort(scores)
|
26 |
ranking = ranking[::-1][:top_n]
|
27 |
emojis = [model.config.id2label[index] for index in ranking]
|
|
|
21 |
preprocessed = preprocess(text)
|
22 |
inputs = tokenizer(preprocessed, return_tensors="pt")
|
23 |
preds = model(**inputs).logits
|
24 |
+
scores = torch.nn.functional.softmax(preds, dim=-1).detach().numpy()
|
25 |
ranking = np.argsort(scores)
|
26 |
ranking = ranking[::-1][:top_n]
|
27 |
emojis = [model.config.id2label[index] for index in ranking]
|