Update README.md
Browse files
README.md
CHANGED
@@ -12,4 +12,27 @@ widget:
|
|
12 |
- src: https://templates.invoicehome.com/invoice-template-us-neat-750px.png
|
13 |
example_title: invoice
|
14 |
|
15 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
- src: https://templates.invoicehome.com/invoice-template-us-neat-750px.png
|
13 |
example_title: invoice
|
14 |
|
15 |
+
---
|
16 |
+
|
17 |
+
**InvoiceReceiptClassifier_LayoutLMv3** is a fine-tuned LayoutLMv3 model that classifies a document to an invoice or receipt.
|
18 |
+
## Quick start: using the raw model
|
19 |
+
```python
|
20 |
+
from transformers import (
|
21 |
+
AutoModelForSequenceClassification,
|
22 |
+
AutoProcessor,
|
23 |
+
)
|
24 |
+
from PIL import Image
|
25 |
+
from urllib.request import urlopen
|
26 |
+
model = AutoModelForSequenceClassification.from_pretrained("fedihch/InvoiceReceiptClassifier_LayoutLMv3")
|
27 |
+
processor = AutoProcessor.from_pretrained("fedihch/InvoiceReceiptClassifier_LayoutLMv3")
|
28 |
+
input_img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/ReceiptSwiss.jpg/1024px-ReceiptSwiss.jpg"
|
29 |
+
with urlopen(input_img_url) as testImage:
|
30 |
+
input_img = Image.open(testImage).convert("RGB")
|
31 |
+
|
32 |
+
encoded_inputs = processor(input_img, padding="max_length", return_tensors="pt")
|
33 |
+
outputs = model(**encoded_inputs)
|
34 |
+
logits = outputs.logits
|
35 |
+
predicted_class_idx = logits.argmax(-1).item()
|
36 |
+
id2label = {0: "invoice", 1: "receipt"}
|
37 |
+
print(id2label[predicted_class_idx])
|
38 |
+
```
|