__init__.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_metric"]
  20. from .det_metric import DetMetric, DetFCEMetric
  21. from .rec_metric import RecMetric, CNTMetric, CANMetric, LaTeXOCRMetric
  22. from .cls_metric import ClsMetric
  23. from .e2e_metric import E2EMetric
  24. from .distillation_metric import DistillationMetric
  25. from .table_metric import TableMetric
  26. from .kie_metric import KIEMetric
  27. from .vqa_token_ser_metric import VQASerTokenMetric
  28. from .vqa_token_re_metric import VQAReTokenMetric
  29. from .sr_metric import SRMetric
  30. from .ct_metric import CTMetric
  31. def build_metric(config):
  32. support_dict = [
  33. "DetMetric",
  34. "DetFCEMetric",
  35. "RecMetric",
  36. "ClsMetric",
  37. "E2EMetric",
  38. "DistillationMetric",
  39. "TableMetric",
  40. "KIEMetric",
  41. "VQASerTokenMetric",
  42. "VQAReTokenMetric",
  43. "SRMetric",
  44. "CTMetric",
  45. "CNTMetric",
  46. "CANMetric",
  47. "LaTeXOCRMetric",
  48. ]
  49. config = copy.deepcopy(config)
  50. module_name = config.pop("name")
  51. assert module_name in support_dict, Exception(
  52. "metric only support {}".format(support_dict)
  53. )
  54. module_class = eval(module_name)(**config)
  55. return module_class