diff --git a/configs/rec/multi_language/rec_en_number_lite_train.yml b/configs/rec/multi_language/rec_en_number_lite_train.yml index 70d825e61ab48029382426b0ec56b4a1a4ac439d..cee0512114fe9d488004a71cf6f0a0409822a4b5 100644 --- a/configs/rec/multi_language/rec_en_number_lite_train.yml +++ b/configs/rec/multi_language/rec_en_number_lite_train.yml @@ -1,5 +1,5 @@ Global: - use_gpu: true + use_gpu: True epoch_num: 500 log_smooth_window: 20 print_batch_step: 10 @@ -15,7 +15,7 @@ Global: use_visualdl: False infer_img: # for data or label process - character_dict_path: ppocr/utils/dict/ic15_dict.txt + character_dict_path: ppocr/utils/dict/en_dict.txt character_type: ch max_text_length: 25 infer_mode: False diff --git a/configs/rec/multi_language/rec_french_lite_train.yml b/configs/rec/multi_language/rec_french_lite_train.yml index 0e8f4eb3a803e8958cf38f0b55fca25e7204bd9c..63378d38a0d31fc77c33173e0ed864f28c5c3a8b 100644 --- a/configs/rec/multi_language/rec_french_lite_train.yml +++ b/configs/rec/multi_language/rec_french_lite_train.yml @@ -1,5 +1,5 @@ Global: - use_gpu: true + use_gpu: True epoch_num: 500 log_smooth_window: 20 print_batch_step: 10 @@ -9,9 +9,9 @@ Global: eval_batch_step: [0, 2000] # if pretrained_model is saved in static mode, load_static_weights must set to True cal_metric_during_train: True - pretrained_model: + pretrained_model: checkpoints: - save_inference_dir: + save_inference_dir: use_visualdl: False infer_img: # for data or label process @@ -19,7 +19,7 @@ Global: character_type: french max_text_length: 25 infer_mode: False - use_space_char: True + use_space_char: False Optimizer: diff --git a/configs/rec/multi_language/rec_german_lite_train.yml b/configs/rec/multi_language/rec_german_lite_train.yml index 9978a21e1e8c70e44e6fd670eca305d045a919e9..1651510c5e4597e82298135d2f6c64aa747cf961 100644 --- a/configs/rec/multi_language/rec_german_lite_train.yml +++ b/configs/rec/multi_language/rec_german_lite_train.yml @@ -1,5 +1,5 @@ Global: - use_gpu: true + use_gpu: True epoch_num: 500 log_smooth_window: 20 print_batch_step: 10 @@ -19,7 +19,7 @@ Global: character_type: german max_text_length: 25 infer_mode: False - use_space_char: True + use_space_char: False Optimizer: diff --git a/configs/rec/multi_language/rec_japan_lite_train.yml b/configs/rec/multi_language/rec_japan_lite_train.yml index 938d377e5d6497bea72fa27b0adcd3d0d691d431..bb47584edbc70f68d8d2d89dced3ec9b12f0e1cb 100644 --- a/configs/rec/multi_language/rec_japan_lite_train.yml +++ b/configs/rec/multi_language/rec_japan_lite_train.yml @@ -1,5 +1,5 @@ Global: - use_gpu: true + use_gpu: True epoch_num: 500 log_smooth_window: 20 print_batch_step: 10 @@ -19,7 +19,7 @@ Global: character_type: japan max_text_length: 25 infer_mode: False - use_space_char: True + use_space_char: False Optimizer: diff --git a/configs/rec/multi_language/rec_korean_lite_train.yml b/configs/rec/multi_language/rec_korean_lite_train.yml index 7b070c449e9511e353b05877eaf217d0b286b47f..77f15524f78cd7f1c3dcf4988960e718422f5d89 100644 --- a/configs/rec/multi_language/rec_korean_lite_train.yml +++ b/configs/rec/multi_language/rec_korean_lite_train.yml @@ -1,5 +1,5 @@ Global: - use_gpu: true + use_gpu: True epoch_num: 500 log_smooth_window: 20 print_batch_step: 10 @@ -19,7 +19,7 @@ Global: character_type: korean max_text_length: 25 infer_mode: False - use_space_char: True + use_space_char: False Optimizer: diff --git a/deploy/cpp_infer/src/ocr_cls.cpp b/deploy/cpp_infer/src/ocr_cls.cpp index 40debaa7835d3174627f8b0528abba673c6e3d86..2c85712b4714154912401133ed24db10f3e4aafe 100644 --- a/deploy/cpp_infer/src/ocr_cls.cpp +++ b/deploy/cpp_infer/src/ocr_cls.cpp @@ -81,7 +81,7 @@ cv::Mat Classifier::Run(cv::Mat &img) { void Classifier::LoadModel(const std::string &model_dir) { AnalysisConfig config; - config.SetModel(model_dir + "/model", model_dir + "/params"); + config.SetModel(model_dir + ".pdmodel", model_dir + ".pdiparams"); if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); diff --git a/deploy/cpp_infer/src/ocr_det.cpp b/deploy/cpp_infer/src/ocr_det.cpp index 1e1aaa1bf04d5f0bb80163d39d3a74f0312ae5af..ef6f96a29f1e241bb277de25aebc1df53191a890 100644 --- a/deploy/cpp_infer/src/ocr_det.cpp +++ b/deploy/cpp_infer/src/ocr_det.cpp @@ -18,7 +18,7 @@ namespace PaddleOCR { void DBDetector::LoadModel(const std::string &model_dir) { AnalysisConfig config; - config.SetModel(model_dir + "/model", model_dir + "/params"); + config.SetModel(model_dir + ".pdmodel", model_dir + ".pdiparams"); if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); diff --git a/deploy/cpp_infer/src/ocr_rec.cpp b/deploy/cpp_infer/src/ocr_rec.cpp index 009b6b75f53230c781dee285774da369ae10ce4b..335d201b24a1a0a0a8c03a3af25586328d24b01c 100644 --- a/deploy/cpp_infer/src/ocr_rec.cpp +++ b/deploy/cpp_infer/src/ocr_rec.cpp @@ -103,7 +103,7 @@ void CRNNRecognizer::Run(std::vector>> boxes, void CRNNRecognizer::LoadModel(const std::string &model_dir) { AnalysisConfig config; - config.SetModel(model_dir + "/model", model_dir + "/params"); + config.SetModel(model_dir + ".pdmodel", model_dir + ".pdiparams"); if (this->use_gpu_) { config.EnableUseGpu(this->gpu_mem_, this->gpu_id_); @@ -186,4 +186,4 @@ cv::Mat CRNNRecognizer::GetRotateCropImage(const cv::Mat &srcimage, } } -} // namespace PaddleOCR \ No newline at end of file +} // namespace PaddleOCR diff --git a/ppocr/utils/dict/en_dict.txt b/ppocr/utils/dict/en_dict.txt new file mode 100644 index 0000000000000000000000000000000000000000..6fbd99f46acca8391a5e86ae546c637399204506 --- /dev/null +++ b/ppocr/utils/dict/en_dict.txt @@ -0,0 +1,63 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z + diff --git a/ppocr/utils/dict/french_dict.txt b/ppocr/utils/dict/french_dict.txt index a74c60ad39a8382da4658b4af3adc2d9b1df317c..e8f657db35bf0b74f779f38a9e3b9b47b007e3c4 100644 --- a/ppocr/utils/dict/french_dict.txt +++ b/ppocr/utils/dict/french_dict.txt @@ -132,4 +132,5 @@ j ³ Å $ -# \ No newline at end of file +# + diff --git a/ppocr/utils/dict/german_dict.txt b/ppocr/utils/dict/german_dict.txt index ba9d472adc5a1c15b860a3cbb934cec97db4f268..af0b01ebc9c5f588b621e318a9d85760cd8f42d9 100644 --- a/ppocr/utils/dict/german_dict.txt +++ b/ppocr/utils/dict/german_dict.txt @@ -123,4 +123,5 @@ z â å æ -é \ No newline at end of file +é + diff --git a/ppocr/utils/dict/japan_dict.txt b/ppocr/utils/dict/japan_dict.txt index 926979bc6b901e915931480010bee4aa720a8cbb..339d4b89e5159a346636641a0814874faa59754a 100644 --- a/ppocr/utils/dict/japan_dict.txt +++ b/ppocr/utils/dict/japan_dict.txt @@ -4395,4 +4395,5 @@ z y z ~ -・ \ No newline at end of file +・ + diff --git a/ppocr/utils/dict/korean_dict.txt b/ppocr/utils/dict/korean_dict.txt index 77ae5c301a1173622b1537d01da34009f2c40a4c..a13899f14dfe3bfc25b34904390c7b1e4ed8674b 100644 --- a/ppocr/utils/dict/korean_dict.txt +++ b/ppocr/utils/dict/korean_dict.txt @@ -179,7 +179,7 @@ z с т я - +​ ’ “ ” @@ -3684,4 +3684,5 @@ z 立 茶 切 -宅 \ No newline at end of file +宅 + diff --git a/tools/export_model.py b/tools/export_model.py index cf568884f695f647c50d375d50d168d5ca1ea86e..46a8a8b8dfb8dd4c33931007692aa91376530089 100755 --- a/tools/export_model.py +++ b/tools/export_model.py @@ -39,26 +39,12 @@ def parse_args(): return parser.parse_args() -class Model(paddle.nn.Layer): - def __init__(self, model): - super(Model, self).__init__() - self.pre_model = model - - # Please modify the 'shape' according to actual needs - @to_static(input_spec=[ - paddle.static.InputSpec( - shape=[None, 3, 640, 640], dtype='float32') - ]) - def forward(self, inputs): - x = self.pre_model(inputs) - return x - - def main(): FLAGS = parse_args() config = load_config(FLAGS.config) logger = get_logger() # build post process + post_process_class = build_post_process(config['PostProcess'], config['Global']) @@ -71,9 +57,16 @@ def main(): init_model(config, model, logger) model.eval() - model = Model(model) - save_path = '{}/{}'.format(FLAGS.output_path, - config['Architecture']['model_type']) + save_path = '{}/{}/inference'.format(FLAGS.output_path, + config['Architecture']['model_type']) + infer_shape = [3, 32, 100] if config['Architecture'][ + 'model_type'] != "det" else [3, 640, 640] + model = to_static( + model, + input_spec=[ + paddle.static.InputSpec( + shape=[None] + infer_shape, dtype='float32') + ]) paddle.jit.save(model, save_path) logger.info('inference model is saved to {}'.format(save_path)) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index ee1f954dcc4b6518cfe454a86650b397b9db449e..75b725a7a0818245bbab1d01e5cbc543bf72f52a 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -100,8 +100,8 @@ def create_predictor(args, mode, logger): if model_dir is None: logger.info("not find {} model file path {}".format(mode, model_dir)) sys.exit(0) - model_file_path = model_dir + "/model" - params_file_path = model_dir + "/params" + model_file_path = model_dir + ".pdmodel" + params_file_path = model_dir + ".pdiparams" if not os.path.exists(model_file_path): logger.info("not find model file path {}".format(model_file_path)) sys.exit(0) @@ -230,10 +230,10 @@ def draw_ocr_box_txt(image, box[2][1], box[3][0], box[3][1] ], outline=color) - box_height = math.sqrt((box[0][0] - box[3][0]) ** 2 + (box[0][1] - box[3][ - 1]) ** 2) - box_width = math.sqrt((box[0][0] - box[1][0]) ** 2 + (box[0][1] - box[1][ - 1]) ** 2) + box_height = math.sqrt((box[0][0] - box[3][0])**2 + (box[0][1] - box[3][ + 1])**2) + box_width = math.sqrt((box[0][0] - box[1][0])**2 + (box[0][1] - box[1][ + 1])**2) if box_height > 2 * box_width: font_size = max(int(box_width * 0.9), 10) font = ImageFont.truetype(font_path, font_size, encoding="utf-8")