__init__.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. def build_metric(config):
  21. from .det_metric import DetMetric
  22. from .rec_metric import RecMetric
  23. from .cls_metric import ClsMetric
  24. support_dict = ['DetMetric', 'RecMetric', 'ClsMetric']
  25. config = copy.deepcopy(config)
  26. module_name = config.pop('name')
  27. assert module_name in support_dict, Exception(
  28. 'metric only support {}'.format(support_dict))
  29. module_class = eval(module_name)(**config)
  30. return module_class