KevanSoon commited on
Commit
64b3bfb
·
1 Parent(s): 4589caf

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -86,17 +86,18 @@ atexit.register(close_model_managers)
86
 
87
  def inference(img, lang):
88
  ocr = model_managers[lang]
89
- result = ocr.infer(img, cls=True)[0]
90
-
91
- boxes = [line[0] for line in result] # Bounding box coordinates
92
- txts = [line[1][0] for line in result] # Extracted text
93
- scores = [line[1][1] for line in result] # Confidence scores
94
-
95
- return {
96
- "boxes": boxes,
97
- "texts": txts,
98
- "scores": scores
99
- }
 
100
 
101
 
102
  title = 'PaddleOCR'
 
86
 
87
  def inference(img, lang):
88
  ocr = model_managers[lang]
89
+ result = ocr.infer(img, cls=True)[0] # OCR results
90
+
91
+ output = []
92
+ for line in result:
93
+ box = line[0] # Bounding box coordinates
94
+ text = line[1][0] # Extracted text
95
+ output.append({
96
+ "text": text,
97
+ "box": box
98
+ })
99
+
100
+ return output
101
 
102
 
103
  title = 'PaddleOCR'