pyxllib 0.3.96__py3-none-any.whl → 0.3.197__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyxllib/algo/geo.py +12 -0
- pyxllib/algo/intervals.py +1 -1
- pyxllib/algo/matcher.py +78 -0
- pyxllib/algo/pupil.py +187 -19
- pyxllib/algo/specialist.py +2 -1
- pyxllib/algo/stat.py +38 -2
- {pyxlpr → pyxllib/autogui}/__init__.py +1 -1
- pyxllib/autogui/activewin.py +246 -0
- pyxllib/autogui/all.py +9 -0
- pyxllib/{ext/autogui → autogui}/autogui.py +40 -11
- pyxllib/autogui/uiautolib.py +362 -0
- pyxllib/autogui/wechat.py +827 -0
- pyxllib/autogui/wechat_msg.py +421 -0
- pyxllib/autogui/wxautolib.py +84 -0
- pyxllib/cv/slidercaptcha.py +137 -0
- pyxllib/data/echarts.py +123 -12
- pyxllib/data/jsonlib.py +89 -0
- pyxllib/data/pglib.py +514 -30
- pyxllib/data/sqlite.py +231 -4
- pyxllib/ext/JLineViewer.py +14 -1
- pyxllib/ext/drissionlib.py +277 -0
- pyxllib/ext/kq5034lib.py +0 -1594
- pyxllib/ext/robustprocfile.py +497 -0
- pyxllib/ext/unixlib.py +6 -5
- pyxllib/ext/utools.py +108 -95
- pyxllib/ext/webhook.py +32 -14
- pyxllib/ext/wjxlib.py +88 -0
- pyxllib/ext/wpsapi.py +124 -0
- pyxllib/ext/xlwork.py +9 -0
- pyxllib/ext/yuquelib.py +1003 -71
- pyxllib/file/docxlib.py +1 -1
- pyxllib/file/libreoffice.py +165 -0
- pyxllib/file/movielib.py +9 -0
- pyxllib/file/packlib/__init__.py +112 -75
- pyxllib/file/pdflib.py +1 -1
- pyxllib/file/pupil.py +1 -1
- pyxllib/file/specialist/dirlib.py +1 -1
- pyxllib/file/specialist/download.py +10 -3
- pyxllib/file/specialist/filelib.py +266 -55
- pyxllib/file/xlsxlib.py +205 -50
- pyxllib/file/xlsyncfile.py +341 -0
- pyxllib/prog/cachetools.py +64 -0
- pyxllib/prog/filelock.py +42 -0
- pyxllib/prog/multiprogs.py +940 -0
- pyxllib/prog/newbie.py +9 -2
- pyxllib/prog/pupil.py +129 -60
- pyxllib/prog/specialist/__init__.py +176 -2
- pyxllib/prog/specialist/bc.py +5 -2
- pyxllib/prog/specialist/browser.py +11 -2
- pyxllib/prog/specialist/datetime.py +68 -0
- pyxllib/prog/specialist/tictoc.py +12 -13
- pyxllib/prog/specialist/xllog.py +5 -5
- pyxllib/prog/xlosenv.py +7 -0
- pyxllib/text/airscript.js +744 -0
- pyxllib/text/charclasslib.py +17 -5
- pyxllib/text/jiebalib.py +6 -3
- pyxllib/text/jinjalib.py +32 -0
- pyxllib/text/jsa_ai_prompt.md +271 -0
- pyxllib/text/jscode.py +159 -4
- pyxllib/text/nestenv.py +1 -1
- pyxllib/text/newbie.py +12 -0
- pyxllib/text/pupil/common.py +26 -0
- pyxllib/text/specialist/ptag.py +2 -2
- pyxllib/text/templates/echart_base.html +11 -0
- pyxllib/text/templates/highlight_code.html +17 -0
- pyxllib/text/templates/latex_editor.html +103 -0
- pyxllib/text/xmllib.py +76 -14
- pyxllib/xl.py +2 -1
- pyxllib-0.3.197.dist-info/METADATA +48 -0
- pyxllib-0.3.197.dist-info/RECORD +126 -0
- {pyxllib-0.3.96.dist-info → pyxllib-0.3.197.dist-info}/WHEEL +1 -2
- pyxllib/ext/autogui/__init__.py +0 -8
- pyxllib-0.3.96.dist-info/METADATA +0 -51
- pyxllib-0.3.96.dist-info/RECORD +0 -333
- pyxllib-0.3.96.dist-info/top_level.txt +0 -2
- pyxlpr/ai/__init__.py +0 -5
- pyxlpr/ai/clientlib.py +0 -1281
- pyxlpr/ai/specialist.py +0 -286
- pyxlpr/ai/torch_app.py +0 -172
- pyxlpr/ai/xlpaddle.py +0 -655
- pyxlpr/ai/xltorch.py +0 -705
- pyxlpr/data/__init__.py +0 -11
- pyxlpr/data/coco.py +0 -1325
- pyxlpr/data/datacls.py +0 -365
- pyxlpr/data/datasets.py +0 -200
- pyxlpr/data/gptlib.py +0 -1291
- pyxlpr/data/icdar/__init__.py +0 -96
- pyxlpr/data/icdar/deteval.py +0 -377
- pyxlpr/data/icdar/icdar2013.py +0 -341
- pyxlpr/data/icdar/iou.py +0 -340
- pyxlpr/data/icdar/rrc_evaluation_funcs_1_1.py +0 -463
- pyxlpr/data/imtextline.py +0 -473
- pyxlpr/data/labelme.py +0 -866
- pyxlpr/data/removeline.py +0 -179
- pyxlpr/data/specialist.py +0 -57
- pyxlpr/eval/__init__.py +0 -85
- pyxlpr/paddleocr.py +0 -776
- pyxlpr/ppocr/__init__.py +0 -15
- pyxlpr/ppocr/configs/rec/multi_language/generate_multi_language_configs.py +0 -226
- pyxlpr/ppocr/data/__init__.py +0 -135
- pyxlpr/ppocr/data/imaug/ColorJitter.py +0 -26
- pyxlpr/ppocr/data/imaug/__init__.py +0 -67
- pyxlpr/ppocr/data/imaug/copy_paste.py +0 -170
- pyxlpr/ppocr/data/imaug/east_process.py +0 -437
- pyxlpr/ppocr/data/imaug/gen_table_mask.py +0 -244
- pyxlpr/ppocr/data/imaug/iaa_augment.py +0 -114
- pyxlpr/ppocr/data/imaug/label_ops.py +0 -789
- pyxlpr/ppocr/data/imaug/make_border_map.py +0 -184
- pyxlpr/ppocr/data/imaug/make_pse_gt.py +0 -106
- pyxlpr/ppocr/data/imaug/make_shrink_map.py +0 -126
- pyxlpr/ppocr/data/imaug/operators.py +0 -433
- pyxlpr/ppocr/data/imaug/pg_process.py +0 -906
- pyxlpr/ppocr/data/imaug/randaugment.py +0 -143
- pyxlpr/ppocr/data/imaug/random_crop_data.py +0 -239
- pyxlpr/ppocr/data/imaug/rec_img_aug.py +0 -533
- pyxlpr/ppocr/data/imaug/sast_process.py +0 -777
- pyxlpr/ppocr/data/imaug/text_image_aug/__init__.py +0 -17
- pyxlpr/ppocr/data/imaug/text_image_aug/augment.py +0 -120
- pyxlpr/ppocr/data/imaug/text_image_aug/warp_mls.py +0 -168
- pyxlpr/ppocr/data/lmdb_dataset.py +0 -115
- pyxlpr/ppocr/data/pgnet_dataset.py +0 -104
- pyxlpr/ppocr/data/pubtab_dataset.py +0 -107
- pyxlpr/ppocr/data/simple_dataset.py +0 -372
- pyxlpr/ppocr/losses/__init__.py +0 -61
- pyxlpr/ppocr/losses/ace_loss.py +0 -52
- pyxlpr/ppocr/losses/basic_loss.py +0 -135
- pyxlpr/ppocr/losses/center_loss.py +0 -88
- pyxlpr/ppocr/losses/cls_loss.py +0 -30
- pyxlpr/ppocr/losses/combined_loss.py +0 -67
- pyxlpr/ppocr/losses/det_basic_loss.py +0 -208
- pyxlpr/ppocr/losses/det_db_loss.py +0 -80
- pyxlpr/ppocr/losses/det_east_loss.py +0 -63
- pyxlpr/ppocr/losses/det_pse_loss.py +0 -149
- pyxlpr/ppocr/losses/det_sast_loss.py +0 -121
- pyxlpr/ppocr/losses/distillation_loss.py +0 -272
- pyxlpr/ppocr/losses/e2e_pg_loss.py +0 -140
- pyxlpr/ppocr/losses/kie_sdmgr_loss.py +0 -113
- pyxlpr/ppocr/losses/rec_aster_loss.py +0 -99
- pyxlpr/ppocr/losses/rec_att_loss.py +0 -39
- pyxlpr/ppocr/losses/rec_ctc_loss.py +0 -44
- pyxlpr/ppocr/losses/rec_enhanced_ctc_loss.py +0 -70
- pyxlpr/ppocr/losses/rec_nrtr_loss.py +0 -30
- pyxlpr/ppocr/losses/rec_sar_loss.py +0 -28
- pyxlpr/ppocr/losses/rec_srn_loss.py +0 -47
- pyxlpr/ppocr/losses/table_att_loss.py +0 -109
- pyxlpr/ppocr/metrics/__init__.py +0 -44
- pyxlpr/ppocr/metrics/cls_metric.py +0 -45
- pyxlpr/ppocr/metrics/det_metric.py +0 -82
- pyxlpr/ppocr/metrics/distillation_metric.py +0 -73
- pyxlpr/ppocr/metrics/e2e_metric.py +0 -86
- pyxlpr/ppocr/metrics/eval_det_iou.py +0 -274
- pyxlpr/ppocr/metrics/kie_metric.py +0 -70
- pyxlpr/ppocr/metrics/rec_metric.py +0 -75
- pyxlpr/ppocr/metrics/table_metric.py +0 -50
- pyxlpr/ppocr/modeling/architectures/__init__.py +0 -32
- pyxlpr/ppocr/modeling/architectures/base_model.py +0 -88
- pyxlpr/ppocr/modeling/architectures/distillation_model.py +0 -60
- pyxlpr/ppocr/modeling/backbones/__init__.py +0 -54
- pyxlpr/ppocr/modeling/backbones/det_mobilenet_v3.py +0 -268
- pyxlpr/ppocr/modeling/backbones/det_resnet_vd.py +0 -246
- pyxlpr/ppocr/modeling/backbones/det_resnet_vd_sast.py +0 -285
- pyxlpr/ppocr/modeling/backbones/e2e_resnet_vd_pg.py +0 -265
- pyxlpr/ppocr/modeling/backbones/kie_unet_sdmgr.py +0 -186
- pyxlpr/ppocr/modeling/backbones/rec_mobilenet_v3.py +0 -138
- pyxlpr/ppocr/modeling/backbones/rec_mv1_enhance.py +0 -258
- pyxlpr/ppocr/modeling/backbones/rec_nrtr_mtb.py +0 -48
- pyxlpr/ppocr/modeling/backbones/rec_resnet_31.py +0 -210
- pyxlpr/ppocr/modeling/backbones/rec_resnet_aster.py +0 -143
- pyxlpr/ppocr/modeling/backbones/rec_resnet_fpn.py +0 -307
- pyxlpr/ppocr/modeling/backbones/rec_resnet_vd.py +0 -286
- pyxlpr/ppocr/modeling/heads/__init__.py +0 -54
- pyxlpr/ppocr/modeling/heads/cls_head.py +0 -52
- pyxlpr/ppocr/modeling/heads/det_db_head.py +0 -118
- pyxlpr/ppocr/modeling/heads/det_east_head.py +0 -121
- pyxlpr/ppocr/modeling/heads/det_pse_head.py +0 -37
- pyxlpr/ppocr/modeling/heads/det_sast_head.py +0 -128
- pyxlpr/ppocr/modeling/heads/e2e_pg_head.py +0 -253
- pyxlpr/ppocr/modeling/heads/kie_sdmgr_head.py +0 -206
- pyxlpr/ppocr/modeling/heads/multiheadAttention.py +0 -163
- pyxlpr/ppocr/modeling/heads/rec_aster_head.py +0 -393
- pyxlpr/ppocr/modeling/heads/rec_att_head.py +0 -202
- pyxlpr/ppocr/modeling/heads/rec_ctc_head.py +0 -88
- pyxlpr/ppocr/modeling/heads/rec_nrtr_head.py +0 -826
- pyxlpr/ppocr/modeling/heads/rec_sar_head.py +0 -402
- pyxlpr/ppocr/modeling/heads/rec_srn_head.py +0 -280
- pyxlpr/ppocr/modeling/heads/self_attention.py +0 -406
- pyxlpr/ppocr/modeling/heads/table_att_head.py +0 -246
- pyxlpr/ppocr/modeling/necks/__init__.py +0 -32
- pyxlpr/ppocr/modeling/necks/db_fpn.py +0 -111
- pyxlpr/ppocr/modeling/necks/east_fpn.py +0 -188
- pyxlpr/ppocr/modeling/necks/fpn.py +0 -138
- pyxlpr/ppocr/modeling/necks/pg_fpn.py +0 -314
- pyxlpr/ppocr/modeling/necks/rnn.py +0 -92
- pyxlpr/ppocr/modeling/necks/sast_fpn.py +0 -284
- pyxlpr/ppocr/modeling/necks/table_fpn.py +0 -110
- pyxlpr/ppocr/modeling/transforms/__init__.py +0 -28
- pyxlpr/ppocr/modeling/transforms/stn.py +0 -135
- pyxlpr/ppocr/modeling/transforms/tps.py +0 -308
- pyxlpr/ppocr/modeling/transforms/tps_spatial_transformer.py +0 -156
- pyxlpr/ppocr/optimizer/__init__.py +0 -61
- pyxlpr/ppocr/optimizer/learning_rate.py +0 -228
- pyxlpr/ppocr/optimizer/lr_scheduler.py +0 -49
- pyxlpr/ppocr/optimizer/optimizer.py +0 -160
- pyxlpr/ppocr/optimizer/regularizer.py +0 -52
- pyxlpr/ppocr/postprocess/__init__.py +0 -55
- pyxlpr/ppocr/postprocess/cls_postprocess.py +0 -33
- pyxlpr/ppocr/postprocess/db_postprocess.py +0 -234
- pyxlpr/ppocr/postprocess/east_postprocess.py +0 -143
- pyxlpr/ppocr/postprocess/locality_aware_nms.py +0 -200
- pyxlpr/ppocr/postprocess/pg_postprocess.py +0 -52
- pyxlpr/ppocr/postprocess/pse_postprocess/__init__.py +0 -15
- pyxlpr/ppocr/postprocess/pse_postprocess/pse/__init__.py +0 -29
- pyxlpr/ppocr/postprocess/pse_postprocess/pse/setup.py +0 -14
- pyxlpr/ppocr/postprocess/pse_postprocess/pse_postprocess.py +0 -118
- pyxlpr/ppocr/postprocess/rec_postprocess.py +0 -654
- pyxlpr/ppocr/postprocess/sast_postprocess.py +0 -355
- pyxlpr/ppocr/tools/__init__.py +0 -14
- pyxlpr/ppocr/tools/eval.py +0 -83
- pyxlpr/ppocr/tools/export_center.py +0 -77
- pyxlpr/ppocr/tools/export_model.py +0 -129
- pyxlpr/ppocr/tools/infer/predict_cls.py +0 -151
- pyxlpr/ppocr/tools/infer/predict_det.py +0 -300
- pyxlpr/ppocr/tools/infer/predict_e2e.py +0 -169
- pyxlpr/ppocr/tools/infer/predict_rec.py +0 -414
- pyxlpr/ppocr/tools/infer/predict_system.py +0 -204
- pyxlpr/ppocr/tools/infer/utility.py +0 -629
- pyxlpr/ppocr/tools/infer_cls.py +0 -83
- pyxlpr/ppocr/tools/infer_det.py +0 -134
- pyxlpr/ppocr/tools/infer_e2e.py +0 -122
- pyxlpr/ppocr/tools/infer_kie.py +0 -153
- pyxlpr/ppocr/tools/infer_rec.py +0 -146
- pyxlpr/ppocr/tools/infer_table.py +0 -107
- pyxlpr/ppocr/tools/program.py +0 -596
- pyxlpr/ppocr/tools/test_hubserving.py +0 -117
- pyxlpr/ppocr/tools/train.py +0 -163
- pyxlpr/ppocr/tools/xlprog.py +0 -748
- pyxlpr/ppocr/utils/EN_symbol_dict.txt +0 -94
- pyxlpr/ppocr/utils/__init__.py +0 -24
- pyxlpr/ppocr/utils/dict/ar_dict.txt +0 -117
- pyxlpr/ppocr/utils/dict/arabic_dict.txt +0 -162
- pyxlpr/ppocr/utils/dict/be_dict.txt +0 -145
- pyxlpr/ppocr/utils/dict/bg_dict.txt +0 -140
- pyxlpr/ppocr/utils/dict/chinese_cht_dict.txt +0 -8421
- pyxlpr/ppocr/utils/dict/cyrillic_dict.txt +0 -163
- pyxlpr/ppocr/utils/dict/devanagari_dict.txt +0 -167
- pyxlpr/ppocr/utils/dict/en_dict.txt +0 -63
- pyxlpr/ppocr/utils/dict/fa_dict.txt +0 -136
- pyxlpr/ppocr/utils/dict/french_dict.txt +0 -136
- pyxlpr/ppocr/utils/dict/german_dict.txt +0 -143
- pyxlpr/ppocr/utils/dict/hi_dict.txt +0 -162
- pyxlpr/ppocr/utils/dict/it_dict.txt +0 -118
- pyxlpr/ppocr/utils/dict/japan_dict.txt +0 -4399
- pyxlpr/ppocr/utils/dict/ka_dict.txt +0 -153
- pyxlpr/ppocr/utils/dict/korean_dict.txt +0 -3688
- pyxlpr/ppocr/utils/dict/latin_dict.txt +0 -185
- pyxlpr/ppocr/utils/dict/mr_dict.txt +0 -153
- pyxlpr/ppocr/utils/dict/ne_dict.txt +0 -153
- pyxlpr/ppocr/utils/dict/oc_dict.txt +0 -96
- pyxlpr/ppocr/utils/dict/pu_dict.txt +0 -130
- pyxlpr/ppocr/utils/dict/rs_dict.txt +0 -91
- pyxlpr/ppocr/utils/dict/rsc_dict.txt +0 -134
- pyxlpr/ppocr/utils/dict/ru_dict.txt +0 -125
- pyxlpr/ppocr/utils/dict/ta_dict.txt +0 -128
- pyxlpr/ppocr/utils/dict/table_dict.txt +0 -277
- pyxlpr/ppocr/utils/dict/table_structure_dict.txt +0 -2759
- pyxlpr/ppocr/utils/dict/te_dict.txt +0 -151
- pyxlpr/ppocr/utils/dict/ug_dict.txt +0 -114
- pyxlpr/ppocr/utils/dict/uk_dict.txt +0 -142
- pyxlpr/ppocr/utils/dict/ur_dict.txt +0 -137
- pyxlpr/ppocr/utils/dict/xi_dict.txt +0 -110
- pyxlpr/ppocr/utils/dict90.txt +0 -90
- pyxlpr/ppocr/utils/e2e_metric/Deteval.py +0 -574
- pyxlpr/ppocr/utils/e2e_metric/polygon_fast.py +0 -83
- pyxlpr/ppocr/utils/e2e_utils/extract_batchsize.py +0 -87
- pyxlpr/ppocr/utils/e2e_utils/extract_textpoint_fast.py +0 -457
- pyxlpr/ppocr/utils/e2e_utils/extract_textpoint_slow.py +0 -592
- pyxlpr/ppocr/utils/e2e_utils/pgnet_pp_utils.py +0 -162
- pyxlpr/ppocr/utils/e2e_utils/visual.py +0 -162
- pyxlpr/ppocr/utils/en_dict.txt +0 -95
- pyxlpr/ppocr/utils/gen_label.py +0 -81
- pyxlpr/ppocr/utils/ic15_dict.txt +0 -36
- pyxlpr/ppocr/utils/iou.py +0 -54
- pyxlpr/ppocr/utils/logging.py +0 -69
- pyxlpr/ppocr/utils/network.py +0 -84
- pyxlpr/ppocr/utils/ppocr_keys_v1.txt +0 -6623
- pyxlpr/ppocr/utils/profiler.py +0 -110
- pyxlpr/ppocr/utils/save_load.py +0 -150
- pyxlpr/ppocr/utils/stats.py +0 -72
- pyxlpr/ppocr/utils/utility.py +0 -80
- pyxlpr/ppstructure/__init__.py +0 -13
- pyxlpr/ppstructure/predict_system.py +0 -187
- pyxlpr/ppstructure/table/__init__.py +0 -13
- pyxlpr/ppstructure/table/eval_table.py +0 -72
- pyxlpr/ppstructure/table/matcher.py +0 -192
- pyxlpr/ppstructure/table/predict_structure.py +0 -136
- pyxlpr/ppstructure/table/predict_table.py +0 -221
- pyxlpr/ppstructure/table/table_metric/__init__.py +0 -16
- pyxlpr/ppstructure/table/table_metric/parallel.py +0 -51
- pyxlpr/ppstructure/table/table_metric/table_metric.py +0 -247
- pyxlpr/ppstructure/table/tablepyxl/__init__.py +0 -13
- pyxlpr/ppstructure/table/tablepyxl/style.py +0 -283
- pyxlpr/ppstructure/table/tablepyxl/tablepyxl.py +0 -118
- pyxlpr/ppstructure/utility.py +0 -71
- pyxlpr/xlai.py +0 -10
- /pyxllib/{ext/autogui → autogui}/virtualkey.py +0 -0
- {pyxllib-0.3.96.dist-info → pyxllib-0.3.197.dist-info/licenses}/LICENSE +0 -0
@@ -1,118 +0,0 @@
|
|
1
|
-
# copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from __future__ import absolute_import
|
16
|
-
from __future__ import division
|
17
|
-
from __future__ import print_function
|
18
|
-
|
19
|
-
import math
|
20
|
-
import paddle
|
21
|
-
from paddle import nn
|
22
|
-
import paddle.nn.functional as F
|
23
|
-
from paddle import ParamAttr
|
24
|
-
|
25
|
-
|
26
|
-
def get_bias_attr(k):
|
27
|
-
stdv = 1.0 / math.sqrt(k * 1.0)
|
28
|
-
initializer = paddle.nn.initializer.Uniform(-stdv, stdv)
|
29
|
-
bias_attr = ParamAttr(initializer=initializer)
|
30
|
-
return bias_attr
|
31
|
-
|
32
|
-
|
33
|
-
class Head(nn.Layer):
|
34
|
-
def __init__(self, in_channels, name_list):
|
35
|
-
super(Head, self).__init__()
|
36
|
-
self.conv1 = nn.Conv2D(
|
37
|
-
in_channels=in_channels,
|
38
|
-
out_channels=in_channels // 4,
|
39
|
-
kernel_size=3,
|
40
|
-
padding=1,
|
41
|
-
weight_attr=ParamAttr(),
|
42
|
-
bias_attr=False)
|
43
|
-
self.conv_bn1 = nn.BatchNorm(
|
44
|
-
num_channels=in_channels // 4,
|
45
|
-
param_attr=ParamAttr(
|
46
|
-
initializer=paddle.nn.initializer.Constant(value=1.0)),
|
47
|
-
bias_attr=ParamAttr(
|
48
|
-
initializer=paddle.nn.initializer.Constant(value=1e-4)),
|
49
|
-
act='relu')
|
50
|
-
self.conv2 = nn.Conv2DTranspose(
|
51
|
-
in_channels=in_channels // 4,
|
52
|
-
out_channels=in_channels // 4,
|
53
|
-
kernel_size=2,
|
54
|
-
stride=2,
|
55
|
-
weight_attr=ParamAttr(
|
56
|
-
initializer=paddle.nn.initializer.KaimingUniform()),
|
57
|
-
bias_attr=get_bias_attr(in_channels // 4))
|
58
|
-
self.conv_bn2 = nn.BatchNorm(
|
59
|
-
num_channels=in_channels // 4,
|
60
|
-
param_attr=ParamAttr(
|
61
|
-
initializer=paddle.nn.initializer.Constant(value=1.0)),
|
62
|
-
bias_attr=ParamAttr(
|
63
|
-
initializer=paddle.nn.initializer.Constant(value=1e-4)),
|
64
|
-
act="relu")
|
65
|
-
self.conv3 = nn.Conv2DTranspose(
|
66
|
-
in_channels=in_channels // 4,
|
67
|
-
out_channels=1,
|
68
|
-
kernel_size=2,
|
69
|
-
stride=2,
|
70
|
-
weight_attr=ParamAttr(
|
71
|
-
initializer=paddle.nn.initializer.KaimingUniform()),
|
72
|
-
bias_attr=get_bias_attr(in_channels // 4), )
|
73
|
-
|
74
|
-
def forward(self, x):
|
75
|
-
x = self.conv1(x)
|
76
|
-
x = self.conv_bn1(x)
|
77
|
-
x = self.conv2(x)
|
78
|
-
x = self.conv_bn2(x)
|
79
|
-
x = self.conv3(x)
|
80
|
-
x = F.sigmoid(x)
|
81
|
-
return x
|
82
|
-
|
83
|
-
|
84
|
-
class DBHead(nn.Layer):
|
85
|
-
"""
|
86
|
-
Differentiable Binarization (DB) for text detection:
|
87
|
-
see https://arxiv.org/abs/1911.08947
|
88
|
-
args:
|
89
|
-
params(dict): super parameters for build DB network
|
90
|
-
"""
|
91
|
-
|
92
|
-
def __init__(self, in_channels, k=50, **kwargs):
|
93
|
-
super(DBHead, self).__init__()
|
94
|
-
self.k = k
|
95
|
-
binarize_name_list = [
|
96
|
-
'conv2d_56', 'batch_norm_47', 'conv2d_transpose_0', 'batch_norm_48',
|
97
|
-
'conv2d_transpose_1', 'binarize'
|
98
|
-
]
|
99
|
-
thresh_name_list = [
|
100
|
-
'conv2d_57', 'batch_norm_49', 'conv2d_transpose_2', 'batch_norm_50',
|
101
|
-
'conv2d_transpose_3', 'thresh'
|
102
|
-
]
|
103
|
-
self.binarize = Head(in_channels, binarize_name_list)
|
104
|
-
self.thresh = Head(in_channels, thresh_name_list)
|
105
|
-
|
106
|
-
def step_function(self, x, y):
|
107
|
-
# 可微二值化实现,通过概率图和阈值图计算文本分割二值图
|
108
|
-
return paddle.reciprocal(1 + paddle.exp(-self.k * (x - y)))
|
109
|
-
|
110
|
-
def forward(self, x, targets=None):
|
111
|
-
shrink_maps = self.binarize(x) # 概率图
|
112
|
-
if not self.training:
|
113
|
-
return {'maps': shrink_maps}
|
114
|
-
|
115
|
-
threshold_maps = self.thresh(x) # 阈值图
|
116
|
-
binary_maps = self.step_function(shrink_maps, threshold_maps)
|
117
|
-
y = paddle.concat([shrink_maps, threshold_maps, binary_maps], axis=1)
|
118
|
-
return {'maps': y}
|
@@ -1,121 +0,0 @@
|
|
1
|
-
# copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from __future__ import absolute_import
|
16
|
-
from __future__ import division
|
17
|
-
from __future__ import print_function
|
18
|
-
|
19
|
-
import math
|
20
|
-
import paddle
|
21
|
-
from paddle import nn
|
22
|
-
import paddle.nn.functional as F
|
23
|
-
from paddle import ParamAttr
|
24
|
-
|
25
|
-
|
26
|
-
class ConvBNLayer(nn.Layer):
|
27
|
-
def __init__(self,
|
28
|
-
in_channels,
|
29
|
-
out_channels,
|
30
|
-
kernel_size,
|
31
|
-
stride,
|
32
|
-
padding,
|
33
|
-
groups=1,
|
34
|
-
if_act=True,
|
35
|
-
act=None,
|
36
|
-
name=None):
|
37
|
-
super(ConvBNLayer, self).__init__()
|
38
|
-
self.if_act = if_act
|
39
|
-
self.act = act
|
40
|
-
self.conv = nn.Conv2D(
|
41
|
-
in_channels=in_channels,
|
42
|
-
out_channels=out_channels,
|
43
|
-
kernel_size=kernel_size,
|
44
|
-
stride=stride,
|
45
|
-
padding=padding,
|
46
|
-
groups=groups,
|
47
|
-
weight_attr=ParamAttr(name=name + '_weights'),
|
48
|
-
bias_attr=False)
|
49
|
-
|
50
|
-
self.bn = nn.BatchNorm(
|
51
|
-
num_channels=out_channels,
|
52
|
-
act=act,
|
53
|
-
param_attr=ParamAttr(name="bn_" + name + "_scale"),
|
54
|
-
bias_attr=ParamAttr(name="bn_" + name + "_offset"),
|
55
|
-
moving_mean_name="bn_" + name + "_mean",
|
56
|
-
moving_variance_name="bn_" + name + "_variance")
|
57
|
-
|
58
|
-
def forward(self, x):
|
59
|
-
x = self.conv(x)
|
60
|
-
x = self.bn(x)
|
61
|
-
return x
|
62
|
-
|
63
|
-
|
64
|
-
class EASTHead(nn.Layer):
|
65
|
-
"""
|
66
|
-
"""
|
67
|
-
def __init__(self, in_channels, model_name, **kwargs):
|
68
|
-
super(EASTHead, self).__init__()
|
69
|
-
self.model_name = model_name
|
70
|
-
if self.model_name == "large":
|
71
|
-
num_outputs = [128, 64, 1, 8]
|
72
|
-
else:
|
73
|
-
num_outputs = [64, 32, 1, 8]
|
74
|
-
|
75
|
-
self.det_conv1 = ConvBNLayer(
|
76
|
-
in_channels=in_channels,
|
77
|
-
out_channels=num_outputs[0],
|
78
|
-
kernel_size=3,
|
79
|
-
stride=1,
|
80
|
-
padding=1,
|
81
|
-
if_act=True,
|
82
|
-
act='relu',
|
83
|
-
name="det_head1")
|
84
|
-
self.det_conv2 = ConvBNLayer(
|
85
|
-
in_channels=num_outputs[0],
|
86
|
-
out_channels=num_outputs[1],
|
87
|
-
kernel_size=3,
|
88
|
-
stride=1,
|
89
|
-
padding=1,
|
90
|
-
if_act=True,
|
91
|
-
act='relu',
|
92
|
-
name="det_head2")
|
93
|
-
self.score_conv = ConvBNLayer(
|
94
|
-
in_channels=num_outputs[1],
|
95
|
-
out_channels=num_outputs[2],
|
96
|
-
kernel_size=1,
|
97
|
-
stride=1,
|
98
|
-
padding=0,
|
99
|
-
if_act=False,
|
100
|
-
act=None,
|
101
|
-
name="f_score")
|
102
|
-
self.geo_conv = ConvBNLayer(
|
103
|
-
in_channels=num_outputs[1],
|
104
|
-
out_channels=num_outputs[3],
|
105
|
-
kernel_size=1,
|
106
|
-
stride=1,
|
107
|
-
padding=0,
|
108
|
-
if_act=False,
|
109
|
-
act=None,
|
110
|
-
name="f_geo")
|
111
|
-
|
112
|
-
def forward(self, x, targets=None):
|
113
|
-
f_det = self.det_conv1(x)
|
114
|
-
f_det = self.det_conv2(f_det)
|
115
|
-
f_score = self.score_conv(f_det)
|
116
|
-
f_score = F.sigmoid(f_score)
|
117
|
-
f_geo = self.geo_conv(f_det)
|
118
|
-
f_geo = (F.sigmoid(f_geo) - 0.5) * 2 * 800
|
119
|
-
|
120
|
-
pred = {'f_score': f_score, 'f_geo': f_geo}
|
121
|
-
return pred
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""
|
15
|
-
This code is refer from:
|
16
|
-
https://github.com/whai362/PSENet/blob/python3/models/head/psenet_head.py
|
17
|
-
"""
|
18
|
-
|
19
|
-
from paddle import nn
|
20
|
-
|
21
|
-
|
22
|
-
class PSEHead(nn.Layer):
|
23
|
-
def __init__(self, in_channels, hidden_dim=256, out_channels=7, **kwargs):
|
24
|
-
super(PSEHead, self).__init__()
|
25
|
-
self.conv1 = nn.Conv2D(
|
26
|
-
in_channels, hidden_dim, kernel_size=3, stride=1, padding=1)
|
27
|
-
self.bn1 = nn.BatchNorm2D(hidden_dim)
|
28
|
-
self.relu1 = nn.ReLU()
|
29
|
-
|
30
|
-
self.conv2 = nn.Conv2D(
|
31
|
-
hidden_dim, out_channels, kernel_size=1, stride=1, padding=0)
|
32
|
-
|
33
|
-
def forward(self, x, **kwargs):
|
34
|
-
out = self.conv1(x)
|
35
|
-
out = self.relu1(self.bn1(out))
|
36
|
-
out = self.conv2(out)
|
37
|
-
return {'maps': out}
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from __future__ import absolute_import
|
16
|
-
from __future__ import division
|
17
|
-
from __future__ import print_function
|
18
|
-
|
19
|
-
import math
|
20
|
-
import paddle
|
21
|
-
from paddle import nn
|
22
|
-
import paddle.nn.functional as F
|
23
|
-
from paddle import ParamAttr
|
24
|
-
|
25
|
-
|
26
|
-
class ConvBNLayer(nn.Layer):
|
27
|
-
def __init__(self,
|
28
|
-
in_channels,
|
29
|
-
out_channels,
|
30
|
-
kernel_size,
|
31
|
-
stride,
|
32
|
-
groups=1,
|
33
|
-
if_act=True,
|
34
|
-
act=None,
|
35
|
-
name=None):
|
36
|
-
super(ConvBNLayer, self).__init__()
|
37
|
-
self.if_act = if_act
|
38
|
-
self.act = act
|
39
|
-
self.conv = nn.Conv2D(
|
40
|
-
in_channels=in_channels,
|
41
|
-
out_channels=out_channels,
|
42
|
-
kernel_size=kernel_size,
|
43
|
-
stride=stride,
|
44
|
-
padding=(kernel_size - 1) // 2,
|
45
|
-
groups=groups,
|
46
|
-
weight_attr=ParamAttr(name=name + '_weights'),
|
47
|
-
bias_attr=False)
|
48
|
-
|
49
|
-
self.bn = nn.BatchNorm(
|
50
|
-
num_channels=out_channels,
|
51
|
-
act=act,
|
52
|
-
param_attr=ParamAttr(name="bn_" + name + "_scale"),
|
53
|
-
bias_attr=ParamAttr(name="bn_" + name + "_offset"),
|
54
|
-
moving_mean_name="bn_" + name + "_mean",
|
55
|
-
moving_variance_name="bn_" + name + "_variance")
|
56
|
-
|
57
|
-
def forward(self, x):
|
58
|
-
x = self.conv(x)
|
59
|
-
x = self.bn(x)
|
60
|
-
return x
|
61
|
-
|
62
|
-
|
63
|
-
class SAST_Header1(nn.Layer):
|
64
|
-
def __init__(self, in_channels, **kwargs):
|
65
|
-
super(SAST_Header1, self).__init__()
|
66
|
-
out_channels = [64, 64, 128]
|
67
|
-
self.score_conv = nn.Sequential(
|
68
|
-
ConvBNLayer(in_channels, out_channels[0], 1, 1, act='relu', name='f_score1'),
|
69
|
-
ConvBNLayer(out_channels[0], out_channels[1], 3, 1, act='relu', name='f_score2'),
|
70
|
-
ConvBNLayer(out_channels[1], out_channels[2], 1, 1, act='relu', name='f_score3'),
|
71
|
-
ConvBNLayer(out_channels[2], 1, 3, 1, act=None, name='f_score4')
|
72
|
-
)
|
73
|
-
self.border_conv = nn.Sequential(
|
74
|
-
ConvBNLayer(in_channels, out_channels[0], 1, 1, act='relu', name='f_border1'),
|
75
|
-
ConvBNLayer(out_channels[0], out_channels[1], 3, 1, act='relu', name='f_border2'),
|
76
|
-
ConvBNLayer(out_channels[1], out_channels[2], 1, 1, act='relu', name='f_border3'),
|
77
|
-
ConvBNLayer(out_channels[2], 4, 3, 1, act=None, name='f_border4')
|
78
|
-
)
|
79
|
-
|
80
|
-
def forward(self, x):
|
81
|
-
f_score = self.score_conv(x)
|
82
|
-
f_score = F.sigmoid(f_score)
|
83
|
-
f_border = self.border_conv(x)
|
84
|
-
return f_score, f_border
|
85
|
-
|
86
|
-
|
87
|
-
class SAST_Header2(nn.Layer):
|
88
|
-
def __init__(self, in_channels, **kwargs):
|
89
|
-
super(SAST_Header2, self).__init__()
|
90
|
-
out_channels = [64, 64, 128]
|
91
|
-
self.tvo_conv = nn.Sequential(
|
92
|
-
ConvBNLayer(in_channels, out_channels[0], 1, 1, act='relu', name='f_tvo1'),
|
93
|
-
ConvBNLayer(out_channels[0], out_channels[1], 3, 1, act='relu', name='f_tvo2'),
|
94
|
-
ConvBNLayer(out_channels[1], out_channels[2], 1, 1, act='relu', name='f_tvo3'),
|
95
|
-
ConvBNLayer(out_channels[2], 8, 3, 1, act=None, name='f_tvo4')
|
96
|
-
)
|
97
|
-
self.tco_conv = nn.Sequential(
|
98
|
-
ConvBNLayer(in_channels, out_channels[0], 1, 1, act='relu', name='f_tco1'),
|
99
|
-
ConvBNLayer(out_channels[0], out_channels[1], 3, 1, act='relu', name='f_tco2'),
|
100
|
-
ConvBNLayer(out_channels[1], out_channels[2], 1, 1, act='relu', name='f_tco3'),
|
101
|
-
ConvBNLayer(out_channels[2], 2, 3, 1, act=None, name='f_tco4')
|
102
|
-
)
|
103
|
-
|
104
|
-
def forward(self, x):
|
105
|
-
f_tvo = self.tvo_conv(x)
|
106
|
-
f_tco = self.tco_conv(x)
|
107
|
-
return f_tvo, f_tco
|
108
|
-
|
109
|
-
|
110
|
-
class SASTHead(nn.Layer):
|
111
|
-
"""
|
112
|
-
"""
|
113
|
-
def __init__(self, in_channels, **kwargs):
|
114
|
-
super(SASTHead, self).__init__()
|
115
|
-
|
116
|
-
self.head1 = SAST_Header1(in_channels)
|
117
|
-
self.head2 = SAST_Header2(in_channels)
|
118
|
-
|
119
|
-
def forward(self, x, targets=None):
|
120
|
-
f_score, f_border = self.head1(x)
|
121
|
-
f_tvo, f_tco = self.head2(x)
|
122
|
-
|
123
|
-
predicts = {}
|
124
|
-
predicts['f_score'] = f_score
|
125
|
-
predicts['f_border'] = f_border
|
126
|
-
predicts['f_tvo'] = f_tvo
|
127
|
-
predicts['f_tco'] = f_tco
|
128
|
-
return predicts
|
@@ -1,253 +0,0 @@
|
|
1
|
-
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from __future__ import absolute_import
|
16
|
-
from __future__ import division
|
17
|
-
from __future__ import print_function
|
18
|
-
|
19
|
-
import math
|
20
|
-
import paddle
|
21
|
-
from paddle import nn
|
22
|
-
import paddle.nn.functional as F
|
23
|
-
from paddle import ParamAttr
|
24
|
-
|
25
|
-
|
26
|
-
class ConvBNLayer(nn.Layer):
|
27
|
-
def __init__(self,
|
28
|
-
in_channels,
|
29
|
-
out_channels,
|
30
|
-
kernel_size,
|
31
|
-
stride,
|
32
|
-
padding,
|
33
|
-
groups=1,
|
34
|
-
if_act=True,
|
35
|
-
act=None,
|
36
|
-
name=None):
|
37
|
-
super(ConvBNLayer, self).__init__()
|
38
|
-
self.if_act = if_act
|
39
|
-
self.act = act
|
40
|
-
self.conv = nn.Conv2D(
|
41
|
-
in_channels=in_channels,
|
42
|
-
out_channels=out_channels,
|
43
|
-
kernel_size=kernel_size,
|
44
|
-
stride=stride,
|
45
|
-
padding=padding,
|
46
|
-
groups=groups,
|
47
|
-
weight_attr=ParamAttr(name=name + '_weights'),
|
48
|
-
bias_attr=False)
|
49
|
-
|
50
|
-
self.bn = nn.BatchNorm(
|
51
|
-
num_channels=out_channels,
|
52
|
-
act=act,
|
53
|
-
param_attr=ParamAttr(name="bn_" + name + "_scale"),
|
54
|
-
bias_attr=ParamAttr(name="bn_" + name + "_offset"),
|
55
|
-
moving_mean_name="bn_" + name + "_mean",
|
56
|
-
moving_variance_name="bn_" + name + "_variance",
|
57
|
-
use_global_stats=False)
|
58
|
-
|
59
|
-
def forward(self, x):
|
60
|
-
x = self.conv(x)
|
61
|
-
x = self.bn(x)
|
62
|
-
return x
|
63
|
-
|
64
|
-
|
65
|
-
class PGHead(nn.Layer):
|
66
|
-
"""
|
67
|
-
"""
|
68
|
-
|
69
|
-
def __init__(self, in_channels, **kwargs):
|
70
|
-
super(PGHead, self).__init__()
|
71
|
-
self.conv_f_score1 = ConvBNLayer(
|
72
|
-
in_channels=in_channels,
|
73
|
-
out_channels=64,
|
74
|
-
kernel_size=1,
|
75
|
-
stride=1,
|
76
|
-
padding=0,
|
77
|
-
act='relu',
|
78
|
-
name="conv_f_score{}".format(1))
|
79
|
-
self.conv_f_score2 = ConvBNLayer(
|
80
|
-
in_channels=64,
|
81
|
-
out_channels=64,
|
82
|
-
kernel_size=3,
|
83
|
-
stride=1,
|
84
|
-
padding=1,
|
85
|
-
act='relu',
|
86
|
-
name="conv_f_score{}".format(2))
|
87
|
-
self.conv_f_score3 = ConvBNLayer(
|
88
|
-
in_channels=64,
|
89
|
-
out_channels=128,
|
90
|
-
kernel_size=1,
|
91
|
-
stride=1,
|
92
|
-
padding=0,
|
93
|
-
act='relu',
|
94
|
-
name="conv_f_score{}".format(3))
|
95
|
-
|
96
|
-
self.conv1 = nn.Conv2D(
|
97
|
-
in_channels=128,
|
98
|
-
out_channels=1,
|
99
|
-
kernel_size=3,
|
100
|
-
stride=1,
|
101
|
-
padding=1,
|
102
|
-
groups=1,
|
103
|
-
weight_attr=ParamAttr(name="conv_f_score{}".format(4)),
|
104
|
-
bias_attr=False)
|
105
|
-
|
106
|
-
self.conv_f_boder1 = ConvBNLayer(
|
107
|
-
in_channels=in_channels,
|
108
|
-
out_channels=64,
|
109
|
-
kernel_size=1,
|
110
|
-
stride=1,
|
111
|
-
padding=0,
|
112
|
-
act='relu',
|
113
|
-
name="conv_f_boder{}".format(1))
|
114
|
-
self.conv_f_boder2 = ConvBNLayer(
|
115
|
-
in_channels=64,
|
116
|
-
out_channels=64,
|
117
|
-
kernel_size=3,
|
118
|
-
stride=1,
|
119
|
-
padding=1,
|
120
|
-
act='relu',
|
121
|
-
name="conv_f_boder{}".format(2))
|
122
|
-
self.conv_f_boder3 = ConvBNLayer(
|
123
|
-
in_channels=64,
|
124
|
-
out_channels=128,
|
125
|
-
kernel_size=1,
|
126
|
-
stride=1,
|
127
|
-
padding=0,
|
128
|
-
act='relu',
|
129
|
-
name="conv_f_boder{}".format(3))
|
130
|
-
self.conv2 = nn.Conv2D(
|
131
|
-
in_channels=128,
|
132
|
-
out_channels=4,
|
133
|
-
kernel_size=3,
|
134
|
-
stride=1,
|
135
|
-
padding=1,
|
136
|
-
groups=1,
|
137
|
-
weight_attr=ParamAttr(name="conv_f_boder{}".format(4)),
|
138
|
-
bias_attr=False)
|
139
|
-
self.conv_f_char1 = ConvBNLayer(
|
140
|
-
in_channels=in_channels,
|
141
|
-
out_channels=128,
|
142
|
-
kernel_size=1,
|
143
|
-
stride=1,
|
144
|
-
padding=0,
|
145
|
-
act='relu',
|
146
|
-
name="conv_f_char{}".format(1))
|
147
|
-
self.conv_f_char2 = ConvBNLayer(
|
148
|
-
in_channels=128,
|
149
|
-
out_channels=128,
|
150
|
-
kernel_size=3,
|
151
|
-
stride=1,
|
152
|
-
padding=1,
|
153
|
-
act='relu',
|
154
|
-
name="conv_f_char{}".format(2))
|
155
|
-
self.conv_f_char3 = ConvBNLayer(
|
156
|
-
in_channels=128,
|
157
|
-
out_channels=256,
|
158
|
-
kernel_size=1,
|
159
|
-
stride=1,
|
160
|
-
padding=0,
|
161
|
-
act='relu',
|
162
|
-
name="conv_f_char{}".format(3))
|
163
|
-
self.conv_f_char4 = ConvBNLayer(
|
164
|
-
in_channels=256,
|
165
|
-
out_channels=256,
|
166
|
-
kernel_size=3,
|
167
|
-
stride=1,
|
168
|
-
padding=1,
|
169
|
-
act='relu',
|
170
|
-
name="conv_f_char{}".format(4))
|
171
|
-
self.conv_f_char5 = ConvBNLayer(
|
172
|
-
in_channels=256,
|
173
|
-
out_channels=256,
|
174
|
-
kernel_size=1,
|
175
|
-
stride=1,
|
176
|
-
padding=0,
|
177
|
-
act='relu',
|
178
|
-
name="conv_f_char{}".format(5))
|
179
|
-
self.conv3 = nn.Conv2D(
|
180
|
-
in_channels=256,
|
181
|
-
out_channels=37,
|
182
|
-
kernel_size=3,
|
183
|
-
stride=1,
|
184
|
-
padding=1,
|
185
|
-
groups=1,
|
186
|
-
weight_attr=ParamAttr(name="conv_f_char{}".format(6)),
|
187
|
-
bias_attr=False)
|
188
|
-
|
189
|
-
self.conv_f_direc1 = ConvBNLayer(
|
190
|
-
in_channels=in_channels,
|
191
|
-
out_channels=64,
|
192
|
-
kernel_size=1,
|
193
|
-
stride=1,
|
194
|
-
padding=0,
|
195
|
-
act='relu',
|
196
|
-
name="conv_f_direc{}".format(1))
|
197
|
-
self.conv_f_direc2 = ConvBNLayer(
|
198
|
-
in_channels=64,
|
199
|
-
out_channels=64,
|
200
|
-
kernel_size=3,
|
201
|
-
stride=1,
|
202
|
-
padding=1,
|
203
|
-
act='relu',
|
204
|
-
name="conv_f_direc{}".format(2))
|
205
|
-
self.conv_f_direc3 = ConvBNLayer(
|
206
|
-
in_channels=64,
|
207
|
-
out_channels=128,
|
208
|
-
kernel_size=1,
|
209
|
-
stride=1,
|
210
|
-
padding=0,
|
211
|
-
act='relu',
|
212
|
-
name="conv_f_direc{}".format(3))
|
213
|
-
self.conv4 = nn.Conv2D(
|
214
|
-
in_channels=128,
|
215
|
-
out_channels=2,
|
216
|
-
kernel_size=3,
|
217
|
-
stride=1,
|
218
|
-
padding=1,
|
219
|
-
groups=1,
|
220
|
-
weight_attr=ParamAttr(name="conv_f_direc{}".format(4)),
|
221
|
-
bias_attr=False)
|
222
|
-
|
223
|
-
def forward(self, x, targets=None):
|
224
|
-
f_score = self.conv_f_score1(x)
|
225
|
-
f_score = self.conv_f_score2(f_score)
|
226
|
-
f_score = self.conv_f_score3(f_score)
|
227
|
-
f_score = self.conv1(f_score)
|
228
|
-
f_score = F.sigmoid(f_score)
|
229
|
-
|
230
|
-
# f_border
|
231
|
-
f_border = self.conv_f_boder1(x)
|
232
|
-
f_border = self.conv_f_boder2(f_border)
|
233
|
-
f_border = self.conv_f_boder3(f_border)
|
234
|
-
f_border = self.conv2(f_border)
|
235
|
-
|
236
|
-
f_char = self.conv_f_char1(x)
|
237
|
-
f_char = self.conv_f_char2(f_char)
|
238
|
-
f_char = self.conv_f_char3(f_char)
|
239
|
-
f_char = self.conv_f_char4(f_char)
|
240
|
-
f_char = self.conv_f_char5(f_char)
|
241
|
-
f_char = self.conv3(f_char)
|
242
|
-
|
243
|
-
f_direction = self.conv_f_direc1(x)
|
244
|
-
f_direction = self.conv_f_direc2(f_direction)
|
245
|
-
f_direction = self.conv_f_direc3(f_direction)
|
246
|
-
f_direction = self.conv4(f_direction)
|
247
|
-
|
248
|
-
predicts = {}
|
249
|
-
predicts['f_score'] = f_score
|
250
|
-
predicts['f_border'] = f_border
|
251
|
-
predicts['f_char'] = f_char
|
252
|
-
predicts['f_direction'] = f_direction
|
253
|
-
return predicts
|