diff --git a/configs/det/det_db_mv3.yml b/configs/det/det_db_mv3.yml index 45e2ee17b72207d98d06169f29a9d3d16ff0557b..583c18933f41facfd9fb8c7b84c664eb2e12a385 100755 --- a/configs/det/det_db_mv3.yml +++ b/configs/det/det_db_mv3.yml @@ -4,7 +4,7 @@ Global: epoch_num: 1200 log_smooth_window: 20 print_batch_step: 2 - save_model_dir: output + save_model_dir: ./output/det_db/ save_epoch_step: 200 eval_batch_step: 5000 train_batch_size_per_card: 16 @@ -13,7 +13,7 @@ Global: reader_yml: ./configs/det/det_db_icdar15_reader.yml pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/ checkpoints: - save_res_path: ./output/predicts_db.txt + save_res_path: ./output/det_db/predicts_db.txt save_inference_dir: Architecture: diff --git a/configs/det/det_db_r50_vd.yml b/configs/det/det_db_r50_vd.yml index 1faecbb512a8f48b1674272f851bc1668b662bc1..78550411ad1746833a46a6bad1fd68e0a65d4754 100755 --- a/configs/det/det_db_r50_vd.yml +++ b/configs/det/det_db_r50_vd.yml @@ -4,7 +4,7 @@ Global: epoch_num: 1200 log_smooth_window: 20 print_batch_step: 2 - save_model_dir: output + save_model_dir: ./output/det_db/ save_epoch_step: 200 eval_batch_step: 5000 train_batch_size_per_card: 8 @@ -12,8 +12,10 @@ Global: image_shape: [3, 640, 640] reader_yml: ./configs/det/det_db_icdar15_reader.yml pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/ - save_res_path: ./output/predicts_db.txt - + save_res_path: ./output/det_db/predicts_db.txt + checkpoints: + save_inference_dir: + Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_east_mv3.yml b/configs/det/det_east_mv3.yml index 6a77768edd5f1f0040f1ccb4081c77b094a919a6..b1129ce999ce7bad29604463a501fa0beed3fff5 100755 --- a/configs/det/det_east_mv3.yml +++ b/configs/det/det_east_mv3.yml @@ -4,7 +4,7 @@ Global: epoch_num: 100000 log_smooth_window: 20 print_batch_step: 5 - save_model_dir: output + save_model_dir: ./output/det_east/ save_epoch_step: 200 eval_batch_step: 5000 train_batch_size_per_card: 16 @@ -12,7 +12,9 @@ Global: image_shape: [3, 512, 512] reader_yml: ./configs/det/det_east_icdar15_reader.yml pretrain_weights: ./pretrain_models/MobileNetV3_pretrained/MobileNetV3_large_x0_5_pretrained/ - save_res_path: ./output/predicts_east.txt + checkpoints: + save_res_path: ./output/det_east/predicts_east.txt + save_inference_dir: Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/det/det_east_r50_vd.yml b/configs/det/det_east_r50_vd.yml index 6e9d23c62626ff97524866e57e3aea51122ea7b4..f0f6e4a47dd28ec7535f8c4b27d107083eeebd6c 100755 --- a/configs/det/det_east_r50_vd.yml +++ b/configs/det/det_east_r50_vd.yml @@ -4,7 +4,7 @@ Global: epoch_num: 100000 log_smooth_window: 20 print_batch_step: 5 - save_model_dir: output + save_model_dir: ./output/det_east/ save_epoch_step: 200 eval_batch_step: 5000 train_batch_size_per_card: 8 @@ -12,8 +12,10 @@ Global: image_shape: [3, 512, 512] reader_yml: ./configs/det/det_east_icdar15_reader.yml pretrain_weights: ./pretrain_models/ResNet50_vd_pretrained/ - save_res_path: ./output/predicts_east.txt - + save_res_path: ./output/det_east/predicts_east.txt + checkpoints: + save_inference_dir: + Architecture: function: ppocr.modeling.architectures.det_model,DetModel diff --git a/configs/rec/rec_mv3_none_bilstm_ctc.yml b/configs/rec/rec_mv3_none_bilstm_ctc.yml index 09479175da4eca321eacfe732a09917e7dee7c32..ea1046380093c5635dcfcbf90761bedcd5320e92 100755 --- a/configs/rec/rec_mv3_none_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_none_bilstm_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,9 @@ Global: character_type: en loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_mv3_none_none_ctc.yml b/configs/rec/rec_mv3_none_none_ctc.yml index ae9264681c6a740600911c015364497c8505d503..06622783976f262c43e256e878bcbc2eec920e4e 100755 --- a/configs/rec/rec_mv3_none_none_ctc.yml +++ b/configs/rec/rec_mv3_none_none_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -15,7 +15,9 @@ Global: loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml pretrain_weights: - + checkpoints: + save_inference_dir: + Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_mv3_tps_bilstm_attn.yml b/configs/rec/rec_mv3_tps_bilstm_attn.yml index 59cb3c2ca78e9d928d97c607e27ac27501017594..f5ba60d95af6635534adf5bffd3307cd4b7b70c8 100755 --- a/configs/rec/rec_mv3_tps_bilstm_attn.yml +++ b/configs/rec/rec_mv3_tps_bilstm_attn.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,9 @@ Global: character_type: en loss_type: attention reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_mv3_tps_bilstm_ctc.yml b/configs/rec/rec_mv3_tps_bilstm_ctc.yml index 3acc23553eab429e10db85536e83c1d63e5460a6..132320bc74ae4da37a56f74f2b4ca8c1b780da36 100755 --- a/configs/rec/rec_mv3_tps_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_tps_bilstm_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,10 @@ Global: character_type: en loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: + Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_r34_vd_none_bilstm_ctc.yml b/configs/rec/rec_r34_vd_none_bilstm_ctc.yml index 20fb0c85b42cdd2d104ca2bf0be02ec70b96969e..b784c7f89847e91a8b650df5db9c7ecd54456548 100755 --- a/configs/rec/rec_r34_vd_none_bilstm_ctc.yml +++ b/configs/rec/rec_r34_vd_none_bilstm_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,9 @@ Global: character_type: en loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_r34_vd_none_none_ctc.yml b/configs/rec/rec_r34_vd_none_none_ctc.yml index 0de87aea741b270393ea584d6b6df2753c525f58..9d42e6d15b6b8d6888d6223880d00c37c8285c4e 100755 --- a/configs/rec/rec_r34_vd_none_none_ctc.yml +++ b/configs/rec/rec_r34_vd_none_none_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,9 @@ Global: character_type: en loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_r34_vd_tps_bilstm_attn.yml b/configs/rec/rec_r34_vd_tps_bilstm_attn.yml index 71d770b9d86a81d76e237b4f7cf6262fb214df86..a77e457b48c6f8801dbc2037d0c77fcf1320cf9d 100755 --- a/configs/rec/rec_r34_vd_tps_bilstm_attn.yml +++ b/configs/rec/rec_r34_vd_tps_bilstm_attn.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -14,7 +14,9 @@ Global: character_type: en loss_type: attention reader_yml: ./configs/rec/rec_benchmark_reader.yml - pretrain_weights: + pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml b/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml index beb643725d1b17849b3ab3598576aa7c2ee921a6..3768aa47c9b6e915f37b663eff6c2f4929dc2d49 100755 --- a/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml +++ b/configs/rec/rec_r34_vd_tps_bilstm_ctc.yml @@ -4,7 +4,7 @@ Global: epoch_num: 72 log_smooth_window: 20 print_batch_step: 10 - save_model_dir: output + save_model_dir: output/rec save_epoch_step: 3 eval_batch_step: 2000 train_batch_size_per_card: 256 @@ -15,6 +15,8 @@ Global: loss_type: ctc reader_yml: ./configs/rec/rec_benchmark_reader.yml pretrain_weights: + checkpoints: + save_inference_dir: Architecture: function: ppocr.modeling.architectures.rec_model,RecModel diff --git a/ppocr/modeling/heads/det_db_head.py b/ppocr/modeling/heads/det_db_head.py index 67ec474890eaedf5da5313166c97ca1d2f88f0cf..bafacaaad533dd1a6eb7129eb37b098f8738e671 100644 --- a/ppocr/modeling/heads/det_db_head.py +++ b/ppocr/modeling/heads/det_db_head.py @@ -196,7 +196,7 @@ class DBHead(object): fuse = fluid.layers.concat(input=[p5, p4, p3, p2], axis=1) shrink_maps = self.binarize(fuse) if mode != "train": - return shrink_maps + return {"maps", shrink_maps} threshold_maps = self.thresh(fuse) binary_maps = self.step_function(shrink_maps, threshold_maps) y = fluid.layers.concat( diff --git a/ppocr/postprocess/db_postprocess.py b/ppocr/postprocess/db_postprocess.py index 15ba46155af4d2c1890a5a863cadea35d0192909..c7b2dbc1df6729d2cfa2beb71b157aff7a89e46f 100644 --- a/ppocr/postprocess/db_postprocess.py +++ b/ppocr/postprocess/db_postprocess.py @@ -128,6 +128,7 @@ class DBPostProcess(object): def __call__(self, outs_dict, ratio_list): pred = outs_dict['maps'] + pred = pred[:, 0, :, :] segmentation = pred > self.thresh diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index d830306e1d624aed3de7e3daa6766dab668cddeb..07a8180fe028e852b86696b0da844fb55165e72a 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -24,6 +24,7 @@ import copy import numpy as np import math import time +import sys class TextDetector(object): @@ -52,10 +53,10 @@ class TextDetector(object): utility.create_predictor(args, mode="det") def order_points_clockwise(self, pts): - ####### - ## https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py - ######## + """ + reference from: https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py # sort the points based on their x-coordinates + """ xSorted = pts[np.argsort(pts[:, 0]), :] # grab the left-most and right-most points from the sorted @@ -141,7 +142,7 @@ class TextDetector(object): outs_dict['f_score'] = outputs[0] outs_dict['f_geo'] = outputs[1] else: - outs_dict['maps'] = [outputs[0]] + 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) diff --git a/tools/program.py b/tools/program.py index f74aacc738df09c7fd2d9a4bec9189030fa571ed..dc14086d5fe8033344dafd8900bb7427c18d128a 100755 --- a/tools/program.py +++ b/tools/program.py @@ -219,6 +219,8 @@ def train_eval_det_run(config, exe, train_info_dict, eval_info_dict): eval_batch_step = config['Global']['eval_batch_step'] save_epoch_step = config['Global']['save_epoch_step'] save_model_dir = config['Global']['save_model_dir'] + if not os.path.exists(save_model_dir): + os.makedirs(save_model_dir) train_stats = TrainingStats(log_smooth_window, train_info_dict['fetch_name_list']) best_eval_hmean = -1