PaddleOCR/ppocr/modeling/backbones/__init__.py

131 lines
4.2 KiB
Python
Raw Normal View History

# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2020-10-13 17:13:33 +08:00
__all__ = ["build_backbone"]
2020-10-13 17:13:33 +08:00
def build_backbone(config, model_type):
2021-11-30 23:26:40 +08:00
if model_type == "det" or model_type == "table":
2020-10-13 17:13:33 +08:00
from .det_mobilenet_v3 import MobileNetV3
2022-06-27 16:26:53 +08:00
from .det_resnet import ResNet
from .det_resnet_vd import ResNet_vd
2020-12-09 14:45:25 +08:00
from .det_resnet_vd_sast import ResNet_SAST
2022-08-08 14:50:27 +08:00
from .det_pp_lcnet import PPLCNet
2023-04-23 16:13:01 +08:00
from .rec_lcnetv3 import PPLCNetV3
from .rec_hgnet import PPHGNet_small
from .rec_vit import ViT
from .det_pp_lcnet_v2 import PPLCNetV2_base
from .rec_repvit import RepSVTR_det
2022-08-08 14:50:27 +08:00
support_dict = [
"MobileNetV3",
"ResNet",
"ResNet_vd",
"ResNet_SAST",
"PPLCNet",
"PPLCNetV3",
"PPHGNet_small",
"PPLCNetV2_base",
"RepSVTR_det",
2022-08-08 14:50:27 +08:00
]
if model_type == "table":
from .table_master_resnet import TableResNetExtra
support_dict.append("TableResNetExtra")
elif model_type == "rec" or model_type == "cls":
2020-10-13 17:13:33 +08:00
from .rec_mobilenet_v3 import MobileNetV3
from .rec_resnet_vd import ResNet
2020-12-30 16:15:49 +08:00
from .rec_resnet_fpn import ResNetFPN
from .rec_mv1_enhance import MobileNetV1Enhance
2021-08-11 17:50:51 +08:00
from .rec_nrtr_mtb import MTB
2021-08-24 11:49:26 +08:00
from .rec_resnet_31 import ResNet31
2022-07-10 10:21:18 +08:00
from .rec_resnet_32 import ResNet32
from .rec_resnet_45 import ResNet45
2021-09-29 10:48:11 +08:00
from .rec_resnet_aster import ResNet_ASTER
2022-01-17 00:05:09 +08:00
from .rec_micronet import MicroNet
from .rec_efficientb3_pren import EfficientNetb3_PREN
from .rec_svtrnet import SVTRNet
from .rec_vitstr import ViTSTR
from .rec_resnet_rfl import ResNetRFL
2022-10-15 20:27:05 +08:00
from .rec_densenet import DenseNet
from .rec_shallow_cnn import ShallowCNN
2023-04-23 16:13:01 +08:00
from .rec_lcnetv3 import PPLCNetV3
from .rec_hgnet import PPHGNet_small
Add new recognition method "ParseQ" (#10836) * Update PP-OCRv4_introduction.md * Update PP-OCRv4_introduction.md (#10616) * Update PP-OCRv4_introduction.md * Update PP-OCRv4_introduction.md * Update PP-OCRv4_introduction.md * Update README.md * Cherrypicking GH-10217 and GH-10216 to PaddlePaddle:Release/2.7 (#10655) * Don't break overall processing on a bad image * Add preprocessing common to OCR tasks Add preprocessing to options * Update requirements.txt (#10656) added missing pyyaml library * [TIPC]update xpu tipc script (#10658) * fix-typo (#10642) Co-authored-by: Dennis <dvorst@users.noreply.github.com> Co-authored-by: shiyutang <34859558+shiyutang@users.noreply.github.com> * 修改数据增强导致的DSR报错 (#10662) (#10681) * 修改数据增强导致的DSR报错 * 错误修改回滚 * Update algorithm_overview_en.md (#10670) Fixed simple spelling errors. * Implement recoginition method ParseQ * Document update for new recognition method ParseQ * add prediction for parseq * Update rec_vit_parseq.yml * Update rec_r31_sar.yml * Update rec_r31_sar.yml * Update rec_r50_fpn_srn.yml * Update rec_vit_parseq.py * Update rec_vit_parseq.yml * Update rec_parseq_head.py * Update rec_img_aug.py * Update rec_vit_parseq.yml * Update __init__.py * Update predict_rec.py * Update paddleocr.py * Update requirements.txt * Update utility.py * Update utility.py --------- Co-authored-by: xiaoting <31891223+tink2123@users.noreply.github.com> Co-authored-by: topduke <784990967@qq.com> Co-authored-by: dyning <dyning.2003@163.com> Co-authored-by: UserUnknownFactor <63057995+UserUnknownFactor@users.noreply.github.com> Co-authored-by: itasli <ilyas.tasli@outlook.fr> Co-authored-by: Kai Song <50285351+USTCKAY@users.noreply.github.com> Co-authored-by: dvorst <87502756+dvorst@users.noreply.github.com> Co-authored-by: Dennis <dvorst@users.noreply.github.com> Co-authored-by: shiyutang <34859558+shiyutang@users.noreply.github.com> Co-authored-by: Dec20B <1192152456@qq.com> Co-authored-by: ncoffman <51147417+ncoffman@users.noreply.github.com>
2023-09-07 16:36:47 +08:00
from .rec_vit_parseq import ViTParseQ
from .rec_repvit import RepSVTR
from .rec_svtrv2 import SVTRv2
support_dict = [
"MobileNetV1Enhance",
"MobileNetV3",
"ResNet",
"ResNetFPN",
"MTB",
"ResNet31",
"ResNet45",
"ResNet_ASTER",
"MicroNet",
"EfficientNetb3_PREN",
"SVTRNet",
"ViTSTR",
"ResNet32",
"ResNetRFL",
"DenseNet",
"ShallowCNN",
"PPLCNetV3",
"PPHGNet_small",
"ViTParseQ",
"ViT",
"RepSVTR",
"SVTRv2",
]
elif model_type == "e2e":
2021-03-08 14:15:47 +08:00
from .e2e_resnet_vd_pg import ResNet
support_dict = ["ResNet"]
elif model_type == "kie":
2021-10-09 15:40:25 +08:00
from .kie_unet_sdmgr import Kie_backbone
from .vqa_layoutlm import (
LayoutLMForSer,
LayoutLMv2ForSer,
LayoutLMv2ForRe,
LayoutXLMForSer,
LayoutXLMForRe,
)
support_dict = [
"Kie_backbone",
"LayoutLMForSer",
"LayoutLMv2ForSer",
"LayoutLMv2ForRe",
"LayoutXLMForSer",
"LayoutXLMForRe",
]
elif model_type == "table":
2021-06-16 16:47:33 +08:00
from .table_resnet_vd import ResNet
from .table_mobilenet_v3 import MobileNetV3
support_dict = ["ResNet", "MobileNetV3"]
2020-10-13 17:13:33 +08:00
else:
raise NotImplementedError
module_name = config.pop("name")
2020-10-13 17:13:33 +08:00
assert module_name in support_dict, Exception(
"when model typs is {}, backbone only support {}".format(
model_type, support_dict
)
)
2020-10-13 17:13:33 +08:00
module_class = eval(module_name)(**config)
return module_class