alitavanaali commited on
Commit
67e7382
1 Parent(s): 911803a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -32,7 +32,7 @@ from datasets import Features, Sequence, ClassLabel, Value, Array2D, Array3D
32
  from transformers import LayoutLMv3ForTokenClassification,LayoutLMv3FeatureExtractor
33
 
34
  # define id2label
35
- id2label={0: 'container id', 1: 'seal number', 2: 'container quantity', 3: 'container type', 4: 'tare', 5: 'package quantity', 6: 'weight', 7: 'others'}
36
  custom_config = r'--oem 3 --psm 6'
37
  # lang='eng+deu+ita+chi_sim'
38
  lang='spa'
@@ -62,19 +62,19 @@ def unnormalize_box(bbox, width, height):
62
 
63
  def iob_to_label(label):
64
  if label == 0:
65
- return 'container id'
66
  if label == 1:
67
- return 'seal number'
68
  if label == 2:
69
- return 'container quantity'
70
  if label == 3:
71
- return 'container type'
72
  if label == 4:
73
- return 'tare'
74
  if label == 5:
75
- return 'package quantity'
76
  if label == 6:
77
- return 'weight'
78
  if label == 7:
79
  return 'others'
80
 
@@ -176,9 +176,10 @@ def visualize_image(final_bbox, final_preds, l_words, image):
176
  draw = ImageDraw.Draw(image)
177
  font = ImageFont.load_default()
178
 
179
- label2color = {'container id':'red', 'seal number':'blue', 'container quantity':'black', 'container type':'green', 'tare':'brown', 'package quantity':'purple', 'weight':'orange', 'others': 'white'}
180
- l2l = {'container id':'red', 'seal number':'blue', 'container quantity':'black', 'container type':'green', 'tare':'brown', 'package quantity':'purple', 'weight':'orange', 'others': 'white'}
181
- f_labels = {'container id':'red', 'seal number':'blue', 'container quantity':'black', 'container type':'green', 'tare':'brown', 'package quantity':'purple', 'weight':'orange', 'others': 'white'}
 
182
 
183
  json_df = []
184
 
 
32
  from transformers import LayoutLMv3ForTokenClassification,LayoutLMv3FeatureExtractor
33
 
34
  # define id2label
35
+ id2label = {0: 'song name', 1: 'artist', 2: 'year', 3: 'album', 4: 'genres', 5: 'song writer', 6: 'lyrics', 7: 'others'}
36
  custom_config = r'--oem 3 --psm 6'
37
  # lang='eng+deu+ita+chi_sim'
38
  lang='spa'
 
62
 
63
  def iob_to_label(label):
64
  if label == 0:
65
+ return 'song name'
66
  if label == 1:
67
+ return 'artist'
68
  if label == 2:
69
+ return 'year'
70
  if label == 3:
71
+ return 'album'
72
  if label == 4:
73
+ return 'genres'
74
  if label == 5:
75
+ return 'song writer'
76
  if label == 6:
77
+ return 'lyrics'
78
  if label == 7:
79
  return 'others'
80
 
 
176
  draw = ImageDraw.Draw(image)
177
  font = ImageFont.load_default()
178
 
179
+ label2color = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue', 'lyrics':'purple', 'others': 'white'}
180
+ l2l = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue','lyrics':'purple', 'others':'white'}
181
+ f_labels = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue','lyrics':'purple', 'others':'white'}
182
+
183
 
184
  json_df = []
185