__init__.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  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. __all__ = ['build_backbone']
  15. def build_backbone(config, model_type):
  16. if model_type == 'det':
  17. from .det_mobilenet_v3 import MobileNetV3
  18. from .det_resnet_vd import ResNet
  19. from .det_resnet_vd_sast import ResNet_SAST
  20. support_dict = ['MobileNetV3', 'ResNet', 'ResNet_SAST']
  21. elif model_type == 'rec' or model_type == 'cls':
  22. from .rec_mobilenet_v3 import MobileNetV3
  23. from .rec_resnet_vd import ResNet
  24. from .rec_resnet_fpn import ResNetFPN
  25. support_dict = ['MobileNetV3', 'ResNet', 'ResNetFPN']
  26. else:
  27. raise NotImplementedError
  28. module_name = config.pop('name')
  29. assert module_name in support_dict, Exception(
  30. 'when model typs is {}, backbone only support {}'.format(model_type,
  31. support_dict))
  32. module_class = eval(module_name)(**config)
  33. return module_class