phamnam commited on
Commit
47a4e45
·
verified ·
1 Parent(s): 1e86052

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -40,13 +40,14 @@ async def create_upload_file(
40
  ocr = get_ocr(lang=lang, use_gpu=use_gpu)
41
  img2np = np.array(image)
42
  result = ocr.ocr(img2np, cls=True)[0]
43
-
44
- boxes = [line[0] for line in result]
45
- txts = [line[1][0] for line in result]
46
- scores = [line[1][1] for line in result]
47
-
48
- # 识别结果
49
- final_result = [dict(boxes=box, txt=txt, score=score) for box, txt, score in zip(boxes, txts, scores)]
 
50
  return final_result
51
 
52
 
 
40
  ocr = get_ocr(lang=lang, use_gpu=use_gpu)
41
  img2np = np.array(image)
42
  result = ocr.ocr(img2np, cls=True)[0]
43
+ final_result = []
44
+ if result:
45
+ boxes = [line[0] for line in result]
46
+ txts = [line[1][0] for line in result]
47
+ scores = [line[1][1] for line in result]
48
+
49
+ # 识别结果
50
+ final_result = [dict(boxes=box, txt=txt, score=score) for box, txt, score in zip(boxes, txts, scores)]
51
  return final_result
52
 
53