Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -54,9 +54,9 @@ EXPLANATIONS = {
|
|
54 |
def custom_sentiment(text):
|
55 |
inputs = sentiment_tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
56 |
with torch.no_grad():
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
label_map = {0: "supportive", 1: "undermining"}
|
62 |
label = label_map[label_idx]
|
|
|
54 |
def custom_sentiment(text):
|
55 |
inputs = sentiment_tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
56 |
with torch.no_grad():
|
57 |
+
outputs = sentiment_model(**inputs)
|
58 |
+
probs = torch.nn.functional.softmax(outputs.logits, dim=1)
|
59 |
+
label_idx = torch.argmax(probs).item()
|
60 |
|
61 |
label_map = {0: "supportive", 1: "undermining"}
|
62 |
label = label_map[label_idx]
|