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.
recognition
We test on on DTRB dataset.
predict
We provide exported models contain weights and process config for easyly predict, which convert from PaddleOCRv3.
detection model
recognition model
direction model
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)

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


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.
