mblt-vision-python 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. mblt_vision/__init__.py +86 -0
  2. mblt_vision/_api.py +53 -0
  3. mblt_vision/_compat.py +227 -0
  4. mblt_vision/_model_paths.py +137 -0
  5. mblt_vision/_tasks.py +30 -0
  6. mblt_vision/benchmark/__init__.py +1 -0
  7. mblt_vision/benchmark/argparse_utils.py +106 -0
  8. mblt_vision/benchmark/chart_utils.py +146 -0
  9. mblt_vision/benchmark/io_utils.py +64 -0
  10. mblt_vision/benchmark/summary_utils.py +770 -0
  11. mblt_vision/cli/__init__.py +5 -0
  12. mblt_vision/cli/__main__.py +5 -0
  13. mblt_vision/cli/_vision.py +337 -0
  14. mblt_vision/cli/compile.py +117 -0
  15. mblt_vision/cli/main.py +35 -0
  16. mblt_vision/cli/predict.py +64 -0
  17. mblt_vision/cli/val.py +562 -0
  18. mblt_vision/compile/__init__.py +21 -0
  19. mblt_vision/compile/vision.py +1120 -0
  20. mblt_vision/datasets/__init__.py +15 -0
  21. mblt_vision/datasets/ade20k.yaml +164 -0
  22. mblt_vision/datasets/cityscapes.yaml +54 -0
  23. mblt_vision/datasets/coco.yaml +178 -0
  24. mblt_vision/datasets/dotav1.yaml +28 -0
  25. mblt_vision/datasets/imagenet.yaml +1019 -0
  26. mblt_vision/datasets/imagenet_synsets.txt +1000 -0
  27. mblt_vision/datasets/nyu-depth.yaml +7 -0
  28. mblt_vision/datasets/registry.py +158 -0
  29. mblt_vision/datasets/widerface.yaml +9 -0
  30. mblt_vision/depth_estimation/__init__.py +19 -0
  31. mblt_vision/face_detection/__init__.py +43 -0
  32. mblt_vision/image_classification/__init__.py +311 -0
  33. mblt_vision/instance_segmentation/__init__.py +65 -0
  34. mblt_vision/models/AlexNet.yaml +23 -0
  35. mblt_vision/models/CAFormer_B36.yaml +22 -0
  36. mblt_vision/models/CAFormer_M36.yaml +22 -0
  37. mblt_vision/models/CAFormer_S18.yaml +22 -0
  38. mblt_vision/models/CAFormer_S36.yaml +22 -0
  39. mblt_vision/models/CoAtNet_0_RW_224.yaml +22 -0
  40. mblt_vision/models/CoAtNet_1_RW_224.yaml +22 -0
  41. mblt_vision/models/CoAtNet_2_RW_224.yaml +22 -0
  42. mblt_vision/models/ConvFormer_B36.yaml +22 -0
  43. mblt_vision/models/ConvFormer_M36.yaml +22 -0
  44. mblt_vision/models/ConvFormer_S18.yaml +22 -0
  45. mblt_vision/models/ConvFormer_S36.yaml +22 -0
  46. mblt_vision/models/ConvNext_Base.yaml +23 -0
  47. mblt_vision/models/ConvNext_Large.yaml +23 -0
  48. mblt_vision/models/ConvNext_Small.yaml +23 -0
  49. mblt_vision/models/ConvNext_Tiny.yaml +23 -0
  50. mblt_vision/models/DeiT3_Base_Patch16_224.yaml +22 -0
  51. mblt_vision/models/DeiT3_Base_Patch16_384.yaml +22 -0
  52. mblt_vision/models/DeiT3_Large_Patch16_224.yaml +22 -0
  53. mblt_vision/models/DeiT3_Large_Patch16_384.yaml +22 -0
  54. mblt_vision/models/DeiT3_Medium_Patch16_224.yaml +22 -0
  55. mblt_vision/models/DeiT3_Small_Patch16_224.yaml +22 -0
  56. mblt_vision/models/DeiT3_Small_Patch16_384.yaml +22 -0
  57. mblt_vision/models/DeiT_Base_Patch16_224.yaml +22 -0
  58. mblt_vision/models/DeiT_Base_Patch16_384.yaml +22 -0
  59. mblt_vision/models/DeiT_Small_Patch16_224.yaml +22 -0
  60. mblt_vision/models/DeiT_Tiny_Patch16_224.yaml +22 -0
  61. mblt_vision/models/DenseNet121.yaml +23 -0
  62. mblt_vision/models/DenseNet161.yaml +23 -0
  63. mblt_vision/models/DenseNet169.yaml +23 -0
  64. mblt_vision/models/DenseNet201.yaml +23 -0
  65. mblt_vision/models/EfficientFormer_L1.yaml +22 -0
  66. mblt_vision/models/EfficientFormer_L3.yaml +22 -0
  67. mblt_vision/models/EfficientFormer_L7.yaml +22 -0
  68. mblt_vision/models/EfficientNet_B0.yaml +23 -0
  69. mblt_vision/models/EfficientNet_B1.yaml +32 -0
  70. mblt_vision/models/EfficientNet_B2.yaml +23 -0
  71. mblt_vision/models/EfficientNet_B3.yaml +23 -0
  72. mblt_vision/models/EfficientNet_B4.yaml +23 -0
  73. mblt_vision/models/EfficientNet_B5.yaml +23 -0
  74. mblt_vision/models/EfficientNet_B6.yaml +23 -0
  75. mblt_vision/models/EfficientNet_B7.yaml +23 -0
  76. mblt_vision/models/EfficientNet_V2_L.yaml +23 -0
  77. mblt_vision/models/EfficientNet_V2_M.yaml +23 -0
  78. mblt_vision/models/EfficientNet_V2_S.yaml +23 -0
  79. mblt_vision/models/FlexiVit_Base.yaml +22 -0
  80. mblt_vision/models/FlexiVit_Large.yaml +22 -0
  81. mblt_vision/models/FlexiVit_Small.yaml +22 -0
  82. mblt_vision/models/GELANc-seg.yaml +29 -0
  83. mblt_vision/models/GELANc.yaml +28 -0
  84. mblt_vision/models/GELANe.yaml +28 -0
  85. mblt_vision/models/GELANm.yaml +28 -0
  86. mblt_vision/models/GELANs.yaml +28 -0
  87. mblt_vision/models/GoogLeNet.yaml +23 -0
  88. mblt_vision/models/Inception_V3.yaml +23 -0
  89. mblt_vision/models/LeViT_Conv_128.yaml +22 -0
  90. mblt_vision/models/LeViT_Conv_128S.yaml +22 -0
  91. mblt_vision/models/LeViT_Conv_192.yaml +22 -0
  92. mblt_vision/models/LeViT_Conv_256.yaml +22 -0
  93. mblt_vision/models/LeViT_Conv_384.yaml +22 -0
  94. mblt_vision/models/MNASNet0_5.yaml +23 -0
  95. mblt_vision/models/MNASNet0_75.yaml +23 -0
  96. mblt_vision/models/MNASNet1_0.yaml +23 -0
  97. mblt_vision/models/MNASNet1_3.yaml +23 -0
  98. mblt_vision/models/MobileNet_V2.yaml +32 -0
  99. mblt_vision/models/MobileNet_V3_Large.yaml +32 -0
  100. mblt_vision/models/MobileNet_V3_Small.yaml +23 -0
  101. mblt_vision/models/RegNet_X_16GF.yaml +32 -0
  102. mblt_vision/models/RegNet_X_1_6GF.yaml +32 -0
  103. mblt_vision/models/RegNet_X_32GF.yaml +32 -0
  104. mblt_vision/models/RegNet_X_3_2GF.yaml +32 -0
  105. mblt_vision/models/RegNet_X_400MF.yaml +32 -0
  106. mblt_vision/models/RegNet_X_800MF.yaml +32 -0
  107. mblt_vision/models/RegNet_X_8GF.yaml +32 -0
  108. mblt_vision/models/RegNet_Y_16GF.yaml +76 -0
  109. mblt_vision/models/RegNet_Y_1_6GF.yaml +32 -0
  110. mblt_vision/models/RegNet_Y_32GF.yaml +76 -0
  111. mblt_vision/models/RegNet_Y_3_2GF.yaml +32 -0
  112. mblt_vision/models/RegNet_Y_400MF.yaml +32 -0
  113. mblt_vision/models/RegNet_Y_800MF.yaml +32 -0
  114. mblt_vision/models/RegNet_Y_8GF.yaml +32 -0
  115. mblt_vision/models/RepViT_M0_9.yaml +22 -0
  116. mblt_vision/models/RepViT_M1.yaml +22 -0
  117. mblt_vision/models/RepViT_M1_0.yaml +22 -0
  118. mblt_vision/models/RepViT_M1_1.yaml +22 -0
  119. mblt_vision/models/RepViT_M1_5.yaml +22 -0
  120. mblt_vision/models/RepViT_M2.yaml +22 -0
  121. mblt_vision/models/RepViT_M2_3.yaml +22 -0
  122. mblt_vision/models/RepViT_M3.yaml +22 -0
  123. mblt_vision/models/ResNeXt101_32X8D.yaml +32 -0
  124. mblt_vision/models/ResNeXt101_64X4D.yaml +23 -0
  125. mblt_vision/models/ResNeXt50_32X4D.yaml +32 -0
  126. mblt_vision/models/ResNet101.yaml +32 -0
  127. mblt_vision/models/ResNet152.yaml +32 -0
  128. mblt_vision/models/ResNet18.yaml +23 -0
  129. mblt_vision/models/ResNet34.yaml +23 -0
  130. mblt_vision/models/ResNet50.yaml +32 -0
  131. mblt_vision/models/ShuffleNet_V2_X0_5.yaml +23 -0
  132. mblt_vision/models/ShuffleNet_V2_X1_0.yaml +23 -0
  133. mblt_vision/models/ShuffleNet_V2_X1_5.yaml +23 -0
  134. mblt_vision/models/ShuffleNet_V2_X2_0.yaml +23 -0
  135. mblt_vision/models/SqueezeNet1_0.yaml +23 -0
  136. mblt_vision/models/SqueezeNet1_1.yaml +23 -0
  137. mblt_vision/models/Swin_B.yaml +23 -0
  138. mblt_vision/models/Swin_S.yaml +23 -0
  139. mblt_vision/models/Swin_T.yaml +23 -0
  140. mblt_vision/models/VGG11.yaml +23 -0
  141. mblt_vision/models/VGG11_BN.yaml +23 -0
  142. mblt_vision/models/VGG13.yaml +23 -0
  143. mblt_vision/models/VGG13_BN.yaml +23 -0
  144. mblt_vision/models/VGG16.yaml +23 -0
  145. mblt_vision/models/VGG16_BN.yaml +23 -0
  146. mblt_vision/models/VGG19.yaml +23 -0
  147. mblt_vision/models/VGG19_BN.yaml +23 -0
  148. mblt_vision/models/ViT_B_16.yaml +67 -0
  149. mblt_vision/models/ViT_B_32.yaml +23 -0
  150. mblt_vision/models/ViT_Base_Patch16_224.yaml +22 -0
  151. mblt_vision/models/ViT_Base_Patch16_384.yaml +22 -0
  152. mblt_vision/models/ViT_Base_Patch32_224.yaml +22 -0
  153. mblt_vision/models/ViT_Base_Patch32_384.yaml +22 -0
  154. mblt_vision/models/ViT_Base_Patch8_224.yaml +22 -0
  155. mblt_vision/models/ViT_L_16.yaml +67 -0
  156. mblt_vision/models/ViT_L_32.yaml +23 -0
  157. mblt_vision/models/ViT_Large_Patch16_224.yaml +22 -0
  158. mblt_vision/models/ViT_Large_Patch16_384.yaml +22 -0
  159. mblt_vision/models/ViT_Large_Patch32_384.yaml +22 -0
  160. mblt_vision/models/ViT_Small_Patch16_224.yaml +22 -0
  161. mblt_vision/models/ViT_Small_Patch16_384.yaml +22 -0
  162. mblt_vision/models/ViT_Small_Patch32_224.yaml +22 -0
  163. mblt_vision/models/ViT_Small_Patch32_384.yaml +22 -0
  164. mblt_vision/models/ViT_Tiny_Patch16_224.yaml +22 -0
  165. mblt_vision/models/ViT_Tiny_Patch16_384.yaml +22 -0
  166. mblt_vision/models/VisFormer_Small.yaml +22 -0
  167. mblt_vision/models/VisFormer_Tiny.yaml +22 -0
  168. mblt_vision/models/Wide_ResNet101_2.yaml +32 -0
  169. mblt_vision/models/Wide_ResNet50_2.yaml +32 -0
  170. mblt_vision/models/YOLO11l-cls.yaml +23 -0
  171. mblt_vision/models/YOLO11l-face.yaml +27 -0
  172. mblt_vision/models/YOLO11l-obb.yaml +28 -0
  173. mblt_vision/models/YOLO11l-pose.yaml +28 -0
  174. mblt_vision/models/YOLO11l-seg.yaml +28 -0
  175. mblt_vision/models/YOLO11l.yaml +27 -0
  176. mblt_vision/models/YOLO11m-cls.yaml +23 -0
  177. mblt_vision/models/YOLO11m-face.yaml +27 -0
  178. mblt_vision/models/YOLO11m-obb.yaml +28 -0
  179. mblt_vision/models/YOLO11m-pose.yaml +28 -0
  180. mblt_vision/models/YOLO11m-seg.yaml +28 -0
  181. mblt_vision/models/YOLO11m.yaml +27 -0
  182. mblt_vision/models/YOLO11n-cls.yaml +23 -0
  183. mblt_vision/models/YOLO11n-face.yaml +27 -0
  184. mblt_vision/models/YOLO11n-obb.yaml +28 -0
  185. mblt_vision/models/YOLO11n-pose.yaml +28 -0
  186. mblt_vision/models/YOLO11n-seg.yaml +28 -0
  187. mblt_vision/models/YOLO11n.yaml +27 -0
  188. mblt_vision/models/YOLO11s-cls.yaml +23 -0
  189. mblt_vision/models/YOLO11s-face.yaml +27 -0
  190. mblt_vision/models/YOLO11s-obb.yaml +28 -0
  191. mblt_vision/models/YOLO11s-pose.yaml +28 -0
  192. mblt_vision/models/YOLO11s-seg.yaml +28 -0
  193. mblt_vision/models/YOLO11s.yaml +27 -0
  194. mblt_vision/models/YOLO11x-cls.yaml +23 -0
  195. mblt_vision/models/YOLO11x-obb.yaml +28 -0
  196. mblt_vision/models/YOLO11x-pose.yaml +28 -0
  197. mblt_vision/models/YOLO11x-seg.yaml +28 -0
  198. mblt_vision/models/YOLO11x.yaml +27 -0
  199. mblt_vision/models/YOLO12l-face.yaml +27 -0
  200. mblt_vision/models/YOLO12l-seg.yaml +28 -0
  201. mblt_vision/models/YOLO12l.yaml +27 -0
  202. mblt_vision/models/YOLO12m-face.yaml +27 -0
  203. mblt_vision/models/YOLO12m-seg.yaml +28 -0
  204. mblt_vision/models/YOLO12m.yaml +27 -0
  205. mblt_vision/models/YOLO12n-face.yaml +27 -0
  206. mblt_vision/models/YOLO12n-seg.yaml +28 -0
  207. mblt_vision/models/YOLO12n.yaml +27 -0
  208. mblt_vision/models/YOLO12s-face.yaml +27 -0
  209. mblt_vision/models/YOLO12s-seg.yaml +28 -0
  210. mblt_vision/models/YOLO12s.yaml +27 -0
  211. mblt_vision/models/YOLO12x-seg.yaml +28 -0
  212. mblt_vision/models/YOLO12x.yaml +27 -0
  213. mblt_vision/models/YOLO26l-cls.yaml +23 -0
  214. mblt_vision/models/YOLO26l-depth.yaml +17 -0
  215. mblt_vision/models/YOLO26l-distill.yaml +27 -0
  216. mblt_vision/models/YOLO26l-obb.yaml +28 -0
  217. mblt_vision/models/YOLO26l-pose.yaml +28 -0
  218. mblt_vision/models/YOLO26l-seg.yaml +28 -0
  219. mblt_vision/models/YOLO26l-sem-ade20k.yaml +17 -0
  220. mblt_vision/models/YOLO26l-sem.yaml +17 -0
  221. mblt_vision/models/YOLO26l.yaml +27 -0
  222. mblt_vision/models/YOLO26m-cls.yaml +23 -0
  223. mblt_vision/models/YOLO26m-depth.yaml +17 -0
  224. mblt_vision/models/YOLO26m-distill.yaml +27 -0
  225. mblt_vision/models/YOLO26m-obb.yaml +28 -0
  226. mblt_vision/models/YOLO26m-pose.yaml +28 -0
  227. mblt_vision/models/YOLO26m-seg.yaml +28 -0
  228. mblt_vision/models/YOLO26m-sem-ade20k.yaml +17 -0
  229. mblt_vision/models/YOLO26m-sem.yaml +17 -0
  230. mblt_vision/models/YOLO26m.yaml +27 -0
  231. mblt_vision/models/YOLO26n-cls.yaml +23 -0
  232. mblt_vision/models/YOLO26n-depth.yaml +17 -0
  233. mblt_vision/models/YOLO26n-distill.yaml +27 -0
  234. mblt_vision/models/YOLO26n-obb.yaml +28 -0
  235. mblt_vision/models/YOLO26n-pose.yaml +28 -0
  236. mblt_vision/models/YOLO26n-seg.yaml +28 -0
  237. mblt_vision/models/YOLO26n-sem-ade20k.yaml +17 -0
  238. mblt_vision/models/YOLO26n-sem.yaml +17 -0
  239. mblt_vision/models/YOLO26n.yaml +27 -0
  240. mblt_vision/models/YOLO26s-cls.yaml +23 -0
  241. mblt_vision/models/YOLO26s-depth.yaml +17 -0
  242. mblt_vision/models/YOLO26s-distill.yaml +27 -0
  243. mblt_vision/models/YOLO26s-obb.yaml +28 -0
  244. mblt_vision/models/YOLO26s-pose.yaml +28 -0
  245. mblt_vision/models/YOLO26s-seg.yaml +28 -0
  246. mblt_vision/models/YOLO26s-sem-ade20k.yaml +17 -0
  247. mblt_vision/models/YOLO26s-sem.yaml +17 -0
  248. mblt_vision/models/YOLO26s.yaml +27 -0
  249. mblt_vision/models/YOLO26x-cls.yaml +23 -0
  250. mblt_vision/models/YOLO26x-depth.yaml +17 -0
  251. mblt_vision/models/YOLO26x-distill.yaml +27 -0
  252. mblt_vision/models/YOLO26x-obb.yaml +28 -0
  253. mblt_vision/models/YOLO26x-pose.yaml +28 -0
  254. mblt_vision/models/YOLO26x-seg.yaml +28 -0
  255. mblt_vision/models/YOLO26x-sem-ade20k.yaml +17 -0
  256. mblt_vision/models/YOLO26x-sem.yaml +17 -0
  257. mblt_vision/models/YOLO26x.yaml +27 -0
  258. mblt_vision/models/YOLOv10b.yaml +28 -0
  259. mblt_vision/models/YOLOv10l-face.yaml +28 -0
  260. mblt_vision/models/YOLOv10l.yaml +28 -0
  261. mblt_vision/models/YOLOv10m-face.yaml +28 -0
  262. mblt_vision/models/YOLOv10m.yaml +28 -0
  263. mblt_vision/models/YOLOv10n-face.yaml +28 -0
  264. mblt_vision/models/YOLOv10n.yaml +28 -0
  265. mblt_vision/models/YOLOv10s-face.yaml +28 -0
  266. mblt_vision/models/YOLOv10s.yaml +28 -0
  267. mblt_vision/models/YOLOv10x.yaml +28 -0
  268. mblt_vision/models/YOLOv3-spp.yaml +44 -0
  269. mblt_vision/models/YOLOv3-sppu.yaml +27 -0
  270. mblt_vision/models/YOLOv3-tiny.yaml +38 -0
  271. mblt_vision/models/YOLOv3-tinyu.yaml +27 -0
  272. mblt_vision/models/YOLOv3.yaml +44 -0
  273. mblt_vision/models/YOLOv3u.yaml +27 -0
  274. mblt_vision/models/YOLOv5l-cls.yaml +22 -0
  275. mblt_vision/models/YOLOv5l-seg.yaml +45 -0
  276. mblt_vision/models/YOLOv5l.yaml +44 -0
  277. mblt_vision/models/YOLOv5l6.yaml +50 -0
  278. mblt_vision/models/YOLOv5l6u.yaml +27 -0
  279. mblt_vision/models/YOLOv5lu.yaml +27 -0
  280. mblt_vision/models/YOLOv5m-cls.yaml +22 -0
  281. mblt_vision/models/YOLOv5m-seg.yaml +45 -0
  282. mblt_vision/models/YOLOv5m.yaml +45 -0
  283. mblt_vision/models/YOLOv5m6.yaml +50 -0
  284. mblt_vision/models/YOLOv5m6u.yaml +27 -0
  285. mblt_vision/models/YOLOv5mu.yaml +27 -0
  286. mblt_vision/models/YOLOv5n-cls.yaml +22 -0
  287. mblt_vision/models/YOLOv5n-seg.yaml +45 -0
  288. mblt_vision/models/YOLOv5n.yaml +44 -0
  289. mblt_vision/models/YOLOv5n6.yaml +50 -0
  290. mblt_vision/models/YOLOv5n6u.yaml +27 -0
  291. mblt_vision/models/YOLOv5nu.yaml +27 -0
  292. mblt_vision/models/YOLOv5s-cls.yaml +22 -0
  293. mblt_vision/models/YOLOv5s-seg.yaml +45 -0
  294. mblt_vision/models/YOLOv5s.yaml +44 -0
  295. mblt_vision/models/YOLOv5s6.yaml +50 -0
  296. mblt_vision/models/YOLOv5s6u.yaml +27 -0
  297. mblt_vision/models/YOLOv5su.yaml +27 -0
  298. mblt_vision/models/YOLOv5x-cls.yaml +22 -0
  299. mblt_vision/models/YOLOv5x-seg.yaml +45 -0
  300. mblt_vision/models/YOLOv5x.yaml +44 -0
  301. mblt_vision/models/YOLOv5x6.yaml +50 -0
  302. mblt_vision/models/YOLOv5x6u.yaml +27 -0
  303. mblt_vision/models/YOLOv5xu.yaml +27 -0
  304. mblt_vision/models/YOLOv6m-face.yaml +27 -0
  305. mblt_vision/models/YOLOv6n-face.yaml +27 -0
  306. mblt_vision/models/YOLOv7.yaml +44 -0
  307. mblt_vision/models/YOLOv7d6.yaml +50 -0
  308. mblt_vision/models/YOLOv7e6.yaml +50 -0
  309. mblt_vision/models/YOLOv7e6e.yaml +50 -0
  310. mblt_vision/models/YOLOv7w6.yaml +50 -0
  311. mblt_vision/models/YOLOv7x.yaml +44 -0
  312. mblt_vision/models/YOLOv8l-cls.yaml +23 -0
  313. mblt_vision/models/YOLOv8l-face.yaml +27 -0
  314. mblt_vision/models/YOLOv8l-obb.yaml +28 -0
  315. mblt_vision/models/YOLOv8l-pose.yaml +28 -0
  316. mblt_vision/models/YOLOv8l-seg.yaml +28 -0
  317. mblt_vision/models/YOLOv8l.yaml +27 -0
  318. mblt_vision/models/YOLOv8m-cls.yaml +23 -0
  319. mblt_vision/models/YOLOv8m-face.yaml +27 -0
  320. mblt_vision/models/YOLOv8m-obb.yaml +28 -0
  321. mblt_vision/models/YOLOv8m-pose.yaml +28 -0
  322. mblt_vision/models/YOLOv8m-seg.yaml +28 -0
  323. mblt_vision/models/YOLOv8m.yaml +27 -0
  324. mblt_vision/models/YOLOv8n-cls.yaml +23 -0
  325. mblt_vision/models/YOLOv8n-face.yaml +27 -0
  326. mblt_vision/models/YOLOv8n-obb.yaml +28 -0
  327. mblt_vision/models/YOLOv8n-pose.yaml +28 -0
  328. mblt_vision/models/YOLOv8n-seg.yaml +28 -0
  329. mblt_vision/models/YOLOv8n.yaml +27 -0
  330. mblt_vision/models/YOLOv8s-cls.yaml +23 -0
  331. mblt_vision/models/YOLOv8s-obb.yaml +28 -0
  332. mblt_vision/models/YOLOv8s-pose.yaml +28 -0
  333. mblt_vision/models/YOLOv8s-seg.yaml +28 -0
  334. mblt_vision/models/YOLOv8s.yaml +27 -0
  335. mblt_vision/models/YOLOv8x-cls.yaml +23 -0
  336. mblt_vision/models/YOLOv8x-obb.yaml +28 -0
  337. mblt_vision/models/YOLOv8x-pose-p6.yaml +28 -0
  338. mblt_vision/models/YOLOv8x-pose.yaml +28 -0
  339. mblt_vision/models/YOLOv8x-seg.yaml +28 -0
  340. mblt_vision/models/YOLOv8x.yaml +27 -0
  341. mblt_vision/models/YOLOv9c-seg.yaml +28 -0
  342. mblt_vision/models/YOLOv9c.yaml +27 -0
  343. mblt_vision/models/YOLOv9e-seg.yaml +28 -0
  344. mblt_vision/models/YOLOv9e.yaml +27 -0
  345. mblt_vision/models/YOLOv9m.yaml +27 -0
  346. mblt_vision/models/YOLOv9s.yaml +27 -0
  347. mblt_vision/models/YOLOv9t.yaml +27 -0
  348. mblt_vision/obb/__init__.py +39 -0
  349. mblt_vision/object_detection/__init__.py +153 -0
  350. mblt_vision/pose_estimation/__init__.py +41 -0
  351. mblt_vision/py.typed +1 -0
  352. mblt_vision/semantic_segmentation/__init__.py +29 -0
  353. mblt_vision/utils/__init__.py +0 -0
  354. mblt_vision/utils/datasets/__init__.py +85 -0
  355. mblt_vision/utils/datasets/ade20k.py +41 -0
  356. mblt_vision/utils/datasets/cityscapes.py +66 -0
  357. mblt_vision/utils/datasets/coco.py +243 -0
  358. mblt_vision/utils/datasets/dataloader.py +1016 -0
  359. mblt_vision/utils/datasets/dotav1.py +59 -0
  360. mblt_vision/utils/datasets/imagenet.py +29 -0
  361. mblt_vision/utils/datasets/organizer.py +2145 -0
  362. mblt_vision/utils/datasets/readiness.py +1063 -0
  363. mblt_vision/utils/evaluation/__init__.py +51 -0
  364. mblt_vision/utils/evaluation/_result.py +22 -0
  365. mblt_vision/utils/evaluation/eval_ade20k.py +302 -0
  366. mblt_vision/utils/evaluation/eval_cityscapes.py +32 -0
  367. mblt_vision/utils/evaluation/eval_coco.py +465 -0
  368. mblt_vision/utils/evaluation/eval_dota.py +878 -0
  369. mblt_vision/utils/evaluation/eval_imagenet.py +151 -0
  370. mblt_vision/utils/evaluation/eval_nyu_depth.py +189 -0
  371. mblt_vision/utils/evaluation/eval_widerface.py +440 -0
  372. mblt_vision/utils/letterbox.py +118 -0
  373. mblt_vision/utils/postprocess/__init__.py +9 -0
  374. mblt_vision/utils/postprocess/_letterbox.py +102 -0
  375. mblt_vision/utils/postprocess/base.py +743 -0
  376. mblt_vision/utils/postprocess/build_post.py +120 -0
  377. mblt_vision/utils/postprocess/cls_post.py +117 -0
  378. mblt_vision/utils/postprocess/common.py +1571 -0
  379. mblt_vision/utils/postprocess/depth_post.py +106 -0
  380. mblt_vision/utils/postprocess/semantic_seg_post.py +192 -0
  381. mblt_vision/utils/postprocess/yolo_anchor_post.py +469 -0
  382. mblt_vision/utils/postprocess/yolo_anchorless_post.py +952 -0
  383. mblt_vision/utils/postprocess/yolo_dflfree_post.py +983 -0
  384. mblt_vision/utils/postprocess/yolo_nmsfree_post.py +176 -0
  385. mblt_vision/utils/preprocess/__init__.py +27 -0
  386. mblt_vision/utils/preprocess/_validation.py +66 -0
  387. mblt_vision/utils/preprocess/base.py +157 -0
  388. mblt_vision/utils/preprocess/build_pre.py +48 -0
  389. mblt_vision/utils/preprocess/center_crop.py +75 -0
  390. mblt_vision/utils/preprocess/letterbox.py +123 -0
  391. mblt_vision/utils/preprocess/normalize.py +94 -0
  392. mblt_vision/utils/preprocess/order.py +74 -0
  393. mblt_vision/utils/preprocess/reader.py +94 -0
  394. mblt_vision/utils/preprocess/resize.py +202 -0
  395. mblt_vision/utils/preprocess/yolo_pre.py +7 -0
  396. mblt_vision/utils/results.py +725 -0
  397. mblt_vision/utils/types.py +15 -0
  398. mblt_vision/wrapper.py +1121 -0
  399. mblt_vision_python-0.0.0.dist-info/METADATA +152 -0
  400. mblt_vision_python-0.0.0.dist-info/RECORD +404 -0
  401. mblt_vision_python-0.0.0.dist-info/WHEEL +5 -0
  402. mblt_vision_python-0.0.0.dist-info/entry_points.txt +2 -0
  403. mblt_vision_python-0.0.0.dist-info/licenses/LICENSE +28 -0
  404. mblt_vision_python-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,86 @@
1
+ """MBLT vision task exports and discovery helpers.
2
+
3
+ The vision package keeps task subpackages as the preferred import surface while
4
+ also supporting legacy top-level model imports such as
5
+ ``from mblt_model_zoo.vision import ResNet50``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from . import depth_estimation as depth_estimation
11
+ from . import face_detection as face_detection
12
+ from . import image_classification as image_classification
13
+ from . import instance_segmentation as instance_segmentation
14
+ from . import obb as obb
15
+ from . import object_detection as object_detection
16
+ from . import pose_estimation as pose_estimation
17
+ from . import semantic_segmentation as semantic_segmentation
18
+ from ._api import list_models as list_models
19
+ from ._api import list_tasks as list_tasks
20
+ from .wrapper import MBLT_Engine as MBLT_Engine
21
+
22
+ __version__ = "0.0.0"
23
+
24
+ _TASK_MODULES = (
25
+ face_detection,
26
+ depth_estimation,
27
+ image_classification,
28
+ instance_segmentation,
29
+ object_detection,
30
+ obb,
31
+ pose_estimation,
32
+ semantic_segmentation,
33
+ )
34
+
35
+ _LEGACY_MODEL_EXPORTS: dict[str, object] = {}
36
+ for _task_module in _TASK_MODULES:
37
+ for _export_name in getattr(_task_module, "__all__", ()):
38
+ if _export_name in _LEGACY_MODEL_EXPORTS:
39
+ raise RuntimeError(
40
+ f"Duplicate vision export detected for '{_export_name}'."
41
+ )
42
+ _LEGACY_MODEL_EXPORTS[_export_name] = _task_module
43
+
44
+ _PUBLIC_EXPORTS = [
45
+ "MBLT_Engine",
46
+ "list_models",
47
+ "list_tasks",
48
+ "face_detection",
49
+ "depth_estimation",
50
+ "image_classification",
51
+ "instance_segmentation",
52
+ "object_detection",
53
+ "obb",
54
+ "pose_estimation",
55
+ "semantic_segmentation",
56
+ ] + sorted(_LEGACY_MODEL_EXPORTS)
57
+ # Keep legacy compatibility exports synchronized with their task packages.
58
+ __all__: list[str] = _PUBLIC_EXPORTS # pyright: ignore[reportUnsupportedDunderAll]
59
+
60
+
61
+ def __getattr__(name: str) -> object:
62
+ """Lazily resolve legacy top-level model exports.
63
+
64
+ Args:
65
+ name: Attribute requested from the vision package.
66
+
67
+ Returns:
68
+ The exported model wrapper class for the requested legacy name.
69
+
70
+ Raises:
71
+ AttributeError: If the requested name is not exported by the package.
72
+ """
73
+
74
+ task_module = _LEGACY_MODEL_EXPORTS.get(name)
75
+ if task_module is None:
76
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
77
+
78
+ value = getattr(task_module, name)
79
+ globals()[name] = value
80
+ return value
81
+
82
+
83
+ def __dir__() -> list[str]:
84
+ """Return package attributes including lazy legacy exports."""
85
+
86
+ return sorted(set(globals()) | set(__all__))
mblt_vision/_api.py ADDED
@@ -0,0 +1,53 @@
1
+ """Public helpers for discovering available vision tasks and models."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import inspect
7
+ from typing import Iterable
8
+
9
+ from ._tasks import VISION_TASKS, normalize_vision_task
10
+ from .wrapper import MBLT_Engine
11
+
12
+
13
+ def list_tasks() -> list[str]:
14
+ """Lists the available vision tasks."""
15
+
16
+ return list(VISION_TASKS)
17
+
18
+
19
+ def list_models(tasks: str | Iterable[str] | None = None) -> dict[str, list[str]]:
20
+ """Lists available models for the selected vision tasks.
21
+
22
+ Args:
23
+ tasks: Task name or names to inspect. When omitted, all tasks are used.
24
+
25
+ Returns:
26
+ A mapping of task name to exported model class names.
27
+
28
+ Raises:
29
+ ValueError: If an unknown task name is provided.
30
+ """
31
+
32
+ if tasks is None:
33
+ task_list = list(VISION_TASKS)
34
+ elif isinstance(tasks, str):
35
+ task_list = [tasks]
36
+ else:
37
+ task_list = list(tasks)
38
+
39
+ available_models: dict[str, list[str]] = {}
40
+ for task in task_list:
41
+ module_name = normalize_vision_task(task)
42
+ module = importlib.import_module(
43
+ f".{module_name}", package=__name__.replace("._api", "")
44
+ )
45
+ available_models[task] = sorted(
46
+ name
47
+ for name, obj in inspect.getmembers(module, inspect.isclass)
48
+ if issubclass(obj, MBLT_Engine)
49
+ and obj is not MBLT_Engine
50
+ and not getattr(obj, "_yaml_missing", False)
51
+ )
52
+
53
+ return available_models
mblt_vision/_compat.py ADDED
@@ -0,0 +1,227 @@
1
+ """Compatibility helpers for YAML-backed vision model exports.
2
+
3
+ This module rebuilds the legacy task package exports that were removed during
4
+ the YAML migration. The generated classes keep the familiar import paths and
5
+ constructor shape while delegating model loading to ``MBLT_Engine``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from pathlib import Path
11
+ from typing import Any, Callable, Iterable, Sequence, TypeAlias, cast
12
+
13
+ from ._model_paths import uses_shifted_compat_model_path_layout
14
+ from .wrapper import CoreMode, MBLT_Engine
15
+
16
+ _MODEL_DIR = Path(__file__).parent / "models"
17
+
18
+
19
+ class CompatMBLTEngine(MBLT_Engine):
20
+ """Typed base for dynamically generated legacy compatibility wrappers."""
21
+
22
+ def __init__(
23
+ self,
24
+ local_path: str | None = None,
25
+ model_type: str = "DEFAULT",
26
+ infer_mode: CoreMode = "global8",
27
+ product: str = "aries",
28
+ dev_no: int = 0,
29
+ target_cores: Sequence[str] | None = None,
30
+ target_clusters: Sequence[int] | None = None,
31
+ mxq_path: str | None = None,
32
+ onnx_path: str | None = None,
33
+ framework: str | None = None,
34
+ model_path: str | None = None,
35
+ ) -> None:
36
+ """Type-only constructor matching the generated legacy wrappers."""
37
+ del (
38
+ local_path,
39
+ model_type,
40
+ infer_mode,
41
+ product,
42
+ dev_no,
43
+ target_cores,
44
+ target_clusters,
45
+ model_path,
46
+ mxq_path,
47
+ onnx_path,
48
+ framework,
49
+ )
50
+ raise NotImplementedError
51
+
52
+
53
+ CompatMBLTEngineClass: TypeAlias = type[CompatMBLTEngine]
54
+
55
+
56
+ def _normalize_name(value: str) -> str:
57
+ """Returns an alphanumeric-only, case-insensitive identifier."""
58
+
59
+ return "".join(char for char in value.lower() if char.isalnum())
60
+
61
+
62
+ def _resolve_yaml_name(class_name: str) -> str:
63
+ """Resolves the YAML config stem associated with a legacy class name.
64
+
65
+ Args:
66
+ class_name: Exported legacy class name.
67
+
68
+ Returns:
69
+ The YAML filename stem without the ``.yaml`` suffix.
70
+
71
+ Raises:
72
+ ValueError: If no unique matching YAML file can be determined.
73
+ """
74
+
75
+ yaml_stems = [path.stem for path in _MODEL_DIR.glob("*.yaml")]
76
+
77
+ exact_matches = [stem for stem in yaml_stems if stem.lower() == class_name.lower()]
78
+ if len(exact_matches) == 1:
79
+ return exact_matches[0]
80
+
81
+ normalized_name = _normalize_name(class_name)
82
+ normalized_matches = [
83
+ stem for stem in yaml_stems if _normalize_name(stem) == normalized_name
84
+ ]
85
+ if len(normalized_matches) == 1:
86
+ return normalized_matches[0]
87
+
88
+ if not normalized_matches:
89
+ raise ValueError(
90
+ f"Could not find a YAML config for legacy class '{class_name}'."
91
+ )
92
+
93
+ raise ValueError(
94
+ f"Found multiple YAML configs for legacy class '{class_name}': {sorted(normalized_matches)}."
95
+ )
96
+
97
+
98
+ def _build_init(yaml_name: str) -> Callable[..., None]:
99
+ """Builds a legacy-compatible ``__init__`` implementation."""
100
+
101
+ def __init__(
102
+ self,
103
+ local_path: str | None = None,
104
+ model_type: str = "DEFAULT",
105
+ infer_mode: CoreMode = "global8",
106
+ product: str = "aries",
107
+ dev_no: int = 0,
108
+ target_cores: Sequence[str] | None = None,
109
+ target_clusters: Sequence[int] | None = None,
110
+ mxq_path: str | None = None,
111
+ onnx_path: str | None = None,
112
+ framework: str | None = None,
113
+ model_path: str | None = None,
114
+ ) -> None:
115
+ """Initializes a YAML-backed compatibility wrapper.
116
+
117
+ Args:
118
+ local_path: Deprecated legacy MXQ path alias. Prefer ``model_path``
119
+ for generic MXQ or ONNX loading, or ``mxq_path`` for an
120
+ explicit MXQ-only override.
121
+ model_type: YAML config variant to load.
122
+ infer_mode: Execution mode forwarded to ``MBLT_Engine``.
123
+ product: Legacy product/board value forwarded as ``target_device``.
124
+ dev_no: Accelerator device number.
125
+ target_cores: Optional core selection for single-core mode.
126
+ target_clusters: Optional cluster selection for multi/global modes.
127
+ mxq_path: Optional explicit MXQ path alias.
128
+ onnx_path: Optional explicit ONNX path.
129
+ framework: Execution framework, either ``"mxq"`` or ``"onnx"``. When
130
+ omitted, ``model_path`` suffix is used first, then MXQ is the fallback.
131
+ model_path: Optional explicit local model path for MXQ or ONNX.
132
+ """
133
+
134
+ if uses_shifted_compat_model_path_layout(
135
+ model_path, mxq_path, onnx_path, framework
136
+ ):
137
+ model_path, mxq_path, onnx_path, framework = (
138
+ mxq_path,
139
+ onnx_path,
140
+ framework,
141
+ cast(str | None, model_path),
142
+ )
143
+ MBLT_Engine.__init__(
144
+ self,
145
+ model_cls=yaml_name,
146
+ model_type=model_type,
147
+ model_path=model_path or "",
148
+ mxq_path=mxq_path or local_path or "",
149
+ onnx_path=onnx_path or "",
150
+ dev_no=dev_no,
151
+ core_mode=infer_mode,
152
+ target_cores=list(target_cores) if target_cores is not None else None,
153
+ target_clusters=list(target_clusters)
154
+ if target_clusters is not None
155
+ else None,
156
+ target_device=product,
157
+ framework=framework,
158
+ )
159
+
160
+ return __init__
161
+
162
+
163
+ def _build_missing_init(class_name: str, reason: str) -> Callable[..., None]:
164
+ """Builds an ``__init__`` that fails with a clear compatibility message."""
165
+
166
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
167
+ """Raises an informative error for removed YAML-backed models."""
168
+
169
+ del args, kwargs
170
+ raise ValueError(
171
+ f"Legacy vision model '{class_name}' is not available in the YAML model registry: {reason}"
172
+ )
173
+
174
+ return __init__
175
+
176
+
177
+ def create_model_class(class_name: str, module_name: str) -> CompatMBLTEngineClass:
178
+ """Creates a legacy model class that delegates to ``MBLT_Engine``.
179
+
180
+ Args:
181
+ class_name: Class name to expose from the task module.
182
+ module_name: Module path that should own the generated class.
183
+
184
+ Returns:
185
+ A dynamically generated ``MBLT_Engine`` subclass.
186
+ """
187
+
188
+ class_doc = f"Compatibility wrapper for the legacy ``{class_name}`` vision model."
189
+ try:
190
+ yaml_name = _resolve_yaml_name(class_name)
191
+ except ValueError as exc:
192
+ return type(
193
+ class_name,
194
+ (CompatMBLTEngine,),
195
+ {
196
+ "__doc__": class_doc,
197
+ "__init__": _build_missing_init(class_name, str(exc)),
198
+ "__module__": module_name,
199
+ "_yaml_missing": True,
200
+ },
201
+ )
202
+
203
+ return type(
204
+ class_name,
205
+ (CompatMBLTEngine,),
206
+ {
207
+ "__doc__": class_doc,
208
+ "__init__": _build_init(yaml_name),
209
+ "__module__": module_name,
210
+ "_yaml_name": yaml_name,
211
+ },
212
+ )
213
+
214
+
215
+ def export_model_classes(
216
+ namespace: dict[str, Any], class_names: Iterable[str], module_name: str
217
+ ) -> None:
218
+ """Populates a module namespace with generated model classes.
219
+
220
+ Args:
221
+ namespace: Target module globals.
222
+ class_names: Legacy class names to generate.
223
+ module_name: Import path for generated classes.
224
+ """
225
+
226
+ for class_name in class_names:
227
+ namespace[class_name] = create_model_class(class_name, module_name)
@@ -0,0 +1,137 @@
1
+ """Framework and local-artifact path resolution for vision engines."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ SUPPORTED_FRAMEWORKS = {"mxq", "onnx"}
8
+
9
+
10
+ def framework_from_model_path(model_path: str) -> str | None:
11
+ """Infer the runtime framework from a local model path suffix."""
12
+
13
+ suffix = Path(model_path).suffix.lower()
14
+ if suffix == ".mxq":
15
+ return "mxq"
16
+ if suffix == ".onnx":
17
+ return "onnx"
18
+ return None
19
+
20
+
21
+ def uses_shifted_engine_model_path_layout(
22
+ model_path: object,
23
+ mxq_path: object,
24
+ dev_no: object,
25
+ core_mode: object,
26
+ target_cores: object,
27
+ postprocess_kwargs: object,
28
+ framework: object,
29
+ onnx_providers: object,
30
+ ) -> bool:
31
+ """Return whether engine arguments use the model-path-first layout.
32
+
33
+ Public constructor layouts have used the third positional argument for
34
+ either ``mxq_path`` or ``model_path``. An ONNX suffix identifies the
35
+ model-path-first layout because it changes runtime routing. For MXQ,
36
+ remapping is needed only when later values have the types produced by a
37
+ one-slot positional shift; a path by itself behaves identically as the
38
+ ``mxq_path`` alias.
39
+ """
40
+
41
+ if not isinstance(mxq_path, str):
42
+ return False
43
+ inferred_framework = framework_from_model_path(mxq_path)
44
+ if inferred_framework not in SUPPORTED_FRAMEWORKS:
45
+ return False
46
+ if (
47
+ isinstance(model_path, str)
48
+ and model_path
49
+ and model_path.lower() not in SUPPORTED_FRAMEWORKS
50
+ ):
51
+ return False
52
+ return (
53
+ isinstance(dev_no, str)
54
+ or isinstance(core_mode, int)
55
+ or isinstance(target_cores, str)
56
+ or (postprocess_kwargs is not None and not isinstance(postprocess_kwargs, dict))
57
+ or isinstance(framework, dict)
58
+ or isinstance(onnx_providers, str)
59
+ or (model_path is not None and not isinstance(model_path, str))
60
+ or (isinstance(model_path, str) and model_path.lower() in SUPPORTED_FRAMEWORKS)
61
+ )
62
+
63
+
64
+ def uses_shifted_compat_model_path_layout(
65
+ model_path: object,
66
+ mxq_path: object,
67
+ onnx_path: object,
68
+ framework: object,
69
+ ) -> bool:
70
+ """Return whether generated-wrapper arguments use a shifted model-path tail."""
71
+
72
+ if not isinstance(mxq_path, str):
73
+ return False
74
+ inferred_framework = framework_from_model_path(mxq_path)
75
+ if inferred_framework not in SUPPORTED_FRAMEWORKS:
76
+ return False
77
+ if (
78
+ isinstance(model_path, str)
79
+ and model_path
80
+ and model_path.lower() not in SUPPORTED_FRAMEWORKS
81
+ ):
82
+ return False
83
+ if inferred_framework == "onnx":
84
+ return True
85
+ return (
86
+ (isinstance(model_path, str) and model_path.lower() in SUPPORTED_FRAMEWORKS)
87
+ or (
88
+ isinstance(onnx_path, str) and framework_from_model_path(onnx_path) == "mxq"
89
+ )
90
+ or (
91
+ isinstance(framework, str)
92
+ and framework_from_model_path(framework) is not None
93
+ )
94
+ )
95
+
96
+
97
+ def resolve_framework(framework: str | None, model_path: str = "") -> str:
98
+ """Resolve the execution framework from explicit input and model path."""
99
+
100
+ normalized_framework = framework.lower() if framework is not None else None
101
+ if (
102
+ normalized_framework is not None
103
+ and normalized_framework not in SUPPORTED_FRAMEWORKS
104
+ ):
105
+ raise ValueError(
106
+ f"Unsupported framework: {framework}. Must be one of {sorted(SUPPORTED_FRAMEWORKS)}."
107
+ )
108
+ inferred_framework = framework_from_model_path(model_path) if model_path else None
109
+ if (
110
+ normalized_framework
111
+ and inferred_framework
112
+ and normalized_framework != inferred_framework
113
+ ):
114
+ raise ValueError(
115
+ f"Framework `{normalized_framework}` conflicts with model path `{model_path}`. "
116
+ f"Use framework `{inferred_framework}` or remove the explicit framework."
117
+ )
118
+ return inferred_framework or normalized_framework or "mxq"
119
+
120
+
121
+ def split_model_paths(
122
+ *, framework: str, model_path: str = "", mxq_path: str = "", onnx_path: str = ""
123
+ ) -> tuple[str, str]:
124
+ """Resolve generic and framework-specific local model path arguments."""
125
+
126
+ resolved_mxq_path = mxq_path
127
+ resolved_onnx_path = onnx_path
128
+ if not model_path:
129
+ return resolved_mxq_path, resolved_onnx_path
130
+ inferred_framework = framework_from_model_path(model_path)
131
+ if inferred_framework == "mxq":
132
+ resolved_mxq_path = resolved_mxq_path or model_path
133
+ elif inferred_framework == "onnx" or framework == "onnx":
134
+ resolved_onnx_path = resolved_onnx_path or model_path
135
+ else:
136
+ resolved_mxq_path = resolved_mxq_path or model_path
137
+ return resolved_mxq_path, resolved_onnx_path
mblt_vision/_tasks.py ADDED
@@ -0,0 +1,30 @@
1
+ """Canonical task names used by the standalone Vision processing API."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterable
6
+
7
+ VISION_TASKS: tuple[str, ...] = (
8
+ "image_classification",
9
+ "depth_estimation",
10
+ "object_detection",
11
+ "instance_segmentation",
12
+ "semantic_segmentation",
13
+ "obb",
14
+ "pose_estimation",
15
+ "face_detection",
16
+ )
17
+
18
+
19
+ def normalize_vision_task(task: str, *, supported: Iterable[str] | None = None) -> str:
20
+ """Normalize a Vision task name and validate it against supported tasks."""
21
+
22
+ if not isinstance(task, str):
23
+ raise TypeError(f"Vision task must be a string, got {type(task).__name__}.")
24
+ normalized = task.lower()
25
+ supported_tasks = tuple(VISION_TASKS if supported is None else supported)
26
+ if normalized not in supported_tasks:
27
+ raise ValueError(
28
+ f"Unsupported Vision task {task!r}; expected one of {sorted(supported_tasks)}."
29
+ )
30
+ return normalized
@@ -0,0 +1 @@
1
+ """Reusable benchmark reporting and command support for Mobilint Vision."""
@@ -0,0 +1,106 @@
1
+ """Shared argparse validators for benchmark scripts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+
7
+
8
+ def parse_positive_int(raw: str) -> int:
9
+ """Parses a positive integer for argparse.
10
+
11
+ Args:
12
+ raw: Raw command-line value.
13
+
14
+ Returns:
15
+ Parsed positive integer.
16
+
17
+ Raises:
18
+ argparse.ArgumentTypeError: If the value is not a positive integer.
19
+ """
20
+ try:
21
+ value = int(raw)
22
+ except (TypeError, ValueError) as e:
23
+ raise argparse.ArgumentTypeError("expected a positive integer") from e
24
+ if value <= 0:
25
+ raise argparse.ArgumentTypeError("expected a positive integer")
26
+ return value
27
+
28
+
29
+ def parse_positive_int_optional(raw: str | None) -> int | None:
30
+ """Parses an optional positive integer for argparse.
31
+
32
+ Args:
33
+ raw: Raw command-line value or ``None``.
34
+
35
+ Returns:
36
+ Parsed positive integer, or ``None`` for empty input.
37
+
38
+ Raises:
39
+ argparse.ArgumentTypeError: If the value is not empty and not a positive integer.
40
+ """
41
+ if raw is None or raw == "":
42
+ return None
43
+ return parse_positive_int(raw)
44
+
45
+
46
+ def parse_range_arg(raw: str) -> tuple[int, int, int]:
47
+ """Parses ``start:end:step`` or ``start,end,step`` positive integer ranges.
48
+
49
+ Args:
50
+ raw: Raw command-line value.
51
+
52
+ Returns:
53
+ Parsed ``(start, end, step)`` tuple.
54
+
55
+ Raises:
56
+ argparse.ArgumentTypeError: If the value is malformed.
57
+ """
58
+ sep = ":" if ":" in raw else ("," if "," in raw else None)
59
+ if sep is None:
60
+ raise argparse.ArgumentTypeError(
61
+ "expected format 'start:end:step' or 'start,end,step'"
62
+ )
63
+ parts = [part.strip() for part in raw.split(sep)]
64
+ if len(parts) != 3:
65
+ raise argparse.ArgumentTypeError(
66
+ "expected exactly 3 integers: 'start:end:step' or 'start,end,step'"
67
+ )
68
+ try:
69
+ start, end, step = (int(part) for part in parts)
70
+ except ValueError as e:
71
+ raise argparse.ArgumentTypeError("range values must be integers") from e
72
+ if start <= 0 or end <= 0 or step <= 0:
73
+ raise argparse.ArgumentTypeError("range values must be positive integers")
74
+ if start > end:
75
+ raise argparse.ArgumentTypeError("range start must be <= end")
76
+ return start, end, step
77
+
78
+
79
+ def parse_int_csv(
80
+ raw: str, *, unique_sorted: bool = True, allow_empty: bool = False
81
+ ) -> list[int]:
82
+ """Parses comma-separated positive integers.
83
+
84
+ Args:
85
+ raw: Raw command-line value.
86
+ unique_sorted: Whether to sort and de-duplicate parsed values.
87
+ allow_empty: Whether an empty input should return an empty list.
88
+
89
+ Returns:
90
+ Parsed positive integers.
91
+
92
+ Raises:
93
+ argparse.ArgumentTypeError: If the value is malformed.
94
+ """
95
+ parts = [item.strip() for item in str(raw).split(",") if item.strip()]
96
+ if not parts:
97
+ if allow_empty:
98
+ return []
99
+ raise argparse.ArgumentTypeError("expected at least one integer")
100
+ try:
101
+ values = [int(item) for item in parts]
102
+ except ValueError as e:
103
+ raise argparse.ArgumentTypeError("all values must be integers") from e
104
+ if any(value <= 0 for value in values):
105
+ raise argparse.ArgumentTypeError("all values must be positive integers")
106
+ return sorted(set(values)) if unique_sorted else values