SickBoy commited on
Commit
86eee17
1 Parent(s): bd490f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -16
app.py CHANGED
@@ -30,22 +30,31 @@ Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
30
  Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
31
  Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
32
  # define id2label, label2color
33
- labels = dataset.features['ner_tags'].feature.names
34
- id2label = {v: k for v, k in enumerate(labels)}
35
- label2color = {
36
- "B-ABN": 'blue',
37
- "B-BILLER": 'blue',
38
- "B-BILLER_ADDRESS": 'green',
39
- "B-BILLER_POST_CODE": 'orange',
40
- "B-DUE_DATE": "blue",
41
- "B-GST": 'green',
42
- "B-INVOICE_DATE": 'violet',
43
- "B-INVOICE_NUMBER": 'orange',
44
- "B-SUBTOTAL": 'green',
45
- "B-TOTAL": 'blue',
46
- "I-BILLER_ADDRESS": 'blue',
47
- "O": 'orange'
48
- }
 
 
 
 
 
 
 
 
 
49
 
50
  def unnormalize_box(bbox, width, height):
51
  return [
 
30
  Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
31
  Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
32
  # define id2label, label2color
33
+ #labels = dataset.features['ner_tags'].feature.names
34
+ labels = ['O', 'HEADER', 'SUBHEADER', 'TEXTO', 'NUMERAL', 'RESUMEN']
35
+ #id2label = {v: k for v, k in enumerate(labels)}
36
+ id2label = {0: 'O', 1: 'HEADER', 2: 'SUBHEADER', 3: 'TEXTO', 4: 'NUMERAL', 5: 'RESUMEN'}
37
+ label2color = {'O': 'violet',
38
+ 'HEADER': 'orange',
39
+ 'SUBHEADER': 'blue',
40
+ 'TEXTO': 'green',
41
+ 'NUMERAL': 'yellow',
42
+ 'RESUMEN': 'black',}
43
+
44
+ #label2color = {
45
+ # "B-ABN": 'blue',
46
+ # "B-BILLER": 'blue',
47
+ # "B-BILLER_ADDRESS": 'green',
48
+ # "B-BILLER_POST_CODE": 'orange',
49
+ # "B-DUE_DATE": "blue",
50
+ # "B-GST": 'green',
51
+ # "B-INVOICE_DATE": 'violet',
52
+ # "B-INVOICE_NUMBER": 'orange',
53
+ # "B-SUBTOTAL": 'green',
54
+ # "B-TOTAL": 'blue',
55
+ # "I-BILLER_ADDRESS": 'blue',
56
+ # "O": 'orange'
57
+ # }
58
 
59
  def unnormalize_box(bbox, width, height):
60
  return [