register.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. # copyright (c) 2024 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. import os
  15. import os.path as osp
  16. from pathlib import Path
  17. from ...base.register import register_model_info, register_suite_info
  18. from .model import TextRecModel
  19. from .runner import TextRecRunner
  20. from .config import TextRecConfig
  21. REPO_ROOT_PATH = os.environ.get("PADDLE_PDX_PADDLEOCR_PATH")
  22. PDX_CONFIG_DIR = osp.abspath(osp.join(osp.dirname(__file__), "..", "configs"))
  23. register_suite_info(
  24. {
  25. "suite_name": "TextRec",
  26. "model": TextRecModel,
  27. "runner": TextRecRunner,
  28. "config": TextRecConfig,
  29. "runner_root_path": REPO_ROOT_PATH,
  30. }
  31. )
  32. register_model_info(
  33. {
  34. "model_name": "PP-OCRv3_mobile_rec",
  35. "suite": "TextRec",
  36. "config_path": osp.join(PDX_CONFIG_DIR, "PP-OCRv3_mobile_rec.yaml"),
  37. "supported_apis": ["train", "evaluate", "predict", "export"],
  38. }
  39. )
  40. register_model_info(
  41. {
  42. "model_name": "en_PP-OCRv3_mobile_rec",
  43. "suite": "TextRec",
  44. "config_path": osp.join(PDX_CONFIG_DIR, "en_PP-OCRv3_mobile_rec.yaml"),
  45. "supported_apis": ["train", "evaluate", "predict", "export"],
  46. }
  47. )
  48. register_model_info(
  49. {
  50. "model_name": "korean_PP-OCRv3_mobile_rec",
  51. "suite": "TextRec",
  52. "config_path": osp.join(PDX_CONFIG_DIR, "korean_PP-OCRv3_mobile_rec.yml"),
  53. "supported_apis": ["train", "evaluate", "predict", "export"],
  54. }
  55. )
  56. register_model_info(
  57. {
  58. "model_name": "japan_PP-OCRv3_mobile_rec",
  59. "suite": "TextRec",
  60. "config_path": osp.join(PDX_CONFIG_DIR, "japan_PP-OCRv3_mobile_rec.yaml"),
  61. "supported_apis": ["train", "evaluate", "predict", "export"],
  62. }
  63. )
  64. register_model_info(
  65. {
  66. "model_name": "chinese_cht_PP-OCRv3_mobile_rec",
  67. "suite": "TextRec",
  68. "config_path": osp.join(PDX_CONFIG_DIR, "chinese_cht_PP-OCRv3_mobile_rec.yaml"),
  69. "supported_apis": ["train", "evaluate", "predict", "export"],
  70. }
  71. )
  72. register_model_info(
  73. {
  74. "model_name": "te_PP-OCRv3_mobile_rec",
  75. "suite": "TextRec",
  76. "config_path": osp.join(PDX_CONFIG_DIR, "te_PP-OCRv3_mobile_rec.yaml"),
  77. "supported_apis": ["train", "evaluate", "predict", "export"],
  78. }
  79. )
  80. register_model_info(
  81. {
  82. "model_name": "ka_PP-OCRv3_mobile_rec",
  83. "suite": "TextRec",
  84. "config_path": osp.join(PDX_CONFIG_DIR, "ka_PP-OCRv3_mobile_rec.yaml"),
  85. "supported_apis": ["train", "evaluate", "predict", "export"],
  86. }
  87. )
  88. register_model_info(
  89. {
  90. "model_name": "ta_PP-OCRv3_mobile_rec",
  91. "suite": "TextRec",
  92. "config_path": osp.join(PDX_CONFIG_DIR, "ta_PP-OCRv3_mobile_rec.yaml"),
  93. "supported_apis": ["train", "evaluate", "predict", "export"],
  94. }
  95. )
  96. register_model_info(
  97. {
  98. "model_name": "latin_PP-OCRv3_mobile_rec",
  99. "suite": "TextRec",
  100. "config_path": osp.join(PDX_CONFIG_DIR, "latin_PP-OCRv3_mobile_rec.yaml"),
  101. "supported_apis": ["train", "evaluate", "predict", "export"],
  102. }
  103. )
  104. register_model_info(
  105. {
  106. "model_name": "arabic_PP-OCRv3_mobile_rec",
  107. "suite": "TextRec",
  108. "config_path": osp.join(PDX_CONFIG_DIR, "arabic_PP-OCRv3_mobile_rec.yaml"),
  109. "supported_apis": ["train", "evaluate", "predict", "export"],
  110. }
  111. )
  112. register_model_info(
  113. {
  114. "model_name": "cyrillic_PP-OCRv3_mobile_rec",
  115. "suite": "TextRec",
  116. "config_path": osp.join(PDX_CONFIG_DIR, "cyrillic_PP-OCRv3_mobile_rec.yaml"),
  117. "supported_apis": ["train", "evaluate", "predict", "export"],
  118. }
  119. )
  120. register_model_info(
  121. {
  122. "model_name": "devanagari_PP-OCRv3_mobile_rec",
  123. "suite": "TextRec",
  124. "config_path": osp.join(PDX_CONFIG_DIR, "devanagari_PP-OCRv3_mobile_rec.yaml"),
  125. "supported_apis": ["train", "evaluate", "predict", "export"],
  126. }
  127. )
  128. register_model_info(
  129. {
  130. "model_name": "PP-OCRv4_mobile_rec",
  131. "suite": "TextRec",
  132. "config_path": osp.join(PDX_CONFIG_DIR, "PP-OCRv4_mobile_rec.yaml"),
  133. "supported_apis": ["train", "evaluate", "predict", "export"],
  134. }
  135. )
  136. register_model_info(
  137. {
  138. "model_name": "PP-OCRv4_server_rec",
  139. "suite": "TextRec",
  140. "config_path": osp.join(PDX_CONFIG_DIR, "PP-OCRv4_server_rec.yaml"),
  141. "supported_apis": ["train", "evaluate", "predict", "export"],
  142. }
  143. )
  144. register_model_info(
  145. {
  146. "model_name": "en_PP-OCRv4_mobile_rec",
  147. "suite": "TextRec",
  148. "config_path": osp.join(PDX_CONFIG_DIR, "en_PP-OCRv4_mobile_rec.yaml"),
  149. "supported_apis": ["train", "evaluate", "predict", "export"],
  150. }
  151. )
  152. register_model_info(
  153. {
  154. "model_name": "PP-OCRv4_server_rec_doc",
  155. "suite": "TextRec",
  156. "config_path": osp.join(PDX_CONFIG_DIR, "PP-OCRv4_server_rec_doc.yaml"),
  157. "supported_apis": ["train", "evaluate", "predict", "export"],
  158. }
  159. )
  160. register_model_info(
  161. {
  162. "model_name": "ch_SVTRv2_rec",
  163. "suite": "TextRec",
  164. "config_path": osp.join(PDX_CONFIG_DIR, "ch_SVTRv2_rec.yaml"),
  165. "supported_apis": ["train", "evaluate", "predict", "export", "infer"],
  166. }
  167. )
  168. register_model_info(
  169. {
  170. "model_name": "ch_RepSVTR_rec",
  171. "suite": "TextRec",
  172. "config_path": osp.join(PDX_CONFIG_DIR, "ch_RepSVTR_rec.yaml"),
  173. "supported_apis": ["train", "evaluate", "predict", "export", "infer"],
  174. }
  175. )