sapthesh commited on
Commit
d7a68f8
Β·
verified Β·
1 Parent(s): ccfaaf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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
- outputs = model(**inputs)
37
- # Get the logits and probabilities
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()