MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / recognize

Function recognize

ocr-ml-viewer/backend/ocr/recognizer.py:7–21  ·  view source on GitHub ↗

Process a PIL image.

(img)

Source from the content-addressed store, hash-verified

5
6
7def recognize(img):
8 """Process a PIL image."""
9 img_arr = np.array(img)
10 result = ocr.ocr(img_arr, cls=True)
11
12 if result is not None and len(result) > 0:
13 boxes = [line[0] for line in result]
14 txts = [line[1][0] for line in result]
15 scores = [line[1][1] for line in result]
16 processed_img = draw_ocr(
17 img, boxes, txts, scores, font_path="./fonts/simfang.ttf"
18 )
19 return result, processed_img
20
21 return result, ""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected