diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index caa7bd4fa09752cff8b4d596e80b5729cce175bf..91a8e86f8bba440df83c1d9f7da0e6523d5907bb 100755 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -49,6 +49,6 @@ Optimizer: PostProcess: function: ppocr.postprocess.db_postprocess,DBPostProcess thresh: 0.3 - box_thresh: 0.7 + box_thresh: 0.6 max_candidates: 1000 - unclip_ratio: 2.0 + unclip_ratio: 1.5 diff --git a/configs/det/det_mv3_db_v1.1.yml b/configs/det/det_mv3_db_v1.1.yml new file mode 100755 index 0000000000000000000000000000000000000000..5f67ca1db758069bb6d19276339895302604fd62 --- /dev/null +++ b/configs/det/det_mv3_db_v1.1.yml @@ -0,0 +1,55 @@ +Global: + algorithm: DB + use_gpu: true + epoch_num: 1200 + log_smooth_window: 20 + print_batch_step: 2 + save_model_dir: ./output/det_db/ + save_epoch_step: 200 + # evaluation is run every 5000 iterations after the 4000th iteration + eval_batch_step: [4000, 5000] + train_batch_size_per_card: 16 + test_batch_size_per_card: 16 + image_shape: [3, 640, 640] + reader_yml: ./configs/det/det_db_icdar15_reader.yml + pretrain_weights: ./pretrain_models/MobileNetV3_large_x0_5_pretrained/ + checkpoints: + save_res_path: ./output/det_db/predicts_db.txt + save_inference_dir: + +Architecture: + function: ppocr.modeling.architectures.det_model,DetModel + +Backbone: + function: ppocr.modeling.backbones.det_mobilenet_v3,MobileNetV3 + scale: 0.5 + model_name: large + disable_se: true + +Head: + function: ppocr.modeling.heads.det_db_head,DBHead + model_name: large + k: 50 + inner_channels: 96 + out_channels: 2 + +Loss: + function: ppocr.modeling.losses.det_db_loss,DBLoss + balance_loss: true + main_loss_type: DiceLoss + alpha: 5 + beta: 10 + ohem_ratio: 3 + +Optimizer: + function: ppocr.optimizer,AdamDecay + base_lr: 0.001 + beta1: 0.9 + beta2: 0.999 + +PostProcess: + function: ppocr.postprocess.db_postprocess,DBPostProcess + thresh: 0.3 + box_thresh: 0.6 + max_candidates: 1000 + unclip_ratio: 1.5 diff --git a/deploy/hubserving/ocr_system/params.py b/deploy/hubserving/ocr_system/params.py index 0ff56d37d50b30b09bb13b529a48a260dfe8f84a..21e8cca4a0990ecb5963280100db1a0a3fb62151 100644 --- a/deploy/hubserving/ocr_system/params.py +++ b/deploy/hubserving/ocr_system/params.py @@ -10,7 +10,7 @@ class Config(object): def read_params(): cfg = Config() - + #params for text detector cfg.det_algorithm = "DB" cfg.det_model_dir = "./inference/ch_det_mv3_db/" @@ -38,6 +38,13 @@ def read_params(): cfg.rec_char_dict_path = "./ppocr/utils/ppocr_keys_v1.txt" cfg.use_space_char = True + #params for text classifier + cfg.use_angle_cls = False + cfg.cls_model_dir = "./inference/ch_ppocr_mobile-v1.1.cls_infer/" + cfg.cls_image_shape = "3, 48, 192" + cfg.label_list = ['0', '180'] + cfg.cls_batch_num = 30 + cfg.use_zero_copy_run = False return cfg diff --git a/ppocr/modeling/backbones/det_mobilenet_v3.py b/ppocr/modeling/backbones/det_mobilenet_v3.py index 87f5dd72452bbd4be96f8532ff6486c299318c5a..508f2bbf2d73216fc35a2d906f94731707a25736 100755 --- a/ppocr/modeling/backbones/det_mobilenet_v3.py +++ b/ppocr/modeling/backbones/det_mobilenet_v3.py @@ -79,6 +79,8 @@ class MobileNetV3(): assert self.scale in supported_scale, \ "supported scale are {} but input scale is {}".format(supported_scale, self.scale) + self.disable_se = params.get('disable_se', False) + def __call__(self, input): scale = self.scale inplanes = self.inplanes @@ -232,7 +234,7 @@ class MobileNetV3(): num_groups=num_mid_filter, use_cudnn=False, name=name + '_depthwise') - if use_se: + if use_se and not self.disable_se: conv1 = self.se_block( input=conv1, num_out_filter=num_mid_filter, name=name + '_se') diff --git a/ppocr/modeling/heads/det_db_head.py b/ppocr/modeling/heads/det_db_head.py index 56998044d8923a2bbda094e01b5a4eb2f5496bb3..59b3a1601a3d070ea7101cd71ceb388147d946b8 100644 --- a/ppocr/modeling/heads/det_db_head.py +++ b/ppocr/modeling/heads/det_db_head.py @@ -123,6 +123,13 @@ class DBHead(object): return fluid.layers.reciprocal(1 + fluid.layers.exp(-self.k * (x - y))) def __call__(self, conv_features, mode="train"): + """ + Fuse different levels of feature map from backbone in the FPN manner. + Args: + conv_features(list): feature maps from backbone + mode(str): runtime mode, can be "train", "eval" or "test" + Return: predicts + """ c2, c3, c4, c5 = conv_features param_attr = fluid.initializer.MSRAInitializer(uniform=False) in5 = fluid.layers.conv2d(