EasyCV/configs/ocr
yhq 397ecf2658
Feature/paddleocr inference (#148)
* add ocr model and convert weights from paddleocrv3
2022-09-28 14:03:16 +08:00
..
detection Feature/paddleocr inference (#148) 2022-09-28 14:03:16 +08:00
direction Feature/paddleocr inference (#148) 2022-09-28 14:03:16 +08:00
recognition Feature/paddleocr inference (#148) 2022-09-28 14:03:16 +08:00
README.md Feature/paddleocr inference (#148) 2022-09-28 14:03:16 +08:00

README.md

OCR algorithm

PP-OCRv3

We convert PaddleOCRv3 models to pytorch style, and provide end2end interface to recognize text in images, by simplely load exported models.

detection

We test on on icdar2015 dataset.

Algorithm backbone configs precison recall Hmean Download
DB MobileNetv3 det_model_en.py 0.7803 0.7250 0.7516 log-model
DB R50 det_model_en_r50.py 0.8622 0.8218 0.8415 log-model

recognition

We test on on DTRB dataset.

Algorithm backbone configs acc Download
SVTR MobileNetv1 rec_model_en.py 0.7536 log-model

predict

We provide exported models contain weights and process config for easyly predict, which convert from PaddleOCRv3.

detection model

language Download
chinese chinese_det.pth
english english_det.pth
multilingual multilingual_det.pth

recognition model

language Download
chiese chinese_rec.pth
english english_rec.pth
korean korean_rec.pth
japan japan_rec.pth
chinese_cht chinese_cht_rec.pth
Telugu te_rec.pth
Canada ka_rec.pth
Tamil ta_rec.pth
latin latin_rec.pth
cyrillic cyrillic_rec.pth
devanagari devanagari_rec.pth

direction model

language Download
direction.pth

usage

detection
import cv2
from easycv.predictors.ocr import OCRDetPredictor
predictor = OCRDetPredictor(model_path)
out = predictor([img_path]) # out = predictor([img])
img = cv2.imread(img_path)
out_img = predictor.show_result(out[0], img)
cv2.imwrite(out_img_path,out_img)

det_result

recognition
import cv2
from easycv.predictors.ocr import OCRRecPredictor
predictor = OCRRecPredictor(model_path)
out = predictor([img_path])
print(out)

rec_input
rec_putput

end2end
import cv2
from easycv.predictors.ocr import OCRPredictor
! wget http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/ocr/simfang.ttf
! wget http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/ocr/ocr_det.jpg
predictor = OCRPredictor(
    det_model_path=path_to_detmodel,
    rec_model_path=path_to_recmodel,
    cls_model_path=path_to_clsmodel,
    use_angle_cls=True)
filter_boxes, filter_rec_res = predictor(img_path)
img = cv2.imread('ocr_det.jpg')
out_img = predictor.show(
    filter_boxes[0],
    filter_rec_res[0],
    img,
    font_path='simfang.ttf')
cv2.imwrite('out_img.jpg', out_img)

There are some ocr results.
ocr_result1 ocr_result2