Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,13 @@ processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
|
| 8 |
model = LayoutLMv3ForQuestionAnswering.from_pretrained("microsoft/layoutlmv3-base")
|
| 9 |
|
| 10 |
def process_question(question, document):
|
| 11 |
-
print(f"Debug - Processing Question: {question}")
|
| 12 |
|
| 13 |
encoding = processor(document, question, return_tensors="pt")
|
| 14 |
-
print(f"Debug - Encoding Input IDs: {encoding.input_ids}")
|
| 15 |
|
| 16 |
outputs = model(**encoding)
|
| 17 |
-
print(f"Debug - Model Outputs: {outputs}")
|
| 18 |
|
| 19 |
predicted_start_idx = outputs.start_logits.argmax(-1).item()
|
| 20 |
predicted_end_idx = outputs.end_logits.argmax(-1).item()
|
|
@@ -88,7 +88,7 @@ def parse_ticket_image(image, question):
|
|
| 88 |
|
| 89 |
|
| 90 |
ticket_number = answers["What is the ticket number?"]
|
| 91 |
-
grain_type = answers["What is the type of grain (For example: corn,
|
| 92 |
date = answers["What is the date?"]
|
| 93 |
time = answers["What is the time?"]
|
| 94 |
gross_weight = answers["What is the gross weight?"]
|
|
|
|
| 8 |
model = LayoutLMv3ForQuestionAnswering.from_pretrained("microsoft/layoutlmv3-base")
|
| 9 |
|
| 10 |
def process_question(question, document):
|
| 11 |
+
#print(f"Debug - Processing Question: {question}")
|
| 12 |
|
| 13 |
encoding = processor(document, question, return_tensors="pt")
|
| 14 |
+
#print(f"Debug - Encoding Input IDs: {encoding.input_ids}")
|
| 15 |
|
| 16 |
outputs = model(**encoding)
|
| 17 |
+
#print(f"Debug - Model Outputs: {outputs}")
|
| 18 |
|
| 19 |
predicted_start_idx = outputs.start_logits.argmax(-1).item()
|
| 20 |
predicted_end_idx = outputs.end_logits.argmax(-1).item()
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
ticket_number = answers["What is the ticket number?"]
|
| 91 |
+
grain_type = answers["What is the type of grain (For example: corn, soybeans, wheat)?"]
|
| 92 |
date = answers["What is the date?"]
|
| 93 |
time = answers["What is the time?"]
|
| 94 |
gross_weight = answers["What is the gross weight?"]
|