wai572 commited on
Commit
8a714a9
·
1 Parent(s): 8c9c5d9
Files changed (1) hide show
  1. main.py +2 -2
main.py CHANGED
@@ -210,7 +210,7 @@ async def analyze_image(image_paths: list[UploadFile]):
210
  text_mask = get_not_white_mask(img)
211
  masked_img = cv2.bitwise_and(img, img, mask=text_mask)
212
  # result = reader.readtext(candidate["img"])
213
- result = reader.ocr(masked_img, det=False)
214
  print(result)
215
  if len(result) > 0:
216
  ocr_results.append(result)
@@ -232,7 +232,7 @@ async def analyze_image(image_paths: list[UploadFile]):
232
  # reds = []
233
  for i, result in enumerate(ocr_results):
234
  # text = result[0]["generated_text"].upper().strip()
235
- text = result[0].get("rec_texts", [])
236
  if text:
237
  text = text[0]
238
  print(text, is_text_valid(text))
 
210
  text_mask = get_not_white_mask(img)
211
  masked_img = cv2.bitwise_and(img, img, mask=text_mask)
212
  # result = reader.readtext(candidate["img"])
213
+ result = reader.recognize([masked_img])
214
  print(result)
215
  if len(result) > 0:
216
  ocr_results.append(result)
 
232
  # reds = []
233
  for i, result in enumerate(ocr_results):
234
  # text = result[0]["generated_text"].upper().strip()
235
+ text = result[0][0]
236
  if text:
237
  text = text[0]
238
  print(text, is_text_valid(text))