def __init__(self, args):
        max_side_len = args.det_max_side_len
        self.det_algorithm = args.det_algorithm
        preprocess_params = {'max_side_len': max_side_len}
        postprocess_params = {}
        if self.det_algorithm == "DB":
            self.preprocess_op = DBProcessTest(preprocess_params)
            postprocess_params["thresh"] = args.det_db_thresh
            postprocess_params["box_thresh"] = args.det_db_box_thresh
            postprocess_params["max_candidates"] = 1000
            postprocess_params["unclip_ratio"] = args.det_db_unclip_ratio
            self.postprocess_op = DBPostProcess(postprocess_params)
        elif self.det_algorithm == "EAST":
            self.preprocess_op = EASTProcessTest(preprocess_params)
            postprocess_params["score_thresh"] = args.det_east_score_thresh
            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)

        self.predictor, self.input_tensor, self.output_tensors =\
            utility.create_predictor(args, mode="det")
示例#2
0
 def __init__(self, args):
     max_side_len = args.det_max_side_len
     self.det_algorithm = args.det_algorithm
     preprocess_params = {
         'test_image_shape': [640, 640],
         'max_side_len': max_side_len
     }
     postprocess_params = {}
     if self.det_algorithm == "DB":
         self.preprocess_op = DBProcessTest(preprocess_params)
         postprocess_params["thresh"] = args.det_db_thresh
         postprocess_params["box_thresh"] = args.det_db_box_thresh
         postprocess_params["max_candidates"] = 1000
         postprocess_params["unclip_ratio"] = args.det_db_unclip_ratio
         self.postprocess_op = DBPostProcess(postprocess_params)
     elif self.det_algorithm == "EAST":
         self.preprocess_op = EASTProcessTest(preprocess_params)
         postprocess_params["score_thresh"] = args.det_east_score_thresh
         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
         self.det_sast_polygon = args.det_sast_polygon
         if self.det_sast_polygon:
             postprocess_params["sample_pts_num"] = 6
             postprocess_params["expand_scale"] = 1.2
             postprocess_params["shrink_ratio_of_width"] = 0.2
         else:
             postprocess_params["sample_pts_num"] = 2
             postprocess_params["expand_scale"] = 1.0
             postprocess_params["shrink_ratio_of_width"] = 0.3
         self.postprocess_op = SASTPostProcess(postprocess_params)
     else:
         logger.info("unknown det_algorithm:{}".format(self.det_algorithm))
         sys.exit(0)
     if args.use_pdserving is False:
         self.use_zero_copy_run = args.use_zero_copy_run
         self.predictor, self.input_tensor, self.output_tensors =\
             utility.create_predictor(args, mode="det")