register.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 ...base.register import register_model_info, register_suite_info
  17. from ..ts_base.model import TSModel
  18. from .runner import TSADRunner
  19. from .config import TSAnomalyConfig
  20. REPO_ROOT_PATH = os.environ.get("PADDLE_PDX_PADDLETS_PATH")
  21. PDX_CONFIG_DIR = osp.abspath(osp.join(osp.dirname(__file__), "..", "configs"))
  22. register_suite_info(
  23. {
  24. "suite_name": "TSAnomaly",
  25. "model": TSModel,
  26. "runner": TSADRunner,
  27. "config": TSAnomalyConfig,
  28. "runner_root_path": REPO_ROOT_PATH,
  29. }
  30. )
  31. ################ Models Using Universal Config ################
  32. # timesnet
  33. TimesNetAD_CFG_PATH = osp.join(PDX_CONFIG_DIR, "TimesNet_ad.yaml")
  34. register_model_info(
  35. {
  36. "model_name": "TimesNet_ad",
  37. "suite": "TSAnomaly",
  38. "config_path": TimesNetAD_CFG_PATH,
  39. "auto_compression_config_path": TimesNetAD_CFG_PATH,
  40. "supported_apis": ["train", "evaluate", "predict", "export"],
  41. "supported_train_opts": {
  42. "device": ["cpu", "gpu_n1cx"],
  43. "dy2st": False,
  44. "amp": [],
  45. },
  46. "supported_evaluate_opts": {"device": ["cpu", "gpu_n1cx"], "amp": []},
  47. "supported_predict_opts": {"device": ["cpu", "gpu"]},
  48. "supported_infer_opts": {"device": ["cpu", "gpu"]},
  49. "supported_compression_opts": {"device": ["cpu", "gpu_n1cx"]},
  50. }
  51. )
  52. # autoencoder_anomaly
  53. AE_CFG_PATH = osp.join(PDX_CONFIG_DIR, "AutoEncoder_ad.yaml")
  54. register_model_info(
  55. {
  56. "model_name": "AutoEncoder_ad",
  57. "suite": "TSAnomaly",
  58. "config_path": AE_CFG_PATH,
  59. "supported_apis": ["train", "evaluate", "predict", "export"],
  60. "supported_train_opts": {
  61. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  62. "dy2st": False,
  63. "amp": [],
  64. },
  65. "supported_evaluate_opts": {
  66. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  67. "amp": [],
  68. },
  69. "supported_predict_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  70. "supported_infer_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  71. }
  72. )
  73. # dlinear_anomaly
  74. DL_CFG_PATH = osp.join(PDX_CONFIG_DIR, "DLinear_ad.yaml")
  75. register_model_info(
  76. {
  77. "model_name": "DLinear_ad",
  78. "suite": "TSAnomaly",
  79. "config_path": DL_CFG_PATH,
  80. "supported_apis": ["train", "evaluate", "predict", "export"],
  81. "supported_train_opts": {
  82. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  83. "dy2st": False,
  84. "amp": [],
  85. },
  86. "supported_evaluate_opts": {
  87. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  88. "amp": [],
  89. },
  90. "supported_predict_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  91. "supported_infer_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  92. }
  93. )
  94. # patch_anomaly
  95. PATCHTST_CFG_PATH = osp.join(PDX_CONFIG_DIR, "PatchTST_ad.yaml")
  96. register_model_info(
  97. {
  98. "model_name": "PatchTST_ad",
  99. "suite": "TSAnomaly",
  100. "config_path": PATCHTST_CFG_PATH,
  101. "supported_apis": ["train", "evaluate", "predict", "export"],
  102. "supported_train_opts": {
  103. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  104. "dy2st": False,
  105. "amp": [],
  106. },
  107. "supported_evaluate_opts": {
  108. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  109. "amp": [],
  110. },
  111. "supported_predict_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  112. "supported_infer_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  113. }
  114. )
  115. # ns_anomaly
  116. NS_CFG_PATH = osp.join(PDX_CONFIG_DIR, "Nonstationary_ad.yaml")
  117. register_model_info(
  118. {
  119. "model_name": "Nonstationary_ad",
  120. "suite": "TSAnomaly",
  121. "config_path": NS_CFG_PATH,
  122. "supported_apis": ["train", "evaluate", "predict", "export"],
  123. "supported_train_opts": {
  124. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  125. "dy2st": False,
  126. "amp": [],
  127. },
  128. "supported_evaluate_opts": {
  129. "device": ["cpu", "gpu_n1cx", "xpu", "npu", "mlu"],
  130. "amp": [],
  131. },
  132. "supported_predict_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  133. "supported_infer_opts": {"device": ["cpu", "gpu", "xpu", "npu", "mlu"]},
  134. }
  135. )