mp-02 commited on
Commit
4064ff6
1 Parent(s): 8e43b0e

Update sroie_inference.py

Browse files
Files changed (1) hide show
  1. sroie_inference.py +8 -13
sroie_inference.py CHANGED
@@ -71,24 +71,16 @@ def prediction(image):
71
  true_words = true_words[1:-1]
72
  true_confidence_scores = true_confidence_scores[1:-1]
73
 
74
- preds = []
75
- l_words = []
76
- bboxes = []
77
-
78
- for i, j in enumerate(true_predictions):
79
- if true_confidence_scores[i] < 0.9: #####################################àà
80
  true_predictions[i] = "O"
81
- preds.append(true_predictions[i])
82
- l_words.append(true_words[i])
83
- bboxes.append(true_boxes[i])
84
 
85
  d = {}
86
- for id, i in enumerate(preds):
87
  if i not in d.keys():
88
- d[i] = l_words[id]
89
  else:
90
- d[i] = d[i] + ", " + l_words[id]
91
-
92
  d = {k: v.strip() for (k, v) in d.items()}
93
 
94
  keys_to_pop = []
@@ -101,6 +93,9 @@ def prediction(image):
101
  if "B-TOTAL" in d: d.pop("B-TOTAL")
102
  for k in keys_to_pop: d.pop(k)
103
 
 
 
 
104
  blur_boxes = []
105
  for prediction, box in zip(preds, bboxes):
106
  if prediction != 'O' and prediction[2:] != 'TOTAL':
 
71
  true_words = true_words[1:-1]
72
  true_confidence_scores = true_confidence_scores[1:-1]
73
 
74
+ for i, j in enumerate(true_confidence_scores):
75
+ if j < 0.9 or : #####################################
 
 
 
 
76
  true_predictions[i] = "O"
 
 
 
77
 
78
  d = {}
79
+ for id, i in enumerate(true_predictions):
80
  if i not in d.keys():
81
+ d[i] = true_words[d]
82
  else:
83
+ d[i] = d[i] + ", " + true_words[id]
 
84
  d = {k: v.strip() for (k, v) in d.items()}
85
 
86
  keys_to_pop = []
 
93
  if "B-TOTAL" in d: d.pop("B-TOTAL")
94
  for k in keys_to_pop: d.pop(k)
95
 
96
+ for k in d.keys():
97
+ k = k[2:]
98
+
99
  blur_boxes = []
100
  for prediction, box in zip(preds, bboxes):
101
  if prediction != 'O' and prediction[2:] != 'TOTAL':