Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -41,14 +41,13 @@ model = AutoModelForSequenceClassification.from_pretrained(modelPath)
|
|
41 |
# RoBERTA: [0]: neutral, [1]: toxic
|
42 |
encoding = tokenizer.encode(txt, return_tensors='pt')
|
43 |
result = model(encoding)
|
44 |
-
|
45 |
-
result
|
46 |
-
if (result.logits.size(dim=1) >= 2):
|
47 |
-
pad = (0, 1)
|
48 |
-
result = nn.functional.pad(result, pad, "constant", 0)
|
49 |
result
|
50 |
|
51 |
# transform logit to get probabilities
|
|
|
|
|
|
|
|
|
52 |
prediction = nn.functional.softmax(result.logits, dim=-1)
|
53 |
prediction
|
54 |
#neutralProb = prediction.data[0][neutralIndex]
|
|
|
41 |
# RoBERTA: [0]: neutral, [1]: toxic
|
42 |
encoding = tokenizer.encode(txt, return_tensors='pt')
|
43 |
result = model(encoding)
|
|
|
|
|
|
|
|
|
|
|
44 |
result
|
45 |
|
46 |
# transform logit to get probabilities
|
47 |
+
if (result.logits.size(dim=1) < 2):
|
48 |
+
pad = (0, 1)
|
49 |
+
result = nn.functional.pad(result, pad, "constant", 0)
|
50 |
+
prediction = nn.functional.softmax(result, dim=-1)
|
51 |
prediction = nn.functional.softmax(result.logits, dim=-1)
|
52 |
prediction
|
53 |
#neutralProb = prediction.data[0][neutralIndex]
|