__init__.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # copyright (c) 2020 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. from __future__ import absolute_import
  15. from __future__ import division
  16. from __future__ import print_function
  17. from __future__ import unicode_literals
  18. import copy
  19. __all__ = ['build_post_process']
  20. from .db_postprocess import DBPostProcess, DistillationDBPostProcess
  21. from .east_postprocess import EASTPostProcess
  22. from .sast_postprocess import SASTPostProcess
  23. from .fce_postprocess import FCEPostProcess
  24. from .rec_postprocess import CTCLabelDecode, AttnLabelDecode, SRNLabelDecode, \
  25. DistillationCTCLabelDecode, NRTRLabelDecode, SARLabelDecode, \
  26. SEEDLabelDecode, PRENLabelDecode, ViTSTRLabelDecode, ABINetLabelDecode, \
  27. SPINLabelDecode, VLLabelDecode, RFLLabelDecode
  28. from .cls_postprocess import ClsPostProcess
  29. from .pg_postprocess import PGPostProcess
  30. from .vqa_token_ser_layoutlm_postprocess import VQASerTokenLayoutLMPostProcess, DistillationSerPostProcess
  31. from .vqa_token_re_layoutlm_postprocess import VQAReTokenLayoutLMPostProcess, DistillationRePostProcess
  32. from .table_postprocess import TableMasterLabelDecode, TableLabelDecode
  33. from .picodet_postprocess import PicoDetPostProcess
  34. from .ct_postprocess import CTPostProcess
  35. from .drrg_postprocess import DRRGPostprocess
  36. from .rec_postprocess import CANLabelDecode
  37. def build_post_process(config, global_config=None):
  38. support_dict = [
  39. 'DBPostProcess', 'EASTPostProcess', 'SASTPostProcess', 'FCEPostProcess',
  40. 'CTCLabelDecode', 'AttnLabelDecode', 'ClsPostProcess', 'SRNLabelDecode',
  41. 'PGPostProcess', 'DistillationCTCLabelDecode', 'TableLabelDecode',
  42. 'DistillationDBPostProcess', 'NRTRLabelDecode', 'SARLabelDecode',
  43. 'SEEDLabelDecode', 'VQASerTokenLayoutLMPostProcess',
  44. 'VQAReTokenLayoutLMPostProcess', 'PRENLabelDecode',
  45. 'DistillationSARLabelDecode', 'ViTSTRLabelDecode', 'ABINetLabelDecode',
  46. 'TableMasterLabelDecode', 'SPINLabelDecode',
  47. 'DistillationSerPostProcess', 'DistillationRePostProcess',
  48. 'VLLabelDecode', 'PicoDetPostProcess', 'CTPostProcess',
  49. 'RFLLabelDecode', 'DRRGPostprocess', 'CANLabelDecode'
  50. ]
  51. if config['name'] == 'PSEPostProcess':
  52. from .pse_postprocess import PSEPostProcess
  53. support_dict.append('PSEPostProcess')
  54. config = copy.deepcopy(config)
  55. module_name = config.pop('name')
  56. if module_name == "None":
  57. return
  58. if global_config is not None:
  59. config.update(global_config)
  60. assert module_name in support_dict, Exception(
  61. 'post process only support {}'.format(support_dict))
  62. module_class = eval(module_name)(**config)
  63. return module_class