__init__.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. def build_post_process(config, global_config=None):
  21. from .db_postprocess import DBPostProcess
  22. from .east_postprocess import EASTPostProcess
  23. from .sast_postprocess import SASTPostProcess
  24. from .rec_postprocess import CTCLabelDecode, AttnLabelDecode, SRNLabelDecode
  25. from .cls_postprocess import ClsPostProcess
  26. support_dict = [
  27. 'DBPostProcess', 'EASTPostProcess', 'SASTPostProcess', 'CTCLabelDecode',
  28. 'AttnLabelDecode', 'ClsPostProcess', 'SRNLabelDecode'
  29. ]
  30. config = copy.deepcopy(config)
  31. module_name = config.pop('name')
  32. if global_config is not None:
  33. config.update(global_config)
  34. assert module_name in support_dict, Exception(
  35. 'post process only support {}'.format(support_dict))
  36. module_class = eval(module_name)(**config)
  37. return module_class