Alealejandrooo commited on
Commit
922a160
1 Parent(s): c2f1ab5

Fixing the dimensions in extract_detected_entries_pdl()

Browse files

Here there was an error with the dimensions returned:

txt shape: (7,) type: <class 'str'>
scores shape: (7,) type: <class 'float'>
boxes shape: (7, 4, 2) type: <class 'tuple'>

Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -143,21 +143,16 @@ def extract_detected_entries_pdl(image):
143
  """
144
  # run the OCR
145
  result = ocr.ocr(image)
146
- # creates the Pandas dataframe
147
  txt = []
148
  scores = []
149
  boxes = []
150
  for r in result[0]:
151
- txt.append(cleanString_basic(r[-1][0]))
152
- scores.append(r[-1][1])
153
- boxes.append(r[0])
154
-
155
- # Debugging: Print shapes and types of txt, scores, and boxes
156
- print("txt shape:", np.shape(txt), "type:", type(txt[0]))
157
- print("scores shape:", np.shape(scores), "type:", type(scores[0]))
158
- print("boxes shape:", np.shape(boxes), "type:", type(boxes[0]))
159
-
160
- return pd.DataFrame(np.transpose([txt, scores, boxes]),columns = ["Text","Score", "Boundary Box"])
161
 
162
  def cleanString_basic(word):
163
  word = word.replace("$", "s")
 
143
  """
144
  # run the OCR
145
  result = ocr.ocr(image)
146
+ # creates Pandas Dataframe
147
  txt = []
148
  scores = []
149
  boxes = []
150
  for r in result[0]:
151
+ txt.append(cleanString_basic(r[-1][0]))
152
+ scores.append(r[-1][1])
153
+ boxes.append(tuple(map(tuple, r[0])))
154
+
155
+ return pd.DataFrame({"Text": txt, "Score": scores, "Boundary Box": boxes})
 
 
 
 
 
156
 
157
  def cleanString_basic(word):
158
  word = word.replace("$", "s")