register.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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', 'infer'],
  36. 'infer_config': 'deploy/configs/inference_cls.yaml'
  37. })
  38. register_model_info({
  39. 'model_name': 'PP-LCNet_x0_25',
  40. 'suite': 'Cls',
  41. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_25.yaml'),
  42. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  43. 'infer_config': 'deploy/configs/inference_cls.yaml'
  44. })
  45. register_model_info({
  46. 'model_name': 'PP-LCNet_x0_35',
  47. 'suite': 'Cls',
  48. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_35.yaml'),
  49. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  50. 'infer_config': 'deploy/configs/inference_cls.yaml'
  51. })
  52. register_model_info({
  53. 'model_name': 'PP-LCNet_x0_5',
  54. 'suite': 'Cls',
  55. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_5.yaml'),
  56. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  57. 'infer_config': 'deploy/configs/inference_cls.yaml'
  58. })
  59. register_model_info({
  60. 'model_name': 'PP-LCNet_x0_75',
  61. 'suite': 'Cls',
  62. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x0_75.yaml'),
  63. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  64. 'infer_config': 'deploy/configs/inference_cls.yaml'
  65. })
  66. register_model_info({
  67. 'model_name': 'PP-LCNet_x1_0',
  68. 'suite': 'Cls',
  69. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x1_0.yaml'),
  70. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  71. 'infer_config': 'deploy/configs/inference_cls.yaml'
  72. })
  73. register_model_info({
  74. 'model_name': 'PP-LCNet_x1_5',
  75. 'suite': 'Cls',
  76. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x1_5.yaml'),
  77. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  78. 'infer_config': 'deploy/configs/inference_cls.yaml'
  79. })
  80. register_model_info({
  81. 'model_name': 'PP-LCNet_x2_0',
  82. 'suite': 'Cls',
  83. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x2_0.yaml'),
  84. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  85. 'infer_config': 'deploy/configs/inference_cls.yaml'
  86. })
  87. register_model_info({
  88. 'model_name': 'PP-LCNet_x2_5',
  89. 'suite': 'Cls',
  90. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNet_x2_5.yaml'),
  91. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  92. 'infer_config': 'deploy/configs/inference_cls.yaml'
  93. })
  94. register_model_info({
  95. 'model_name': 'PP-LCNetV2_small',
  96. 'suite': 'Cls',
  97. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_small.yaml'),
  98. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  99. 'infer_config': 'deploy/configs/inference_cls.yaml'
  100. })
  101. register_model_info({
  102. 'model_name': 'PP-LCNetV2_base',
  103. 'suite': 'Cls',
  104. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_base.yaml'),
  105. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  106. 'infer_config': 'deploy/configs/inference_cls.yaml'
  107. })
  108. register_model_info({
  109. 'model_name': 'PP-LCNetV2_large',
  110. 'suite': 'Cls',
  111. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-LCNetV2_large.yaml'),
  112. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  113. 'infer_config': 'deploy/configs/inference_cls.yaml'
  114. })
  115. register_model_info({
  116. 'model_name': 'CLIP_vit_base_patch16_224',
  117. 'suite': 'Cls',
  118. 'config_path': osp.join(PDX_CONFIG_DIR, 'CLIP_vit_base_patch16_224.yaml'),
  119. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  120. 'infer_config': 'deploy/configs/inference_cls.yaml'
  121. })
  122. register_model_info({
  123. 'model_name': 'CLIP_vit_large_patch14_224',
  124. 'suite': 'Cls',
  125. 'config_path': osp.join(PDX_CONFIG_DIR, 'CLIP_vit_large_patch14_224.yaml'),
  126. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  127. 'infer_config': 'deploy/configs/inference_cls.yaml'
  128. })
  129. register_model_info({
  130. 'model_name': 'PP-HGNet_small',
  131. 'suite': 'Cls',
  132. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNet_small.yaml'),
  133. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  134. 'infer_config': 'deploy/configs/inference_cls.yaml'
  135. })
  136. register_model_info({
  137. 'model_name': 'PP-HGNetV2-B0',
  138. 'suite': 'Cls',
  139. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B0.yaml'),
  140. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  141. 'infer_config': 'deploy/configs/inference_cls.yaml'
  142. })
  143. register_model_info({
  144. 'model_name': 'PP-HGNetV2-B4',
  145. 'suite': 'Cls',
  146. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B4.yaml'),
  147. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  148. 'infer_config': 'deploy/configs/inference_cls.yaml'
  149. })
  150. register_model_info({
  151. 'model_name': 'PP-HGNetV2-B6',
  152. 'suite': 'Cls',
  153. 'config_path': osp.join(PDX_CONFIG_DIR, 'PP-HGNetV2-B6.yaml'),
  154. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  155. 'infer_config': 'deploy/configs/inference_cls.yaml'
  156. })
  157. register_model_info({
  158. 'model_name': 'ResNet18',
  159. 'suite': 'Cls',
  160. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet18.yaml'),
  161. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  162. 'infer_config': 'deploy/configs/inference_cls.yaml'
  163. })
  164. register_model_info({
  165. 'model_name': 'ResNet18_vd',
  166. 'suite': 'Cls',
  167. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet18_vd.yaml'),
  168. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  169. 'infer_config': 'deploy/configs/inference_cls.yaml'
  170. })
  171. register_model_info({
  172. 'model_name': 'ResNet34',
  173. 'suite': 'Cls',
  174. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet34.yaml'),
  175. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  176. 'infer_config': 'deploy/configs/inference_cls.yaml'
  177. })
  178. register_model_info({
  179. 'model_name': 'ResNet34_vd',
  180. 'suite': 'Cls',
  181. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet34_vd.yaml'),
  182. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  183. 'infer_config': 'deploy/configs/inference_cls.yaml'
  184. })
  185. register_model_info({
  186. 'model_name': 'ResNet50',
  187. 'suite': 'Cls',
  188. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet50.yaml'),
  189. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  190. 'infer_config': 'deploy/configs/inference_cls.yaml'
  191. })
  192. register_model_info({
  193. 'model_name': 'ResNet50_vd',
  194. 'suite': 'Cls',
  195. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet50_vd.yaml'),
  196. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  197. 'infer_config': 'deploy/configs/inference_cls.yaml'
  198. })
  199. register_model_info({
  200. 'model_name': 'ResNet101',
  201. 'suite': 'Cls',
  202. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet101.yaml'),
  203. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  204. 'infer_config': 'deploy/configs/inference_cls.yaml'
  205. })
  206. register_model_info({
  207. 'model_name': 'ResNet101_vd',
  208. 'suite': 'Cls',
  209. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet101_vd.yaml'),
  210. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  211. 'infer_config': 'deploy/configs/inference_cls.yaml'
  212. })
  213. register_model_info({
  214. 'model_name': 'ResNet152',
  215. 'suite': 'Cls',
  216. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet152.yaml'),
  217. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  218. 'infer_config': 'deploy/configs/inference_cls.yaml'
  219. })
  220. register_model_info({
  221. 'model_name': 'ResNet152_vd',
  222. 'suite': 'Cls',
  223. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet152_vd.yaml'),
  224. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  225. 'infer_config': 'deploy/configs/inference_cls.yaml'
  226. })
  227. register_model_info({
  228. 'model_name': 'ResNet200_vd',
  229. 'suite': 'Cls',
  230. 'config_path': osp.join(PDX_CONFIG_DIR, 'ResNet200_vd.yaml'),
  231. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  232. 'infer_config': 'deploy/configs/inference_cls.yaml'
  233. })
  234. register_model_info({
  235. 'model_name': 'MobileNetV2_x0_25',
  236. 'suite': 'Cls',
  237. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x0_25.yaml'),
  238. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  239. 'infer_config': 'deploy/configs/inference_cls.yaml'
  240. })
  241. register_model_info({
  242. 'model_name': 'MobileNetV2_x0_5',
  243. 'suite': 'Cls',
  244. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x0_5.yaml'),
  245. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  246. 'infer_config': 'deploy/configs/inference_cls.yaml'
  247. })
  248. register_model_info({
  249. 'model_name': 'MobileNetV2_x1_0',
  250. 'suite': 'Cls',
  251. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x1_0.yaml'),
  252. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  253. 'infer_config': 'deploy/configs/inference_cls.yaml'
  254. })
  255. register_model_info({
  256. 'model_name': 'MobileNetV2_x1_5',
  257. 'suite': 'Cls',
  258. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x1_5.yaml'),
  259. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  260. 'infer_config': 'deploy/configs/inference_cls.yaml'
  261. })
  262. register_model_info({
  263. 'model_name': 'MobileNetV2_x2_0',
  264. 'suite': 'Cls',
  265. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV2_x2_0.yaml'),
  266. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  267. 'infer_config': 'deploy/configs/inference_cls.yaml'
  268. })
  269. register_model_info({
  270. 'model_name': 'MobileNetV3_large_x0_35',
  271. 'suite': 'Cls',
  272. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_35.yaml'),
  273. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  274. 'infer_config': 'deploy/configs/inference_cls.yaml'
  275. })
  276. register_model_info({
  277. 'model_name': 'MobileNetV3_large_x0_5',
  278. 'suite': 'Cls',
  279. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_5.yaml'),
  280. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  281. 'infer_config': 'deploy/configs/inference_cls.yaml'
  282. })
  283. register_model_info({
  284. 'model_name': 'MobileNetV3_large_x0_75',
  285. 'suite': 'Cls',
  286. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x0_75.yaml'),
  287. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  288. 'infer_config': 'deploy/configs/inference_cls.yaml'
  289. })
  290. register_model_info({
  291. 'model_name': 'MobileNetV3_large_x1_0',
  292. 'suite': 'Cls',
  293. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x1_0.yaml'),
  294. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  295. 'infer_config': 'deploy/configs/inference_cls.yaml'
  296. })
  297. register_model_info({
  298. 'model_name': 'MobileNetV3_large_x1_25',
  299. 'suite': 'Cls',
  300. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_large_x1_25.yaml'),
  301. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  302. 'infer_config': 'deploy/configs/inference_cls.yaml'
  303. })
  304. register_model_info({
  305. 'model_name': 'MobileNetV3_small_x0_35',
  306. 'suite': 'Cls',
  307. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_35.yaml'),
  308. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  309. 'infer_config': 'deploy/configs/inference_cls.yaml'
  310. })
  311. register_model_info({
  312. 'model_name': 'MobileNetV3_small_x0_5',
  313. 'suite': 'Cls',
  314. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_5.yaml'),
  315. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  316. 'infer_config': 'deploy/configs/inference_cls.yaml'
  317. })
  318. register_model_info({
  319. 'model_name': 'MobileNetV3_small_x0_75',
  320. 'suite': 'Cls',
  321. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x0_75.yaml'),
  322. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  323. 'infer_config': 'deploy/configs/inference_cls.yaml'
  324. })
  325. register_model_info({
  326. 'model_name': 'MobileNetV3_small_x1_0',
  327. 'suite': 'Cls',
  328. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x1_0.yaml'),
  329. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  330. 'infer_config': 'deploy/configs/inference_cls.yaml'
  331. })
  332. register_model_info({
  333. 'model_name': 'MobileNetV3_small_x1_25',
  334. 'suite': 'Cls',
  335. 'config_path': osp.join(PDX_CONFIG_DIR, 'MobileNetV3_small_x1_25.yaml'),
  336. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  337. 'infer_config': 'deploy/configs/inference_cls.yaml'
  338. })
  339. register_model_info({
  340. 'model_name': 'ConvNeXt_tiny',
  341. 'suite': 'Cls',
  342. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_tiny.yaml'),
  343. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  344. 'infer_config': 'deploy/configs/inference_cls.yaml'
  345. })
  346. register_model_info({
  347. 'model_name': 'ConvNeXt_small',
  348. 'suite': 'Cls',
  349. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_small.yaml'),
  350. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  351. 'infer_config': 'deploy/configs/inference_cls.yaml'
  352. })
  353. register_model_info({
  354. 'model_name': 'ConvNeXt_base_224',
  355. 'suite': 'Cls',
  356. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_base_224.yaml'),
  357. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  358. 'infer_config': 'deploy/configs/inference_cls.yaml'
  359. })
  360. register_model_info({
  361. 'model_name': 'ConvNeXt_base_384',
  362. 'suite': 'Cls',
  363. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_base_384.yaml'),
  364. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  365. 'infer_config': 'deploy/configs/inference_cls.yaml'
  366. })
  367. register_model_info({
  368. 'model_name': 'ConvNeXt_large_224',
  369. 'suite': 'Cls',
  370. 'config_path': osp.join(PDX_CONFIG_DIR, 'ConvNeXt_large_384.yaml'),
  371. 'supported_apis': ['train', 'evaluate', 'predict', 'export', 'infer'],
  372. 'infer_config': 'deploy/configs/inference_cls.yaml'
  373. })