-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_ocr.py
More file actions
38 lines (32 loc) · 1.41 KB
/
Copy pathrun_ocr.py
File metadata and controls
38 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from paddleocr import PaddleOCR
ocr = PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False) # text detection + text recognition
# ocr = PaddleOCR(use_doc_orientation_classify=True, use_doc_unwarping=True) # text image preprocessing + text detection + textline orientation classification + text recognition
# ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False) # text detection + textline orientation classification + text recognition
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_mobile_det",
# text_recognition_model_name="PP-OCRv5_mobile_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False) # Switch to PP-OCRv5_mobile models
result = ocr.predict("./test3.jpeg")
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")
from paddleocr import TextDetection
from paddleocr import TextRecognition
model = TextDetection()
output = model.predict("test2.png")
for res in output:
res.print()
res.save_to_img(save_path="./outputDetection/")
res.save_to_json(save_path="./outputDetection/res.json")
model = TextRecognition()
output = model.predict(input="test2.png")
for res in output:
res.print()
res.save_to_img(save_path="./outputRecognition/")
res.save_to_json(save_path="./outputRecognition/res.json")