__init__.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. from .iaa_augment import IaaAugment
  19. from .make_border_map import MakeBorderMap
  20. from .make_shrink_map import MakeShrinkMap
  21. from .random_crop_data import EastRandomCropData, RandomCropImgMask
  22. from .make_pse_gt import MakePseGt
  23. from .rec_img_aug import BaseDataAugmentation, RecAug, RecConAug, RecResizeImg, ClsResizeImg, \
  24. SRNRecResizeImg, GrayRecResizeImg, SARRecResizeImg, PRENResizeImg, \
  25. ABINetRecResizeImg, SVTRRecResizeImg, ABINetRecAug, VLRecResizeImg, SPINRecResizeImg, RobustScannerRecResizeImg, \
  26. RFLRecResizeImg, SVTRRecAug
  27. from .ssl_img_aug import SSLRotateResize
  28. from .randaugment import RandAugment
  29. from .copy_paste import CopyPaste
  30. from .ColorJitter import ColorJitter
  31. from .operators import *
  32. from .label_ops import *
  33. from .east_process import *
  34. from .sast_process import *
  35. from .pg_process import *
  36. from .table_ops import *
  37. from .vqa import *
  38. from .fce_aug import *
  39. from .fce_targets import FCENetTargets
  40. from .ct_process import *
  41. from .drrg_targets import DRRGTargets
  42. def transform(data, ops=None):
  43. """ transform """
  44. if ops is None:
  45. ops = []
  46. for op in ops:
  47. data = op(data)
  48. if data is None:
  49. return None
  50. return data
  51. def create_operators(op_param_list, global_config=None):
  52. """
  53. create operators based on the config
  54. Args:
  55. params(list): a dict list, used to create some operators
  56. """
  57. assert isinstance(op_param_list, list), ('operator config should be a list')
  58. ops = []
  59. for operator in op_param_list:
  60. assert isinstance(operator,
  61. dict) and len(operator) == 1, "yaml format error"
  62. op_name = list(operator)[0]
  63. param = {} if operator[op_name] is None else operator[op_name]
  64. if global_config is not None:
  65. param.update(global_config)
  66. op = eval(op_name)(**param)
  67. ops.append(op)
  68. return ops