register.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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 .model import ClsModel
  18. from .runner import ClsRunner
  19. from .config import ClsConfig
  20. REPO_ROOT_PATH = os.environ.get('PADDLE_PDX_PADDLECLAS_PATH')
  21. PDX_CONFIG_DIR = osp.abspath(osp.join(osp.dirname(__file__), '..', 'configs'))
  22. register_suite_info({
  23. 'suite_name': 'Cls',
  24. 'model': ClsModel,
  25. 'runner': ClsRunner,
  26. 'config': ClsConfig,
  27. 'runner_root_path': REPO_ROOT_PATH
  28. })
  29. ################ Models Using Universal Config ################
  30. register_model_info({
  31. 'model_name': 'SwinTransformer_base_patch4_window7_224',
  32. 'suite': 'Cls',
  33. 'config_path': osp.join(PDX_CONFIG_DIR,
  34. 'SwinTransformer_base_patch4_window7_224.yaml'),
  35. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  36. })
  37. register_model_info({
  38. 'model_name': 'PP-LCNet_x0_25',
  39. 'suite': 'Cls',
  40. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_25.yaml'),
  41. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  42. })
  43. register_model_info({
  44. 'model_name': 'PP-LCNet_x0_35',
  45. 'suite': 'Cls',
  46. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_35.yaml'),
  47. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  48. })
  49. register_model_info({
  50. 'model_name': 'PP-LCNet_x0_5',
  51. 'suite': 'Cls',
  52. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_5.yaml'),
  53. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  54. })
  55. register_model_info({
  56. 'model_name': 'PP-LCNet_x0_75',
  57. 'suite': 'Cls',
  58. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_75.yaml'),
  59. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  60. })
  61. register_model_info({
  62. 'model_name': 'PP-LCNet_x1_0',
  63. 'suite': 'Cls',
  64. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x1_0.yaml'),
  65. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  66. })
  67. register_model_info({
  68. 'model_name': 'PP-LCNet_x1_5',
  69. 'suite': 'Cls',
  70. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x1_5.yaml'),
  71. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  72. })
  73. register_model_info({
  74. 'model_name': 'PP-LCNet_x2_0',
  75. 'suite': 'Cls',
  76. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x2_0.yaml'),
  77. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  78. })
  79. register_model_info({
  80. 'model_name': 'PP-LCNet_x2_5',
  81. 'suite': 'Cls',
  82. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x2_5.yaml'),
  83. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  84. })
  85. register_model_info({
  86. 'model_name': 'PP-LCNetV2_small',
  87. 'suite': 'Cls',
  88. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_small.yaml'),
  89. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  90. })
  91. register_model_info({
  92. 'model_name': 'PP-LCNetV2_base',
  93. 'suite': 'Cls',
  94. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_base.yaml'),
  95. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  96. })
  97. register_model_info({
  98. 'model_name': 'PP-LCNetV2_large',
  99. 'suite': 'Cls',
  100. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_large.yaml'),
  101. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  102. })
  103. register_model_info({
  104. 'model_name': 'CLIP_vit_base_patch16_224',
  105. 'suite': 'Cls',
  106. 'config_path': osp.join(PDX_CONFIG_DIR, 'CLIP_vit_base_patch16_224.yaml'),
  107. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  108. })
  109. register_model_info({
  110. 'model_name': 'CLIP_vit_large_patch14_224',
  111. 'suite': 'Cls',
  112. 'config_path': osp.join(PDX_CONFIG_DIR, 'CLIP_vit_large_patch14_224.yaml'),
  113. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  114. })
  115. register_model_info({
  116. 'model_name': 'PP-HGNet_small',
  117. 'suite': 'Cls',
  118. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNet_small.yaml'),
  119. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  120. })
  121. register_model_info({
  122. 'model_name': 'PP-HGNetV2-B0',
  123. 'suite': 'Cls',
  124. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B0.yaml'),
  125. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  126. })
  127. register_model_info({
  128. 'model_name': 'PP-HGNetV2-B4',
  129. 'suite': 'Cls',
  130. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B4.yaml'),
  131. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  132. })
  133. register_model_info({
  134. 'model_name': 'PP-HGNetV2-B6',
  135. 'suite': 'Cls',
  136. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B6.yaml'),
  137. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  138. })
  139. register_model_info({
  140. 'model_name': 'ResNet18',
  141. 'suite': 'Cls',
  142. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet18.yaml'),
  143. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  144. })
  145. register_model_info({
  146. 'model_name': 'ResNet18_vd',
  147. 'suite': 'Cls',
  148. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet18_vd.yaml'),
  149. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  150. })
  151. register_model_info({
  152. 'model_name': 'ResNet34',
  153. 'suite': 'Cls',
  154. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet34.yaml'),
  155. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  156. })
  157. register_model_info({
  158. 'model_name': 'ResNet34_vd',
  159. 'suite': 'Cls',
  160. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet34_vd.yaml'),
  161. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  162. })
  163. register_model_info({
  164. 'model_name': 'ResNet50',
  165. 'suite': 'Cls',
  166. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet50.yaml'),
  167. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  168. })
  169. register_model_info({
  170. 'model_name': 'ResNet50_vd',
  171. 'suite': 'Cls',
  172. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet50_vd.yaml'),
  173. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  174. })
  175. register_model_info({
  176. 'model_name': 'ResNet101',
  177. 'suite': 'Cls',
  178. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet101.yaml'),
  179. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  180. })
  181. register_model_info({
  182. 'model_name': 'ResNet101_vd',
  183. 'suite': 'Cls',
  184. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet101_vd.yaml'),
  185. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  186. })
  187. register_model_info({
  188. 'model_name': 'ResNet152',
  189. 'suite': 'Cls',
  190. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet152.yaml'),
  191. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  192. })
  193. register_model_info({
  194. 'model_name': 'ResNet152_vd',
  195. 'suite': 'Cls',
  196. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet152_vd.yaml'),
  197. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  198. })
  199. register_model_info({
  200. 'model_name': 'ResNet200_vd',
  201. 'suite': 'Cls',
  202. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet200_vd.yaml'),
  203. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  204. })
  205. register_model_info({
  206. 'model_name': 'MobileNetV2_x0_25',
  207. 'suite': 'Cls',
  208. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x0_25.yaml'),
  209. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  210. })
  211. register_model_info({
  212. 'model_name': 'MobileNetV2_x0_5',
  213. 'suite': 'Cls',
  214. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x0_5.yaml'),
  215. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  216. })
  217. register_model_info({
  218. 'model_name': 'MobileNetV2_x1_0',
  219. 'suite': 'Cls',
  220. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x1_0.yaml'),
  221. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  222. })
  223. register_model_info({
  224. 'model_name': 'MobileNetV2_x1_5',
  225. 'suite': 'Cls',
  226. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x1_5.yaml'),
  227. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  228. })
  229. register_model_info({
  230. 'model_name': 'MobileNetV2_x2_0',
  231. 'suite': 'Cls',
  232. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x2_0.yaml'),
  233. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  234. })
  235. register_model_info({
  236. 'model_name': 'MobileNetV3_large_x0_35',
  237. 'suite': 'Cls',
  238. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_35.yaml'),
  239. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  240. })
  241. register_model_info({
  242. 'model_name': 'MobileNetV3_large_x0_5',
  243. 'suite': 'Cls',
  244. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_5.yaml'),
  245. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  246. })
  247. register_model_info({
  248. 'model_name': 'MobileNetV3_large_x0_75',
  249. 'suite': 'Cls',
  250. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_75.yaml'),
  251. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  252. })
  253. register_model_info({
  254. 'model_name': 'MobileNetV3_large_x1_0',
  255. 'suite': 'Cls',
  256. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x1_0.yaml'),
  257. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  258. })
  259. register_model_info({
  260. 'model_name': 'MobileNetV3_large_x1_25',
  261. 'suite': 'Cls',
  262. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x1_25.yaml'),
  263. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  264. })
  265. register_model_info({
  266. 'model_name': 'MobileNetV3_small_x0_35',
  267. 'suite': 'Cls',
  268. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_35.yaml'),
  269. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  270. })
  271. register_model_info({
  272. 'model_name': 'MobileNetV3_small_x0_5',
  273. 'suite': 'Cls',
  274. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_5.yaml'),
  275. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  276. })
  277. register_model_info({
  278. 'model_name': 'MobileNetV3_small_x0_75',
  279. 'suite': 'Cls',
  280. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_75.yaml'),
  281. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  282. })
  283. register_model_info({
  284. 'model_name': 'MobileNetV3_small_x1_0',
  285. 'suite': 'Cls',
  286. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x1_0.yaml'),
  287. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  288. })
  289. register_model_info({
  290. 'model_name': 'MobileNetV3_small_x1_25',
  291. 'suite': 'Cls',
  292. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x1_25.yaml'),
  293. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  294. })
  295. register_model_info({
  296. 'model_name': 'ConvNeXt_tiny',
  297. 'suite': 'Cls',
  298. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_tiny.yaml'),
  299. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  300. })
  301. register_model_info({
  302. 'model_name': 'ConvNeXt_small',
  303. 'suite': 'Cls',
  304. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_small.yaml'),
  305. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  306. })
  307. register_model_info({
  308. 'model_name': 'ConvNeXt_base_224',
  309. 'suite': 'Cls',
  310. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_base_224.yaml'),
  311. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  312. })
  313. register_model_info({
  314. 'model_name': 'ConvNeXt_base_384',
  315. 'suite': 'Cls',
  316. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_base_384.yaml'),
  317. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  318. })
  319. register_model_info({
  320. 'model_name': 'ConvNeXt_large_224',
  321. 'suite': 'Cls',
  322. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_large_384.yaml'),
  323. 'supported_apis': ['train', 'evaluate', 'predict', 'export'],
  324. })