提交 c0b4cefd 编写于 作者: L LDOUBLEV

fix comments and transform to transforms

上级 5f2f08a0
......@@ -10,7 +10,7 @@ Global:
# if pretrained_model is saved in static mode, load_static_weights must set to True
load_static_weights: True
cal_metric_during_train: False
pretrained_model: ./pretrain_models/MobileNetV3_large_x0_5_pretrained
pretrained_model: ./pretrain_models/ResNet18_vd_pretrained
checkpoints: #./output/det_db_0.001_DiceLoss_256_pp_config_2.0b_4gpu/best_accuracy
save_inference_dir:
use_visualdl: False
......
......@@ -16,7 +16,7 @@ from __future__ import division
from __future__ import print_function
from paddle import nn
from ppocr.modeling.transform import build_transform
from ppocr.modeling.transforms import build_transform
from ppocr.modeling.backbones import build_backbone
from ppocr.modeling.necks import build_neck
from ppocr.modeling.heads import build_head
......
......@@ -111,6 +111,7 @@ class MobileNetV3(nn.Layer):
i = 0
inplanes = make_divisible(inplanes * scale)
for (k, exp, c, se, nl, s) in cfg:
se = se and not self.disable_se
if s == 2 and i > 2:
self.out_channels.append(inplanes)
self.stages.append(nn.Sequential(*block_list))
......@@ -231,7 +232,7 @@ class ResidualUnit(nn.Layer):
if_act=True,
act=act,
name=name + "_depthwise")
if self.if_se and not self.disable_se:
if self.if_se:
self.mid_se = SEModule(mid_channels, name=name + "_se")
self.linear_conv = ConvBNLayer(
in_channels=mid_channels,
......@@ -246,7 +247,7 @@ class ResidualUnit(nn.Layer):
def forward(self, inputs):
x = self.expand_conv(inputs)
x = self.bottleneck_conv(x)
if self.if_se and not self.disable_se:
if self.if_se:
x = self.mid_se(x)
x = self.linear_conv(x)
if self.if_shortcut:
......
......@@ -33,13 +33,14 @@ class DBPostProcess(object):
box_thresh=0.7,
max_candidates=1000,
unclip_ratio=2.0,
use_dilation=False,
**kwargs):
self.thresh = thresh
self.box_thresh = box_thresh
self.max_candidates = max_candidates
self.unclip_ratio = unclip_ratio
self.min_size = 3
self.dilation_kernel = np.array([[1, 1], [1, 1]])
self.dilation_kernel = None if not use_dilation else [[1, 1], [1, 1]]
def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
'''
......@@ -140,9 +141,12 @@ class DBPostProcess(object):
boxes_batch = []
for batch_index in range(pred.shape[0]):
height, width = shape_list[batch_index]
mask = cv2.dilate(
np.array(segmentation[batch_index]).astype(np.uint8),
self.dilation_kernel)
if self.dilation_kernel is not None:
mask = cv2.dilate(
np.array(segmentation[batch_index]).astype(np.uint8),
self.dilation_kernel)
else:
mask = segmentation[batch_index]
boxes, scores = self.boxes_from_bitmap(pred[batch_index], mask,
width, height)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册