Views
No views yet
albertosei/layoutlmv3-receipt-parser| Metric | Value |
|---|---|
| Final Validation Accuracy | 89.34% |
| Training Loss (Epoch 1) | 0.6824 |
| Training Loss (Epoch 2) | 0.3278 |
| Validation Accuracy (Epoch 1) | 83.49% |
| Number of Entity Labels | 51 |
vendor_name - Store/business namevendor_address - Physical addressvendor_phone_number - Contact numberdate - Transaction datetime - Transaction timereceipt_id - Receipt number/identifiercurrency - Currency typetotal_amount - Final totalsubtotal_amount - Subtotal before taxtax_amount - Tax amountservice_charge_amount - Service feesdiscount_amount - Discounts appliedtip_amount - Tip/gratuitycash_paid_amount - Cash paymentchange_amount - Change returnedcredit_card_amount - Credit card paymente_money_amount - Electronic paymentpayment_method - Payment typeline_item_name - Product/service nameline_item_quantity - Quantity purchasedline_item_unit_price - Price per unitline_item_total_price - Line item totalline_item_discount_amount - Item-level discountline_item_vat_status - VAT informationother - Miscellaneous information1from transformers import AutoProcessor, AutoModelForTokenClassification
2from PIL import Image
3import torch
4
5# Load model and processor
6processor = AutoProcessor.from_pretrained("albertosei/layoutlmv3-receipt-parser", apply_ocr=False)
7model = AutoModelForTokenClassification.from_pretrained("albertosei/layoutlmv3-receipt-parser")
8
9# Prepare inputs (requires external OCR for text and bounding boxes)
10image = Image.open("receipt.jpg").convert("RGB")
11words = ["STORE", "NAME", "Date:", "2024-01-01", "Total:", "25.99"] # From OCR
12boxes = [[0, 0, 100, 20], [100, 0, 200, 20], [0, 20, 50, 40],
13 [50, 20, 150, 40], [0, 40, 50, 60], [50, 40, 150, 60]] # From OCR
14
15# Process and predict
16encoding = processor(image, words, boxes=boxes, return_tensors="pt")
17with torch.no_grad():
18 outputs = model(**encoding)
19 predictions = outputs.logits.argmax(-1).squeeze().tolist()
20
21# Convert to labels
22predicted_labels = [model.config.id2label[pred] for pred in predictions]