register.py 16 KB

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