disable se & add cls params for hub serving

This commit is contained in:
lichenxia 2020-09-16 17:33:06 +08:00
parent 5b5b72e651
commit fd76c1234b
4 changed files with 21 additions and 4 deletions

View File

@ -24,6 +24,7 @@ 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
@ -49,6 +50,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

View File

@ -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

View File

@ -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')

View File

@ -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(