marufahmed commited on
Commit
3eb6200
·
1 Parent(s): 26f7d7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -19,32 +19,32 @@ from PIL import Image, ImageDraw, ImageFont
19
 
20
 
21
  processor = AutoProcessor.from_pretrained("microsoft/layoutlmv3-base", apply_ocr=True)
22
- model = AutoModelForTokenClassification.from_pretrained("Theivaprakasham/layoutlmv3-finetuned-invoice")
23
 
24
 
25
 
26
  # load image example
27
- dataset = load_dataset("darentang/generated", split="test")
28
- Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
29
- Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
30
- Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
31
  # define id2label, label2color
32
  labels = dataset.features['ner_tags'].feature.names
33
  id2label = {v: k for v, k in enumerate(labels)}
34
- label2color = {
35
- "B-ABN": 'blue',
36
- "B-BILLER": 'blue',
37
- "B-BILLER_ADDRESS": 'green',
38
- "B-BILLER_POST_CODE": 'orange',
39
- "B-DUE_DATE": "blue",
40
- "B-GST": 'green',
41
- "B-INVOICE_DATE": 'violet',
42
- "B-INVOICE_NUMBER": 'orange',
43
- "B-SUBTOTAL": 'green',
44
- "B-TOTAL": 'blue',
45
- "I-BILLER_ADDRESS": 'blue',
46
- "O": 'orange'
47
- }
48
 
49
  def unnormalize_box(bbox, width, height):
50
  return [
@@ -92,11 +92,11 @@ def process_image(image):
92
  return image
93
 
94
 
95
- title = "Official Document Layout Scanner for a2i competition"
96
- description = "This is a web app for scanning official documents that will extract the layout from the documents automatically."
97
 
98
 
99
- examples =[['example1.png'],['example2.png'],['example3.png']]
100
 
101
  css = """.output_image, .input_image {height: 600px !important}"""
102
 
 
19
 
20
 
21
  processor = AutoProcessor.from_pretrained("microsoft/layoutlmv3-base", apply_ocr=True)
22
+ model = AutoModelForTokenClassification.from_pretrained("microsoft/layoutlmv3-base")
23
 
24
 
25
 
26
  # load image example
27
+ # dataset = load_dataset("darentang/generated", split="test")
28
+ # Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
29
+ # Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
30
+ # Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
31
  # define id2label, label2color
32
  labels = dataset.features['ner_tags'].feature.names
33
  id2label = {v: k for v, k in enumerate(labels)}
34
+ # label2color = {
35
+ # "B-ABN": 'blue',
36
+ # "B-BILLER": 'blue',
37
+ # "B-BILLER_ADDRESS": 'green',
38
+ # "B-BILLER_POST_CODE": 'orange',
39
+ # "B-DUE_DATE": "blue",
40
+ # "B-GST": 'green',
41
+ # "B-INVOICE_DATE": 'violet',
42
+ # "B-INVOICE_NUMBER": 'orange',
43
+ # "B-SUBTOTAL": 'green',
44
+ # "B-TOTAL": 'blue',
45
+ # "I-BILLER_ADDRESS": 'blue',
46
+ # "O": 'orange'
47
+ # }
48
 
49
  def unnormalize_box(bbox, width, height):
50
  return [
 
92
  return image
93
 
94
 
95
+ title = "Demonstration of LayoutLmv3 for Document Layout Analysis"
96
+ description = "Demo of Microsoft's LayoutLMv3 Document Foundation Model"
97
 
98
 
99
+ #examples =[['example1.png'],['example2.png'],['example3.png']]
100
 
101
  css = """.output_image, .input_image {height: 600px !important}"""
102