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