Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -408,7 +408,9 @@ def analyze_contract_clauses(text):
|
|
408 |
]
|
409 |
chunks = [text[i:i+max_length] for i in range(0, len(text), step) if i+step < len(text)]
|
410 |
for chunk in chunks:
|
411 |
-
|
|
|
|
|
412 |
with torch.no_grad():
|
413 |
outputs = cuad_model(**inputs)
|
414 |
predictions = torch.sigmoid(outputs.start_logits).cpu().numpy()[0]
|
|
|
408 |
]
|
409 |
chunks = [text[i:i+max_length] for i in range(0, len(text), step) if i+step < len(text)]
|
410 |
for chunk in chunks:
|
411 |
+
# Move each tensor individually to the device
|
412 |
+
tokenized_inputs = cuad_tokenizer(chunk, return_tensors="pt", truncation=True, max_length=512)
|
413 |
+
inputs = {k: v.to(device) for k, v in tokenized_inputs.items()}
|
414 |
with torch.no_grad():
|
415 |
outputs = cuad_model(**inputs)
|
416 |
predictions = torch.sigmoid(outputs.start_logits).cpu().numpy()[0]
|