Mhassanen commited on
Commit
fa69787
·
verified ·
1 Parent(s): 31fe8a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -18,7 +18,11 @@ def extract_text_from_pdf(file_path):
18
 
19
  def predict_class(text):
20
  try:
21
- inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
 
 
 
 
22
  with torch.no_grad():
23
  outputs = model(**inputs)
24
  logits = outputs.logits
 
18
 
19
  def predict_class(text):
20
  try:
21
+ # Truncate text to maximum length of 4096 tokens
22
+ max_length = 4096
23
+ truncated_text = text[:max_length]
24
+
25
+ inputs = tokenizer(truncated_text, return_tensors="pt", padding=True, truncation=True, max_length=max_length)
26
  with torch.no_grad():
27
  outputs = model(**inputs)
28
  logits = outputs.logits