ngupta2026 commited on
Commit
330791f
·
verified ·
1 Parent(s): 24caea8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -8,15 +8,11 @@ from transformers import LayoutLMTokenizerFast, LayoutLMForTokenClassification
8
  label2id = {"O":0, "COMPANY":1, "DATE":2, "TOTAL":3}
9
  id2label = {v:k for k,v in label2id.items()}
10
 
11
- # MODEL
12
- model = LayoutLMForTokenClassification.from_pretrained(
13
- "microsoft/layoutlm-base-uncased",
14
- num_labels=4
15
- )
16
 
17
- tokenizer = LayoutLMTokenizerFast.from_pretrained(
18
- "microsoft/layoutlm-base-uncased"
19
- )
20
 
21
  # NORMALIZE
22
  def normalize(box, width, height):
@@ -53,7 +49,8 @@ def process(image):
53
  return_tensors="pt",
54
  padding="max_length",
55
  truncation=True,
56
- is_split_into_words=True
 
57
  )
58
 
59
  with torch.no_grad():
 
8
  label2id = {"O":0, "COMPANY":1, "DATE":2, "TOTAL":3}
9
  id2label = {v:k for k,v in label2id.items()}
10
 
11
+ # ✅ USE YOUR MODEL
12
+ MODEL_NAME = "YOUR_USERNAME/sroie-layoutlm"
 
 
 
13
 
14
+ model = LayoutLMForTokenClassification.from_pretrained(MODEL_NAME)
15
+ tokenizer = LayoutLMTokenizerFast.from_pretrained(MODEL_NAME)
 
16
 
17
  # NORMALIZE
18
  def normalize(box, width, height):
 
49
  return_tensors="pt",
50
  padding="max_length",
51
  truncation=True,
52
+ is_split_into_words=True,
53
+ max_length=128
54
  )
55
 
56
  with torch.no_grad():