Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,11 +31,10 @@ else:
|
|
| 31 |
def classify_text(text):
|
| 32 |
try:
|
| 33 |
# Tokenize the input text
|
| 34 |
-
inputs = tokenizer(text, return_tensors="pt")
|
| 35 |
# Pass the inputs to the model
|
| 36 |
-
|
| 37 |
-
# Get the
|
| 38 |
-
logits = outputs.logits
|
| 39 |
probabilities = torch.softmax(logits, dim=-1).tolist()[0]
|
| 40 |
# Get the predicted class
|
| 41 |
predicted_class = torch.argmax(logits, dim=-1).item()
|
|
|
|
| 31 |
def classify_text(text):
|
| 32 |
try:
|
| 33 |
# Tokenize the input text
|
| 34 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 35 |
# Pass the inputs to the model
|
| 36 |
+
logits = model(**inputs)
|
| 37 |
+
# Get the probabilities
|
|
|
|
| 38 |
probabilities = torch.softmax(logits, dim=-1).tolist()[0]
|
| 39 |
# Get the predicted class
|
| 40 |
predicted_class = torch.argmax(logits, dim=-1).item()
|