|
|
|
@ -22,10 +22,12 @@ from ppocr.utils.utility import initial_logger
|
|
|
|
|
logger = initial_logger()
|
|
|
|
|
from ppocr.utils.utility import get_image_file_list, check_and_read_gif
|
|
|
|
|
import cv2
|
|
|
|
|
from ppocr.data.det.sast_process import SASTProcessTest
|
|
|
|
|
from ppocr.data.det.east_process import EASTProcessTest
|
|
|
|
|
from ppocr.data.det.db_process import DBProcessTest
|
|
|
|
|
from ppocr.postprocess.db_postprocess import DBPostProcess
|
|
|
|
|
from ppocr.postprocess.east_postprocess import EASTPostPocess
|
|
|
|
|
from ppocr.postprocess.sast_postprocess import SASTPostProcess
|
|
|
|
|
import copy
|
|
|
|
|
import numpy as np
|
|
|
|
|
import math
|
|
|
|
@ -52,6 +54,14 @@ class TextDetector(object):
|
|
|
|
|
postprocess_params["cover_thresh"] = args.det_east_cover_thresh
|
|
|
|
|
postprocess_params["nms_thresh"] = args.det_east_nms_thresh
|
|
|
|
|
self.postprocess_op = EASTPostPocess(postprocess_params)
|
|
|
|
|
elif self.det_algorithm == "SAST":
|
|
|
|
|
self.preprocess_op = SASTProcessTest(preprocess_params)
|
|
|
|
|
postprocess_params["score_thresh"] = args.det_sast_score_thresh
|
|
|
|
|
postprocess_params["nms_thresh"] = args.det_sast_nms_thresh
|
|
|
|
|
postprocess_params["sample_pts_num"] = args.det_sast_sample_pts_num
|
|
|
|
|
postprocess_params["expand_scale"] = args.det_sast_expand_scale
|
|
|
|
|
postprocess_params["shrink_ratio_of_width"] = args.det_sast_shrink_ratio_of_width
|
|
|
|
|
self.postprocess_op = SASTPostProcess(postprocess_params)
|
|
|
|
|
else:
|
|
|
|
|
logger.info("unknown det_algorithm:{}".format(self.det_algorithm))
|
|
|
|
|
sys.exit(0)
|
|
|
|
@ -120,8 +130,14 @@ class TextDetector(object):
|
|
|
|
|
if self.det_algorithm == "EAST":
|
|
|
|
|
outs_dict['f_geo'] = outputs[0]
|
|
|
|
|
outs_dict['f_score'] = outputs[1]
|
|
|
|
|
elif self.det_algorithm == 'SAST':
|
|
|
|
|
outs_dict['f_border'] = outputs[0]
|
|
|
|
|
outs_dict['f_score'] = outputs[1]
|
|
|
|
|
outs_dict['f_tco'] = outputs[2]
|
|
|
|
|
outs_dict['f_tvo'] = outputs[3]
|
|
|
|
|
else:
|
|
|
|
|
outs_dict['maps'] = outputs[0]
|
|
|
|
|
|
|
|
|
|
dt_boxes_list = self.postprocess_op(outs_dict, [ratio_list])
|
|
|
|
|
dt_boxes = dt_boxes_list[0]
|
|
|
|
|
dt_boxes = self.filter_tag_det_res(dt_boxes, ori_im.shape)
|
|
|
|
|