__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 (
  24. BaseDataAugmentation,
  25. RecAug,
  26. RecConAug,
  27. RecResizeImg,
  28. ClsResizeImg,
  29. SRNRecResizeImg,
  30. GrayRecResizeImg,
  31. SARRecResizeImg,
  32. PRENResizeImg,
  33. ABINetRecResizeImg,
  34. SVTRRecResizeImg,
  35. ABINetRecAug,
  36. VLRecResizeImg,
  37. SPINRecResizeImg,
  38. RobustScannerRecResizeImg,
  39. RFLRecResizeImg,
  40. SVTRRecAug,
  41. ParseQRecAug,
  42. )
  43. from .ssl_img_aug import SSLRotateResize
  44. from .randaugment import RandAugment
  45. from .copy_paste import CopyPaste
  46. from .ColorJitter import ColorJitter
  47. from .operators import *
  48. from .label_ops import *
  49. from .east_process import *
  50. from .sast_process import *
  51. from .pg_process import *
  52. from .table_ops import *
  53. from .vqa import *
  54. from .fce_aug import *
  55. from .fce_targets import FCENetTargets
  56. from .ct_process import *
  57. from .drrg_targets import DRRGTargets
  58. from .latex_ocr_aug import *
  59. from .unimernet_aug import *
  60. def transform(data, ops=None):
  61. """transform"""
  62. if ops is None:
  63. ops = []
  64. for op in ops:
  65. data = op(data)
  66. if data is None:
  67. return None
  68. return data
  69. def create_operators(op_param_list, global_config=None):
  70. """
  71. create operators based on the config
  72. Args:
  73. params(list): a dict list, used to create some operators
  74. """
  75. assert isinstance(op_param_list, list), "operator config should be a list"
  76. ops = []
  77. for operator in op_param_list:
  78. assert isinstance(operator, dict) and len(operator) == 1, "yaml format error"
  79. op_name = list(operator)[0]
  80. param = {} if operator[op_name] is None else operator[op_name]
  81. if global_config is not None:
  82. param.update(global_config)
  83. op = eval(op_name)(**param)
  84. ops.append(op)
  85. return ops