tempest-react-sdk 0.57.0 → 0.59.0

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 (396) hide show
  1. package/README.md +14 -2
  2. package/bin/lib/css/findings.mjs +1 -0
  3. package/bin/lib/css/semantic.mjs +70 -6
  4. package/bin/lib/css/semantic.test.mjs +52 -1
  5. package/bin/lib/icons/generate.test.mjs +4 -4
  6. package/dist/br/geocode.cjs +1 -1
  7. package/dist/br/geocode.cjs.map +1 -1
  8. package/dist/br/geocode.js +1 -1
  9. package/dist/br/geocode.js.map +1 -1
  10. package/dist/capture/use-barcode-scanner.cjs +1 -1
  11. package/dist/capture/use-barcode-scanner.cjs.map +1 -1
  12. package/dist/capture/use-barcode-scanner.js +1 -1
  13. package/dist/capture/use-barcode-scanner.js.map +1 -1
  14. package/dist/components/AIChat/AIChat.cjs +1 -1
  15. package/dist/components/AIChat/AIChat.cjs.map +1 -1
  16. package/dist/components/AIChat/AIChat.js +1 -1
  17. package/dist/components/AIChat/AIChat.js.map +1 -1
  18. package/dist/components/AIChat/AIChatTurn.cjs +1 -1
  19. package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
  20. package/dist/components/AIChat/AIChatTurn.js +1 -1
  21. package/dist/components/AIChat/AIChatTurn.js.map +1 -1
  22. package/dist/components/Alert/Alert.module.cjs.map +1 -1
  23. package/dist/components/Alert/Alert.module.js.map +1 -1
  24. package/dist/components/AppBar/use-sticky-body-warning.cjs +1 -1
  25. package/dist/components/AppBar/use-sticky-body-warning.cjs.map +1 -1
  26. package/dist/components/AppBar/use-sticky-body-warning.js +1 -1
  27. package/dist/components/AppBar/use-sticky-body-warning.js.map +1 -1
  28. package/dist/components/AudioPlayer/AudioPlayer.cjs +1 -1
  29. package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
  30. package/dist/components/AudioPlayer/AudioPlayer.js +2 -2
  31. package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -1
  32. package/dist/components/AudioRecorder/AudioRecorder.cjs +1 -1
  33. package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -1
  34. package/dist/components/AudioRecorder/AudioRecorder.js +1 -1
  35. package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -1
  36. package/dist/components/Badge/Badge.module.cjs.map +1 -1
  37. package/dist/components/Badge/Badge.module.js.map +1 -1
  38. package/dist/components/BarList/BarList.module.cjs.map +1 -1
  39. package/dist/components/BarList/BarList.module.js.map +1 -1
  40. package/dist/components/BottomSheet/BottomSheet.module.cjs.map +1 -1
  41. package/dist/components/BottomSheet/BottomSheet.module.js.map +1 -1
  42. package/dist/components/Chat/Chat.cjs +1 -1
  43. package/dist/components/Chat/Chat.cjs.map +1 -1
  44. package/dist/components/Chat/Chat.js +1 -1
  45. package/dist/components/Chat/Chat.js.map +1 -1
  46. package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
  47. package/dist/components/DataTable/DataTable.module.js.map +1 -1
  48. package/dist/components/Dropzone/Dropzone.module.cjs.map +1 -1
  49. package/dist/components/Dropzone/Dropzone.module.js.map +1 -1
  50. package/dist/components/ErrorText/ErrorText.module.cjs.map +1 -1
  51. package/dist/components/ErrorText/ErrorText.module.js.map +1 -1
  52. package/dist/components/FilterBar/FilterBar.cjs +1 -1
  53. package/dist/components/FilterBar/FilterBar.cjs.map +1 -1
  54. package/dist/components/FilterBar/FilterBar.js +1 -1
  55. package/dist/components/FilterBar/FilterBar.js.map +1 -1
  56. package/dist/components/FilterBar/filter-apply.cjs +1 -1
  57. package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
  58. package/dist/components/FilterBar/filter-apply.js +1 -1
  59. package/dist/components/FilterBar/filter-apply.js.map +1 -1
  60. package/dist/components/ImageCropper/ImageCropper.cjs +1 -1
  61. package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -1
  62. package/dist/components/ImageCropper/ImageCropper.js +1 -1
  63. package/dist/components/ImageCropper/ImageCropper.js.map +1 -1
  64. package/dist/components/Markdown/Markdown.module.cjs.map +1 -1
  65. package/dist/components/Markdown/Markdown.module.js.map +1 -1
  66. package/dist/components/PasswordInput/PasswordInput.module.cjs.map +1 -1
  67. package/dist/components/PasswordInput/PasswordInput.module.js.map +1 -1
  68. package/dist/components/SegmentedControl/SegmentedControl.module.cjs.map +1 -1
  69. package/dist/components/SegmentedControl/SegmentedControl.module.js.map +1 -1
  70. package/dist/components/Sidebar/Sidebar.module.cjs.map +1 -1
  71. package/dist/components/Sidebar/Sidebar.module.js.map +1 -1
  72. package/dist/components/StepperInput/StepperInput.module.cjs.map +1 -1
  73. package/dist/components/StepperInput/StepperInput.module.js.map +1 -1
  74. package/dist/components/Tag/Tag.module.cjs.map +1 -1
  75. package/dist/components/Tag/Tag.module.js.map +1 -1
  76. package/dist/components/Timeline/Timeline.module.cjs.map +1 -1
  77. package/dist/components/Timeline/Timeline.module.js.map +1 -1
  78. package/dist/components/Toggle/Toggle.module.cjs.map +1 -1
  79. package/dist/components/Toggle/Toggle.module.js.map +1 -1
  80. package/dist/components/ToggleGroup/ToggleGroup.module.cjs.map +1 -1
  81. package/dist/components/ToggleGroup/ToggleGroup.module.js.map +1 -1
  82. package/dist/components/VideoPlayer/VideoPlayer.cjs +1 -1
  83. package/dist/components/VideoPlayer/VideoPlayer.cjs.map +1 -1
  84. package/dist/components/VideoPlayer/VideoPlayer.js +2 -2
  85. package/dist/components/VideoPlayer/VideoPlayer.js.map +1 -1
  86. package/dist/components/VirtualTable/VirtualTable.cjs +1 -1
  87. package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
  88. package/dist/components/VirtualTable/VirtualTable.js +1 -1
  89. package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
  90. package/dist/feature-flags/growthbook-adapter.cjs +1 -1
  91. package/dist/feature-flags/growthbook-adapter.cjs.map +1 -1
  92. package/dist/feature-flags/growthbook-adapter.js +1 -1
  93. package/dist/feature-flags/growthbook-adapter.js.map +1 -1
  94. package/dist/hooks/use-focus-trap.cjs +1 -1
  95. package/dist/hooks/use-focus-trap.cjs.map +1 -1
  96. package/dist/hooks/use-focus-trap.js +1 -1
  97. package/dist/hooks/use-focus-trap.js.map +1 -1
  98. package/dist/hooks/use-push-to-talk.cjs +1 -1
  99. package/dist/hooks/use-push-to-talk.cjs.map +1 -1
  100. package/dist/hooks/use-push-to-talk.js +1 -1
  101. package/dist/hooks/use-push-to-talk.js.map +1 -1
  102. package/dist/http/describe-api-error.cjs +1 -1
  103. package/dist/http/describe-api-error.cjs.map +1 -1
  104. package/dist/http/describe-api-error.js +12 -8
  105. package/dist/http/describe-api-error.js.map +1 -1
  106. package/dist/http/errors.cjs +1 -1
  107. package/dist/http/errors.cjs.map +1 -1
  108. package/dist/http/errors.js +21 -16
  109. package/dist/http/errors.js.map +1 -1
  110. package/dist/http/resumable-upload.cjs +1 -1
  111. package/dist/http/resumable-upload.cjs.map +1 -1
  112. package/dist/http/resumable-upload.js +1 -1
  113. package/dist/http/resumable-upload.js.map +1 -1
  114. package/dist/icons/generated/aliases.cjs +1 -1
  115. package/dist/icons/generated/aliases.cjs.map +1 -1
  116. package/dist/icons/generated/aliases.js +1 -0
  117. package/dist/icons/generated/aliases.js.map +1 -1
  118. package/dist/icons/generated/icon-names.cjs +1 -1
  119. package/dist/icons/generated/icon-names.cjs.map +1 -1
  120. package/dist/icons/generated/icon-names.js +1 -1
  121. package/dist/icons/generated/icon-names.js.map +1 -1
  122. package/dist/icons/generated/loaders.cjs +1 -1
  123. package/dist/icons/generated/loaders.cjs.map +1 -1
  124. package/dist/icons/generated/loaders.js +48 -42
  125. package/dist/icons/generated/loaders.js.map +1 -1
  126. package/dist/icons/generated/shard-02.cjs +1 -1
  127. package/dist/icons/generated/shard-02.cjs.map +1 -1
  128. package/dist/icons/generated/shard-02.js +20 -20
  129. package/dist/icons/generated/shard-02.js.map +1 -1
  130. package/dist/icons/generated/shard-03.cjs +1 -1
  131. package/dist/icons/generated/shard-03.cjs.map +1 -1
  132. package/dist/icons/generated/shard-03.js +41 -41
  133. package/dist/icons/generated/shard-03.js.map +1 -1
  134. package/dist/icons/generated/shard-04.cjs +1 -1
  135. package/dist/icons/generated/shard-04.cjs.map +1 -1
  136. package/dist/icons/generated/shard-04.js +41 -41
  137. package/dist/icons/generated/shard-04.js.map +1 -1
  138. package/dist/icons/generated/shard-05.cjs +1 -1
  139. package/dist/icons/generated/shard-05.cjs.map +1 -1
  140. package/dist/icons/generated/shard-05.js +41 -41
  141. package/dist/icons/generated/shard-05.js.map +1 -1
  142. package/dist/icons/generated/shard-06.cjs +1 -1
  143. package/dist/icons/generated/shard-06.cjs.map +1 -1
  144. package/dist/icons/generated/shard-06.js +41 -41
  145. package/dist/icons/generated/shard-06.js.map +1 -1
  146. package/dist/icons/generated/shard-07.cjs +1 -1
  147. package/dist/icons/generated/shard-07.cjs.map +1 -1
  148. package/dist/icons/generated/shard-07.js +41 -41
  149. package/dist/icons/generated/shard-07.js.map +1 -1
  150. package/dist/icons/generated/shard-08.cjs +1 -1
  151. package/dist/icons/generated/shard-08.cjs.map +1 -1
  152. package/dist/icons/generated/shard-08.js +41 -41
  153. package/dist/icons/generated/shard-08.js.map +1 -1
  154. package/dist/icons/generated/shard-09.cjs +1 -1
  155. package/dist/icons/generated/shard-09.cjs.map +1 -1
  156. package/dist/icons/generated/shard-09.js +41 -41
  157. package/dist/icons/generated/shard-09.js.map +1 -1
  158. package/dist/icons/generated/shard-10.cjs +1 -1
  159. package/dist/icons/generated/shard-10.cjs.map +1 -1
  160. package/dist/icons/generated/shard-10.js +41 -41
  161. package/dist/icons/generated/shard-10.js.map +1 -1
  162. package/dist/icons/generated/shard-11.cjs +1 -1
  163. package/dist/icons/generated/shard-11.cjs.map +1 -1
  164. package/dist/icons/generated/shard-11.js +41 -41
  165. package/dist/icons/generated/shard-11.js.map +1 -1
  166. package/dist/icons/generated/shard-12.cjs +1 -1
  167. package/dist/icons/generated/shard-12.cjs.map +1 -1
  168. package/dist/icons/generated/shard-12.js +41 -41
  169. package/dist/icons/generated/shard-12.js.map +1 -1
  170. package/dist/icons/generated/shard-13.cjs +1 -1
  171. package/dist/icons/generated/shard-13.cjs.map +1 -1
  172. package/dist/icons/generated/shard-13.js +41 -41
  173. package/dist/icons/generated/shard-13.js.map +1 -1
  174. package/dist/icons/generated/shard-14.cjs +1 -1
  175. package/dist/icons/generated/shard-14.cjs.map +1 -1
  176. package/dist/icons/generated/shard-14.js +41 -41
  177. package/dist/icons/generated/shard-14.js.map +1 -1
  178. package/dist/icons/generated/shard-15.cjs +1 -1
  179. package/dist/icons/generated/shard-15.cjs.map +1 -1
  180. package/dist/icons/generated/shard-15.js +41 -41
  181. package/dist/icons/generated/shard-15.js.map +1 -1
  182. package/dist/icons/generated/shard-16.cjs +1 -1
  183. package/dist/icons/generated/shard-16.cjs.map +1 -1
  184. package/dist/icons/generated/shard-16.js +41 -41
  185. package/dist/icons/generated/shard-16.js.map +1 -1
  186. package/dist/icons/generated/shard-17.cjs +1 -1
  187. package/dist/icons/generated/shard-17.cjs.map +1 -1
  188. package/dist/icons/generated/shard-17.js +41 -41
  189. package/dist/icons/generated/shard-17.js.map +1 -1
  190. package/dist/icons/generated/shard-18.cjs +1 -1
  191. package/dist/icons/generated/shard-18.cjs.map +1 -1
  192. package/dist/icons/generated/shard-18.js +41 -41
  193. package/dist/icons/generated/shard-18.js.map +1 -1
  194. package/dist/icons/generated/shard-19.cjs +1 -1
  195. package/dist/icons/generated/shard-19.cjs.map +1 -1
  196. package/dist/icons/generated/shard-19.js +41 -41
  197. package/dist/icons/generated/shard-19.js.map +1 -1
  198. package/dist/icons/generated/shard-20.cjs +1 -1
  199. package/dist/icons/generated/shard-20.cjs.map +1 -1
  200. package/dist/icons/generated/shard-20.js +41 -41
  201. package/dist/icons/generated/shard-20.js.map +1 -1
  202. package/dist/icons/generated/shard-21.cjs +1 -1
  203. package/dist/icons/generated/shard-21.cjs.map +1 -1
  204. package/dist/icons/generated/shard-21.js +41 -41
  205. package/dist/icons/generated/shard-21.js.map +1 -1
  206. package/dist/icons/generated/shard-22.cjs +1 -1
  207. package/dist/icons/generated/shard-22.cjs.map +1 -1
  208. package/dist/icons/generated/shard-22.js +41 -41
  209. package/dist/icons/generated/shard-22.js.map +1 -1
  210. package/dist/icons/generated/shard-23.cjs +1 -1
  211. package/dist/icons/generated/shard-23.cjs.map +1 -1
  212. package/dist/icons/generated/shard-23.js +41 -41
  213. package/dist/icons/generated/shard-23.js.map +1 -1
  214. package/dist/icons/generated/shard-24.cjs +1 -1
  215. package/dist/icons/generated/shard-24.cjs.map +1 -1
  216. package/dist/icons/generated/shard-24.js +41 -41
  217. package/dist/icons/generated/shard-24.js.map +1 -1
  218. package/dist/icons/generated/shard-25.cjs +1 -1
  219. package/dist/icons/generated/shard-25.cjs.map +1 -1
  220. package/dist/icons/generated/shard-25.js +41 -41
  221. package/dist/icons/generated/shard-25.js.map +1 -1
  222. package/dist/icons/generated/shard-26.cjs +1 -1
  223. package/dist/icons/generated/shard-26.cjs.map +1 -1
  224. package/dist/icons/generated/shard-26.js +41 -41
  225. package/dist/icons/generated/shard-26.js.map +1 -1
  226. package/dist/icons/generated/shard-27.cjs +1 -1
  227. package/dist/icons/generated/shard-27.cjs.map +1 -1
  228. package/dist/icons/generated/shard-27.js +41 -41
  229. package/dist/icons/generated/shard-27.js.map +1 -1
  230. package/dist/icons/generated/shard-28.cjs +1 -1
  231. package/dist/icons/generated/shard-28.cjs.map +1 -1
  232. package/dist/icons/generated/shard-28.js +41 -41
  233. package/dist/icons/generated/shard-28.js.map +1 -1
  234. package/dist/icons/generated/shard-29.cjs +1 -1
  235. package/dist/icons/generated/shard-29.cjs.map +1 -1
  236. package/dist/icons/generated/shard-29.js +41 -41
  237. package/dist/icons/generated/shard-29.js.map +1 -1
  238. package/dist/icons/generated/shard-30.cjs +1 -1
  239. package/dist/icons/generated/shard-30.cjs.map +1 -1
  240. package/dist/icons/generated/shard-30.js +41 -41
  241. package/dist/icons/generated/shard-30.js.map +1 -1
  242. package/dist/icons/generated/shard-31.cjs +1 -1
  243. package/dist/icons/generated/shard-31.cjs.map +1 -1
  244. package/dist/icons/generated/shard-31.js +41 -41
  245. package/dist/icons/generated/shard-31.js.map +1 -1
  246. package/dist/icons/generated/shard-32.cjs +1 -1
  247. package/dist/icons/generated/shard-32.cjs.map +1 -1
  248. package/dist/icons/generated/shard-32.js +41 -41
  249. package/dist/icons/generated/shard-32.js.map +1 -1
  250. package/dist/icons/generated/shard-33.cjs +1 -1
  251. package/dist/icons/generated/shard-33.cjs.map +1 -1
  252. package/dist/icons/generated/shard-33.js +41 -41
  253. package/dist/icons/generated/shard-33.js.map +1 -1
  254. package/dist/icons/generated/shard-34.cjs +1 -1
  255. package/dist/icons/generated/shard-34.cjs.map +1 -1
  256. package/dist/icons/generated/shard-34.js +41 -41
  257. package/dist/icons/generated/shard-34.js.map +1 -1
  258. package/dist/icons/generated/shard-35.cjs +1 -1
  259. package/dist/icons/generated/shard-35.cjs.map +1 -1
  260. package/dist/icons/generated/shard-35.js +41 -41
  261. package/dist/icons/generated/shard-35.js.map +1 -1
  262. package/dist/icons/generated/shard-36.cjs +1 -1
  263. package/dist/icons/generated/shard-36.cjs.map +1 -1
  264. package/dist/icons/generated/shard-36.js +41 -41
  265. package/dist/icons/generated/shard-36.js.map +1 -1
  266. package/dist/icons/generated/shard-37.cjs +1 -1
  267. package/dist/icons/generated/shard-37.cjs.map +1 -1
  268. package/dist/icons/generated/shard-37.js +41 -41
  269. package/dist/icons/generated/shard-37.js.map +1 -1
  270. package/dist/icons/generated/shard-38.cjs +1 -1
  271. package/dist/icons/generated/shard-38.cjs.map +1 -1
  272. package/dist/icons/generated/shard-38.js +41 -41
  273. package/dist/icons/generated/shard-38.js.map +1 -1
  274. package/dist/icons/generated/shard-39.cjs +1 -1
  275. package/dist/icons/generated/shard-39.cjs.map +1 -1
  276. package/dist/icons/generated/shard-39.js +41 -41
  277. package/dist/icons/generated/shard-39.js.map +1 -1
  278. package/dist/icons/generated/shard-40.cjs +1 -1
  279. package/dist/icons/generated/shard-40.cjs.map +1 -1
  280. package/dist/icons/generated/shard-40.js +41 -41
  281. package/dist/icons/generated/shard-40.js.map +1 -1
  282. package/dist/icons/generated/shard-41.cjs +1 -1
  283. package/dist/icons/generated/shard-41.cjs.map +1 -1
  284. package/dist/icons/generated/shard-41.js +41 -41
  285. package/dist/icons/generated/shard-41.js.map +1 -1
  286. package/dist/icons/generated/shard-42.cjs +1 -1
  287. package/dist/icons/generated/shard-42.cjs.map +1 -1
  288. package/dist/icons/generated/shard-42.js +41 -41
  289. package/dist/icons/generated/shard-42.js.map +1 -1
  290. package/dist/icons/generated/shard-43.cjs +1 -1
  291. package/dist/icons/generated/shard-43.cjs.map +1 -1
  292. package/dist/icons/generated/shard-43.js +41 -41
  293. package/dist/icons/generated/shard-43.js.map +1 -1
  294. package/dist/icons/generated/shard-44.cjs +1 -1
  295. package/dist/icons/generated/shard-44.cjs.map +1 -1
  296. package/dist/icons/generated/shard-44.js +43 -10
  297. package/dist/icons/generated/shard-44.js.map +1 -1
  298. package/dist/icons/generated/shard-45.cjs +2 -0
  299. package/dist/icons/generated/shard-45.cjs.map +1 -0
  300. package/dist/icons/generated/shard-45.js +15 -0
  301. package/dist/icons/generated/shard-45.js.map +1 -0
  302. package/dist/icons/material-symbols.cjs +1 -1
  303. package/dist/icons/material-symbols.cjs.map +1 -1
  304. package/dist/icons/material-symbols.js +3 -3
  305. package/dist/icons/material-symbols.js.map +1 -1
  306. package/dist/icons.d.ts +4 -4
  307. package/dist/query/foreign-client-warning.cjs +1 -1
  308. package/dist/query/foreign-client-warning.cjs.map +1 -1
  309. package/dist/query/foreign-client-warning.js +1 -1
  310. package/dist/query/foreign-client-warning.js.map +1 -1
  311. package/dist/styles/Alert.css +1 -1
  312. package/dist/styles/Badge.css +1 -1
  313. package/dist/styles/BarList.css +3 -3
  314. package/dist/styles/BottomSheet.css +1 -1
  315. package/dist/styles/DataTable.css +1 -1
  316. package/dist/styles/Dropzone.css +1 -1
  317. package/dist/styles/ErrorText.css +1 -1
  318. package/dist/styles/Markdown.css +1 -1
  319. package/dist/styles/PasswordInput.css +1 -1
  320. package/dist/styles/SegmentedControl.css +1 -1
  321. package/dist/styles/Sidebar.css +2 -2
  322. package/dist/styles/StepperInput.css +1 -1
  323. package/dist/styles/Tag.css +1 -1
  324. package/dist/styles/Timeline.css +1 -1
  325. package/dist/styles/Toggle.css +1 -1
  326. package/dist/styles/ToggleGroup.css +1 -1
  327. package/dist/styles/advanced.css +2 -2
  328. package/dist/styles/core.css +4 -2
  329. package/dist/styles/data.css +6 -6
  330. package/dist/styles/feedback.css +3 -3
  331. package/dist/styles/forms.css +3 -3
  332. package/dist/styles/navigation.css +3 -3
  333. package/dist/styles/overlay.css +1 -1
  334. package/dist/styles/utility.css +1 -1
  335. package/dist/styles.css +1 -1
  336. package/dist/tempest-react-sdk.cjs +1 -1
  337. package/dist/tempest-react-sdk.d.ts +81 -7
  338. package/dist/tempest-react-sdk.js +347 -346
  339. package/dist/theme/create-theme.cjs +3 -3
  340. package/dist/theme/create-theme.cjs.map +1 -1
  341. package/dist/theme/create-theme.js +15 -14
  342. package/dist/theme/create-theme.js.map +1 -1
  343. package/dist/utils/dev-mode.cjs +1 -1
  344. package/dist/utils/dev-mode.cjs.map +1 -1
  345. package/dist/utils/dev-mode.js +7 -2
  346. package/dist/utils/dev-mode.js.map +1 -1
  347. package/dist/utils/json-frame.cjs +1 -1
  348. package/dist/utils/json-frame.cjs.map +1 -1
  349. package/dist/utils/json-frame.js +1 -1
  350. package/dist/utils/json-frame.js.map +1 -1
  351. package/dist/vision/core/providers.cjs +1 -1
  352. package/dist/vision/core/providers.cjs.map +1 -1
  353. package/dist/vision/core/providers.js +22 -3
  354. package/dist/vision/core/providers.js.map +1 -1
  355. package/dist/vision/core/session.cjs +1 -1
  356. package/dist/vision/core/session.cjs.map +1 -1
  357. package/dist/vision/core/session.js +22 -15
  358. package/dist/vision/core/session.js.map +1 -1
  359. package/dist/vision/fusion.cjs.map +1 -1
  360. package/dist/vision/fusion.js.map +1 -1
  361. package/dist/vision/index.cjs +1 -1
  362. package/dist/vision/index.cjs.map +1 -1
  363. package/dist/vision/index.js +17 -16
  364. package/dist/vision/index.js.map +1 -1
  365. package/dist/vision/normalization.cjs +2 -0
  366. package/dist/vision/normalization.cjs.map +1 -0
  367. package/dist/vision/normalization.js +49 -0
  368. package/dist/vision/normalization.js.map +1 -0
  369. package/dist/vision/results.cjs +1 -1
  370. package/dist/vision/results.cjs.map +1 -1
  371. package/dist/vision/results.js +8 -2
  372. package/dist/vision/results.js.map +1 -1
  373. package/dist/vision/tasks/classifier.cjs +1 -1
  374. package/dist/vision/tasks/classifier.cjs.map +1 -1
  375. package/dist/vision/tasks/classifier.js +36 -32
  376. package/dist/vision/tasks/classifier.js.map +1 -1
  377. package/dist/vision.cjs +1 -1
  378. package/dist/vision.d.ts +218 -13
  379. package/dist/vision.js +19 -18
  380. package/dist/vite/tempest-pwa-manifest.cjs +1 -1
  381. package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
  382. package/dist/vite/tempest-pwa-manifest.js +1 -1
  383. package/dist/vite/tempest-pwa-manifest.js.map +1 -1
  384. package/dist/webrtc/peer-link.cjs +1 -1
  385. package/dist/webrtc/peer-link.cjs.map +1 -1
  386. package/dist/webrtc/peer-link.js +1 -1
  387. package/dist/webrtc/peer-link.js.map +1 -1
  388. package/dist/webrtc/peer-mesh.cjs +1 -1
  389. package/dist/webrtc/peer-mesh.cjs.map +1 -1
  390. package/dist/webrtc/peer-mesh.js +1 -1
  391. package/dist/webrtc/peer-mesh.js.map +1 -1
  392. package/dist/ws/create-web-socket.cjs +1 -1
  393. package/dist/ws/create-web-socket.cjs.map +1 -1
  394. package/dist/ws/create-web-socket.js +1 -1
  395. package/dist/ws/create-web-socket.js.map +1 -1
  396. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"session.cjs","names":[],"sources":["../../../src/vision/core/session.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Thin wrapper around `onnxruntime-web` `InferenceSession` with typed metadata.\n */\n\nimport type * as ort from \"onnxruntime-web\";\nimport * as ortRuntime from \"onnxruntime-web\";\n\nimport { InferenceError, ModelLoadError } from \"./exceptions\";\nimport { type DeclaredShape, declaredShapesFrom } from \"./graph\";\nimport { readModelMetadata } from \"./metadata\";\nimport { resolveProviders } from \"./providers\";\n\n/** Anything `InferenceSession.create` accepts. */\nexport type ModelSource = string | ArrayBufferLike | Uint8Array;\n\n/**\n * Fetch a model URL as bytes so its metadata can be read.\n *\n * Falls back to the URL itself when the fetch fails, letting ORT try its own\n * load path: losing the metadata map is a downgrade, but failing to load a model\n * that ORT could have fetched would be a regression.\n *\n * @param url Where the `.onnx` lives.\n * @returns The model bytes, or the original URL when they could not be fetched.\n */\nasync function fetchModel(url: string): Promise<Uint8Array | string> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n warnMetadataUnavailable(url, `HTTP ${response.status} ${response.statusText}`);\n return url;\n }\n return new Uint8Array(await response.arrayBuffer());\n } catch (err) {\n warnMetadataUnavailable(url, (err as Error).message);\n return url;\n }\n}\n\n/**\n * Warn that a model's metadata could not be read, and say what that costs.\n *\n * The fallback itself is right — losing the metadata beats failing a load that\n * ORT could have completed on its own — but it used to be silent, and the\n * symptom it produces is remote from the cause: class names come back as\n * `class_0`, `class_1`, ... with nothing anywhere explaining why. Whoever hits\n * this needs to be told that passing `labels` is the way out.\n *\n * @param url The model URL that could not be fetched here.\n * @param reason What went wrong, as reported by `fetch`.\n */\nfunction warnMetadataUnavailable(url: string, reason: string): void {\n console.warn(\n `[@ort-vision-sdk/web] Could not fetch ${url} to read its metadata (${reason}). ` +\n \"Letting ONNX Runtime load it instead: the model will work, but its baked-in \" +\n \"class names are unavailable, so labels fall back to class_0, class_1, ... \" +\n \"Pass `labels` explicitly to name them.\",\n );\n}\n\nexport interface OrtSessionOptions {\n /** Execution providers in preference order. `undefined` uses {@link DEFAULT_PROVIDERS}. */\n readonly providers?: readonly string[];\n /** Optional ORT session options forwarded to `InferenceSession.create`. */\n readonly sessionOptions?: ort.InferenceSession.SessionOptions;\n /**\n * Whether to read the model's custom metadata map (`names`, `task`, `imgsz`).\n * Defaults to `true`.\n *\n * The runtime does not expose that map, so it is read from the file itself —\n * which means a URL model is fetched here and handed to ORT as bytes instead\n * of letting ORT fetch it. That is the same single download either way, and\n * it is what lets a task resolve its labels off the model. Set to `false` to\n * keep the URL path untouched and leave {@link OrtSession.metadata} empty.\n *\n * `false` is also the escape hatch when a device cannot afford the bytes: the\n * fetched buffer is dropped before ORT builds the graph (see\n * {@link OrtSession.create}), but ORT's own load path still keeps the model out\n * of reach of anything the SDK holds. A session built this way resolves its\n * input size from the graph as usual — only the class names are lost, so a\n * caller taking this route has to pass `labels` itself.\n */\n readonly readMetadata?: boolean;\n}\n\n/**\n * Wrap an ONNX Runtime Web `InferenceSession` with convenient metadata access.\n *\n * The wrapper exposes input/output names and the shapes the graph declares,\n * manages execution-provider selection, provides a typed {@link OrtSession.run}\n * method, and releases the native session through {@link OrtSession.release}.\n */\nexport class OrtSession {\n private constructor(\n private readonly _session: ort.InferenceSession,\n public readonly providers: readonly string[],\n private readonly _metadata: Readonly<Record<string, string>>,\n ) {}\n\n /**\n * Load an ONNX model into an ORT inference session.\n *\n * The metadata map is read **before** the session is built, and that order is\n * load-bearing on memory-constrained devices. ORT copies the model into its\n * WASM heap and then allocates the graph and the weights on top of that copy;\n * a `readModelMetadata` call placed after `InferenceSession.create` keeps the\n * JavaScript-side buffer reachable across the whole build, so a 5 MB model\n * costs 5 MB of JS heap plus 5 MB of WASM heap plus the weights at the same\n * instant. Reading first makes the buffer collectable as soon as ORT has copied\n * it — on a phone that was the difference between a session and\n * `Can't create a session. failed to allocate a buffer of size N`.\n *\n * @param model Either a URL string, or a `Uint8Array`/`ArrayBuffer` containing the model bytes.\n * @param options Provider list, pass-through `SessionOptions`, and whether to\n * read the model's metadata map (see {@link OrtSessionOptions.readMetadata}).\n * @throws {@link ModelLoadError} if the model cannot be loaded.\n */\n static async create(model: ModelSource, options: OrtSessionOptions = {}): Promise<OrtSession> {\n const providers = resolveProviders(options.providers);\n const sessionOptions: ort.InferenceSession.SessionOptions = {\n ...(options.sessionOptions ?? {}),\n executionProviders:\n providers as ort.InferenceSession.SessionOptions[\"executionProviders\"],\n };\n const wantsMetadata = options.readMetadata !== false;\n const source = typeof model === \"string\" && wantsMetadata ? await fetchModel(model) : model;\n const metadata =\n wantsMetadata && typeof source !== \"string\" ? readModelMetadata(source) : {};\n\n let session: ort.InferenceSession;\n try {\n if (typeof source === \"string\") {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else if (source instanceof Uint8Array) {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else {\n session = await ortRuntime.InferenceSession.create(\n source as ArrayBuffer,\n sessionOptions,\n );\n }\n } catch (err) {\n throw new ModelLoadError(`Failed to load ONNX model: ${(err as Error).message}`, {\n cause: err,\n });\n }\n\n return new OrtSession(session, providers, metadata);\n }\n\n /** Names of the model's inputs, in declaration order. */\n get inputNames(): readonly string[] {\n return this._session.inputNames;\n }\n\n /** Name of the first (and usually only) input. */\n get inputName(): string {\n const name = this._session.inputNames[0];\n if (name === undefined) {\n throw new InferenceError(\"Model has no inputs.\");\n }\n return name;\n }\n\n /** Names of the model's outputs, in declaration order. */\n get outputNames(): readonly string[] {\n return this._session.outputNames;\n }\n\n /**\n * Shapes the graph declares for its inputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Empty shapes mean the runtime\n * reported no metadata — either a non-tensor input, or an `onnxruntime-web`\n * older than 1.21, which predates input metadata.\n */\n get inputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.inputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first input, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get inputShape(): DeclaredShape {\n return this.inputShapes[0] ?? [];\n }\n\n /**\n * Shapes the graph declares for its outputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Reading them is how a task can\n * tell how many classes a head emits without being told.\n */\n get outputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.outputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first output, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get outputShape(): DeclaredShape {\n return this.outputShapes[0] ?? [];\n }\n\n /**\n * The model's custom metadata map — `names`, `task`, `imgsz`, ... for an\n * Ultralytics export.\n *\n * Read from the model's bytes at load time, since the runtime does not expose\n * it. Empty when the session was created with `readMetadata: false`, from a\n * URL that could not be fetched here, or from a model carrying no metadata.\n */\n get metadata(): Readonly<Record<string, string>> {\n return this._metadata;\n }\n\n /**\n * Release the native session and free its memory.\n *\n * Call it when a session is discarded while the page lives on — rebuilding a\n * task at a different input size, swapping in a newer model. A failure from\n * the runtime is ignored: a session being torn down has nothing left to fail\n * at, and the caller is already moving on.\n */\n async release(): Promise<void> {\n await this._session.release().catch(() => undefined);\n }\n\n /** The underlying `onnxruntime-web` session, for advanced use cases. */\n get raw(): ort.InferenceSession {\n return this._session;\n }\n\n /**\n * Run inference and return all outputs.\n *\n * @param feeds Map of input name to `ort.Tensor`. Keys must match {@link inputNames}.\n * @throws {@link InferenceError} if ORT raises any error during execution.\n */\n async run(feeds: Record<string, ort.Tensor>): Promise<Record<string, ort.Tensor>> {\n try {\n const result = await this._session.run(feeds);\n return result as Record<string, ort.Tensor>;\n } catch (err) {\n throw new InferenceError(`Inference failed: ${(err as Error).message}`, { cause: err });\n }\n }\n}\n"],"mappings":"0NA0BA,eAAe,EAAW,EAA2C,CACjE,GAAI,CACA,IAAM,EAAW,MAAM,MAAM,CAAG,EAKhC,OAJK,EAAS,GAIP,IAAI,WAAW,MAAM,EAAS,YAAY,CAAC,GAH9C,EAAwB,EAAK,QAAQ,EAAS,OAAO,GAAG,EAAS,YAAY,EACtE,EAGf,OAAS,EAAK,CAEV,OADA,EAAwB,EAAM,EAAc,OAAO,EAC5C,CACX,CACJ,CAcA,SAAS,EAAwB,EAAa,EAAsB,CAChE,QAAQ,KACJ,yCAAyC,EAAI,yBAAyB,EAAO,kMAIjF,CACJ,CAkCA,IAAa,EAAb,MAAa,CAAW,CAEC,SACD,UACC,UAHrB,YACI,EACA,EACA,EACF,CAHmB,KAAA,SAAA,EACD,KAAA,UAAA,EACC,KAAA,UAAA,CAClB,CAoBH,aAAa,OAAO,EAAoB,EAA6B,CAAC,EAAwB,CAC1F,IAAM,EAAY,EAAA,iBAAiB,EAAQ,SAAS,EAC9C,EAAsD,CACxD,GAAI,EAAQ,gBAAkB,CAAC,EAC/B,mBACI,CACR,EACM,EAAgB,EAAQ,eAAiB,GACzC,EAAS,OAAO,GAAU,UAAY,EAAgB,MAAM,EAAW,CAAK,EAAI,EAChF,EACF,GAAiB,OAAO,GAAW,SAAW,EAAA,kBAAkB,CAAM,EAAI,CAAC,EAE3E,EACJ,GAAI,CACA,AAKI,GALA,OAAO,GAAW,UAEX,aAAkB,WADf,MAAM,EAAW,iBAAiB,OAAO,EAAQ,CAAc,EASjF,OAAS,EAAK,CACV,MAAM,IAAI,EAAA,eAAe,8BAA+B,EAAc,UAAW,CAC7E,MAAO,CACX,CAAC,CACL,CAEA,OAAO,IAAI,EAAW,EAAS,EAAW,CAAQ,CACtD,CAGA,IAAI,YAAgC,CAChC,OAAO,KAAK,SAAS,UACzB,CAGA,IAAI,WAAoB,CACpB,IAAM,EAAO,KAAK,SAAS,WAAW,GACtC,GAAI,IAAS,IAAA,GACT,MAAM,IAAI,EAAA,eAAe,sBAAsB,EAEnD,OAAO,CACX,CAGA,IAAI,aAAiC,CACjC,OAAO,KAAK,SAAS,WACzB,CASA,IAAI,aAAwC,CACxC,OAAO,EAAA,mBACH,KAAK,SAAS,aAElB,CACJ,CAOA,IAAI,YAA4B,CAC5B,OAAO,KAAK,YAAY,IAAM,CAAC,CACnC,CAQA,IAAI,cAAyC,CACzC,OAAO,EAAA,mBACH,KAAK,SAAS,cAElB,CACJ,CAOA,IAAI,aAA6B,CAC7B,OAAO,KAAK,aAAa,IAAM,CAAC,CACpC,CAUA,IAAI,UAA6C,CAC7C,OAAO,KAAK,SAChB,CAUA,MAAM,SAAyB,CAC3B,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,UAAY,IAAA,EAAS,CACvD,CAGA,IAAI,KAA4B,CAC5B,OAAO,KAAK,QAChB,CAQA,MAAM,IAAI,EAAwE,CAC9E,GAAI,CAEA,OAAO,MADc,KAAK,SAAS,IAAI,CAAK,CAEhD,OAAS,EAAK,CACV,MAAM,IAAI,EAAA,eAAe,qBAAsB,EAAc,UAAW,CAAE,MAAO,CAAI,CAAC,CAC1F,CACJ,CACJ"}
1
+ {"version":3,"file":"session.cjs","names":[],"sources":["../../../src/vision/core/session.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Thin wrapper around `onnxruntime-web` `InferenceSession` with typed metadata.\n */\n\nimport type * as ort from \"onnxruntime-web\";\nimport * as ortRuntime from \"onnxruntime-web\";\n\nimport { InferenceError, ModelLoadError } from \"./exceptions\";\nimport { type DeclaredShape, declaredShapesFrom } from \"./graph\";\nimport { readModelMetadata } from \"./metadata\";\nimport { FALLBACK_PROVIDER, detectProviders, resolveProviders } from \"./providers\";\n\n/** Anything `InferenceSession.create` accepts. */\nexport type ModelSource = string | ArrayBufferLike | Uint8Array;\n\n/**\n * Fetch a model URL as bytes so its metadata can be read.\n *\n * Falls back to the URL itself when the fetch fails, letting ORT try its own\n * load path: losing the metadata map is a downgrade, but failing to load a model\n * that ORT could have fetched would be a regression.\n *\n * @param url Where the `.onnx` lives.\n * @returns The model bytes, or the original URL when they could not be fetched.\n */\nasync function fetchModel(url: string): Promise<Uint8Array | string> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n warnMetadataUnavailable(url, `HTTP ${response.status} ${response.statusText}`);\n return url;\n }\n return new Uint8Array(await response.arrayBuffer());\n } catch (err) {\n warnMetadataUnavailable(url, (err as Error).message);\n return url;\n }\n}\n\n/**\n * Warn that a model's metadata could not be read, and say what that costs.\n *\n * The fallback itself is right — losing the metadata beats failing a load that\n * ORT could have completed on its own — but it used to be silent, and the\n * symptom it produces is remote from the cause: class names come back as\n * `class_0`, `class_1`, ... with nothing anywhere explaining why. Whoever hits\n * this needs to be told that passing `labels` is the way out.\n *\n * @param url The model URL that could not be fetched here.\n * @param reason What went wrong, as reported by `fetch`.\n */\nfunction warnMetadataUnavailable(url: string, reason: string): void {\n console.warn(\n `[@ort-vision-sdk/web] Could not fetch ${url} to read its metadata (${reason}). ` +\n \"Letting ONNX Runtime load it instead: the model will work, but its baked-in \" +\n \"class names are unavailable, so labels fall back to class_0, class_1, ... \" +\n \"Pass `labels` explicitly to name them.\",\n );\n}\n\nexport interface OrtSessionOptions {\n /**\n * Execution providers in preference order. `undefined` uses {@link DEFAULT_PROVIDERS}.\n *\n * Naming one explicitly also opts into a `console.warn` when this browser\n * cannot offer it, instead of falling back in silence.\n */\n readonly providers?: readonly string[];\n /** Optional ORT session options forwarded to `InferenceSession.create`. */\n readonly sessionOptions?: ort.InferenceSession.SessionOptions;\n /**\n * Whether to read the model's custom metadata map (`names`, `task`, `imgsz`).\n * Defaults to `true`.\n *\n * The runtime does not expose that map, so it is read from the file itself —\n * which means a URL model is fetched here and handed to ORT as bytes instead\n * of letting ORT fetch it. That is the same single download either way, and\n * it is what lets a task resolve its labels off the model. Set to `false` to\n * keep the URL path untouched and leave {@link OrtSession.metadata} empty.\n *\n * `false` is also the escape hatch when a device cannot afford the bytes: the\n * fetched buffer is dropped before ORT builds the graph (see\n * {@link OrtSession.create}), but ORT's own load path still keeps the model out\n * of reach of anything the SDK holds. A session built this way resolves its\n * input size from the graph as usual — only the class names are lost, so a\n * caller taking this route has to pass `labels` itself.\n */\n readonly readMetadata?: boolean;\n}\n\n/**\n * Warn when a provider named explicitly by the caller is not going to run.\n *\n * Only explicit requests are worth a warning. The default list exists precisely\n * so that falling from `webgpu` to `wasm` is the expected outcome — but a caller\n * who wrote `providers: [\"webgpu\"]` and lands on WASM has a page several times\n * slower than intended and nothing in the console to explain it.\n *\n * @param requested Providers that were asked for.\n * @param effective Providers that survived capability detection.\n */\nfunction warnOnDroppedProviders(requested: readonly string[], effective: readonly string[]): void {\n const dropped = requested.filter((provider) => !effective.includes(provider));\n if (dropped.length === 0) {\n return;\n }\n console.warn(\n `This browser cannot offer the requested execution provider(s) ${JSON.stringify(dropped)}; ` +\n `the session will run on ${JSON.stringify(effective)}. Inference still produces correct ` +\n \"results, on the fallback provider.\",\n );\n}\n\n/**\n * Wrap an ONNX Runtime Web `InferenceSession` with convenient metadata access.\n *\n * The wrapper exposes input/output names and the shapes the graph declares,\n * manages execution-provider selection, provides a typed {@link OrtSession.run}\n * method, and releases the native session through {@link OrtSession.release}.\n */\nexport class OrtSession {\n private constructor(\n private readonly _session: ort.InferenceSession,\n /**\n * Execution providers this session is expected to run on.\n *\n * The requested list narrowed to what this browser can actually offer — a\n * `webgpu` entry survives only where an adapter exists. Best-effort: ORT-Web\n * exposes no way to ask which provider a session ended up on, so an entry\n * here means \"not ruled out\", not \"confirmed\". See\n * {@link requestedProviders} for what was asked for.\n *\n * When nothing survives — a caller asking for `webgpu` alone on a device\n * without it — this falls back to {@link FALLBACK_PROVIDER}, which ORT-Web\n * can always run. Handing ORT the unsatisfiable list instead makes\n * `InferenceSession.create` reject with \"no available backend found\", so the\n * page gets no inference at all rather than the slow-but-working fallback\n * the `console.warn` describes. Measured in a real Chromium, where\n * `navigator.gpu` exists but yields no adapter.\n */\n public readonly providers: readonly string[],\n private readonly _metadata: Readonly<Record<string, string>>,\n /**\n * Execution providers that were asked for, after defaults were applied.\n *\n * Kept separate because ORT-Web falls back silently: a page that asks for\n * `webgpu` on a device without it runs on WASM and is told nothing.\n */\n public readonly requestedProviders: readonly string[],\n ) {}\n\n /**\n * Load an ONNX model into an ORT inference session.\n *\n * The metadata map is read **before** the session is built, and that order is\n * load-bearing on memory-constrained devices. ORT copies the model into its\n * WASM heap and then allocates the graph and the weights on top of that copy;\n * a `readModelMetadata` call placed after `InferenceSession.create` keeps the\n * JavaScript-side buffer reachable across the whole build, so a 5 MB model\n * costs 5 MB of JS heap plus 5 MB of WASM heap plus the weights at the same\n * instant. Reading first makes the buffer collectable as soon as ORT has copied\n * it — on a phone that was the difference between a session and\n * `Can't create a session. failed to allocate a buffer of size N`.\n *\n * @param model Either a URL string, or a `Uint8Array`/`ArrayBuffer` containing the model bytes.\n * @param options Provider list, pass-through `SessionOptions`, and whether to\n * read the model's metadata map (see {@link OrtSessionOptions.readMetadata}).\n * @throws {@link ModelLoadError} if the model cannot be loaded.\n */\n static async create(model: ModelSource, options: OrtSessionOptions = {}): Promise<OrtSession> {\n const requested = resolveProviders(options.providers);\n const detected = await detectProviders(requested);\n const providers = detected.length > 0 ? detected : [FALLBACK_PROVIDER];\n if (options.providers !== undefined && options.providers.length > 0) {\n warnOnDroppedProviders(requested, providers);\n }\n const sessionOptions: ort.InferenceSession.SessionOptions = {\n ...(options.sessionOptions ?? {}),\n executionProviders:\n providers as ort.InferenceSession.SessionOptions[\"executionProviders\"],\n };\n const wantsMetadata = options.readMetadata !== false;\n const source = typeof model === \"string\" && wantsMetadata ? await fetchModel(model) : model;\n const metadata =\n wantsMetadata && typeof source !== \"string\" ? readModelMetadata(source) : {};\n\n let session: ort.InferenceSession;\n try {\n if (typeof source === \"string\") {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else if (source instanceof Uint8Array) {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else {\n session = await ortRuntime.InferenceSession.create(\n source as ArrayBuffer,\n sessionOptions,\n );\n }\n } catch (err) {\n throw new ModelLoadError(`Failed to load ONNX model: ${(err as Error).message}`, {\n cause: err,\n });\n }\n\n return new OrtSession(session, providers, metadata, requested);\n }\n\n /** Names of the model's inputs, in declaration order. */\n get inputNames(): readonly string[] {\n return this._session.inputNames;\n }\n\n /** Name of the first (and usually only) input. */\n get inputName(): string {\n const name = this._session.inputNames[0];\n if (name === undefined) {\n throw new InferenceError(\"Model has no inputs.\");\n }\n return name;\n }\n\n /** Names of the model's outputs, in declaration order. */\n get outputNames(): readonly string[] {\n return this._session.outputNames;\n }\n\n /**\n * Shapes the graph declares for its inputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Empty shapes mean the runtime\n * reported no metadata — either a non-tensor input, or an `onnxruntime-web`\n * older than 1.21, which predates input metadata.\n */\n get inputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.inputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first input, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get inputShape(): DeclaredShape {\n return this.inputShapes[0] ?? [];\n }\n\n /**\n * Shapes the graph declares for its outputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Reading them is how a task can\n * tell how many classes a head emits without being told.\n */\n get outputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.outputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first output, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get outputShape(): DeclaredShape {\n return this.outputShapes[0] ?? [];\n }\n\n /**\n * The model's custom metadata map — `names`, `task`, `imgsz`, ... for an\n * Ultralytics export.\n *\n * Read from the model's bytes at load time, since the runtime does not expose\n * it. Empty when the session was created with `readMetadata: false`, from a\n * URL that could not be fetched here, or from a model carrying no metadata.\n */\n get metadata(): Readonly<Record<string, string>> {\n return this._metadata;\n }\n\n /**\n * Release the native session and free its memory.\n *\n * Call it when a session is discarded while the page lives on — rebuilding a\n * task at a different input size, swapping in a newer model. A failure from\n * the runtime is ignored: a session being torn down has nothing left to fail\n * at, and the caller is already moving on.\n */\n async release(): Promise<void> {\n await this._session.release().catch(() => undefined);\n }\n\n /** The underlying `onnxruntime-web` session, for advanced use cases. */\n get raw(): ort.InferenceSession {\n return this._session;\n }\n\n /**\n * Run inference and return all outputs.\n *\n * @param feeds Map of input name to `ort.Tensor`. Keys must match {@link inputNames}.\n * @throws {@link InferenceError} if ORT raises any error during execution.\n */\n async run(feeds: Record<string, ort.Tensor>): Promise<Record<string, ort.Tensor>> {\n try {\n const result = await this._session.run(feeds);\n return result as Record<string, ort.Tensor>;\n } catch (err) {\n throw new InferenceError(`Inference failed: ${(err as Error).message}`, { cause: err });\n }\n }\n}\n"],"mappings":"0NA0BA,eAAe,EAAW,EAA2C,CACjE,GAAI,CACA,IAAM,EAAW,MAAM,MAAM,CAAG,EAKhC,OAJK,EAAS,GAIP,IAAI,WAAW,MAAM,EAAS,YAAY,CAAC,GAH9C,EAAwB,EAAK,QAAQ,EAAS,OAAO,GAAG,EAAS,YAAY,EACtE,EAGf,OAAS,EAAK,CAEV,OADA,EAAwB,EAAM,EAAc,OAAO,EAC5C,CACX,CACJ,CAcA,SAAS,EAAwB,EAAa,EAAsB,CAChE,QAAQ,KACJ,yCAAyC,EAAI,yBAAyB,EAAO,kMAIjF,CACJ,CA2CA,SAAS,EAAuB,EAA8B,EAAoC,CAC9F,IAAM,EAAU,EAAU,OAAQ,GAAa,CAAC,EAAU,SAAS,CAAQ,CAAC,EACxE,EAAQ,SAAW,GAGvB,QAAQ,KACJ,iEAAiE,KAAK,UAAU,CAAO,EAAE,4BAC1D,KAAK,UAAU,CAAS,EAAE,sEAE7D,CACJ,CASA,IAAa,EAAb,MAAa,CAAW,CAEC,SAkBD,UACC,UAOD,mBA3BpB,YACI,EAkBA,EACA,EAOA,EACF,CA3BmB,KAAA,SAAA,EAkBD,KAAA,UAAA,EACC,KAAA,UAAA,EAOD,KAAA,mBAAA,CACjB,CAoBH,aAAa,OAAO,EAAoB,EAA6B,CAAC,EAAwB,CAC1F,IAAM,EAAY,EAAA,iBAAiB,EAAQ,SAAS,EAC9C,EAAW,MAAM,EAAA,gBAAgB,CAAS,EAC1C,EAAY,EAAS,OAAS,EAAI,EAAW,CAAC,EAAA,iBAAiB,EACjE,EAAQ,YAAc,IAAA,IAAa,EAAQ,UAAU,OAAS,GAC9D,EAAuB,EAAW,CAAS,EAE/C,IAAM,EAAsD,CACxD,GAAI,EAAQ,gBAAkB,CAAC,EAC/B,mBACI,CACR,EACM,EAAgB,EAAQ,eAAiB,GACzC,EAAS,OAAO,GAAU,UAAY,EAAgB,MAAM,EAAW,CAAK,EAAI,EAChF,EACF,GAAiB,OAAO,GAAW,SAAW,EAAA,kBAAkB,CAAM,EAAI,CAAC,EAE3E,EACJ,GAAI,CACA,AAKI,GALA,OAAO,GAAW,UAEX,aAAkB,WADf,MAAM,EAAW,iBAAiB,OAAO,EAAQ,CAAc,EASjF,OAAS,EAAK,CACV,MAAM,IAAI,EAAA,eAAe,8BAA+B,EAAc,UAAW,CAC7E,MAAO,CACX,CAAC,CACL,CAEA,OAAO,IAAI,EAAW,EAAS,EAAW,EAAU,CAAS,CACjE,CAGA,IAAI,YAAgC,CAChC,OAAO,KAAK,SAAS,UACzB,CAGA,IAAI,WAAoB,CACpB,IAAM,EAAO,KAAK,SAAS,WAAW,GACtC,GAAI,IAAS,IAAA,GACT,MAAM,IAAI,EAAA,eAAe,sBAAsB,EAEnD,OAAO,CACX,CAGA,IAAI,aAAiC,CACjC,OAAO,KAAK,SAAS,WACzB,CASA,IAAI,aAAwC,CACxC,OAAO,EAAA,mBACH,KAAK,SAAS,aAElB,CACJ,CAOA,IAAI,YAA4B,CAC5B,OAAO,KAAK,YAAY,IAAM,CAAC,CACnC,CAQA,IAAI,cAAyC,CACzC,OAAO,EAAA,mBACH,KAAK,SAAS,cAElB,CACJ,CAOA,IAAI,aAA6B,CAC7B,OAAO,KAAK,aAAa,IAAM,CAAC,CACpC,CAUA,IAAI,UAA6C,CAC7C,OAAO,KAAK,SAChB,CAUA,MAAM,SAAyB,CAC3B,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,UAAY,IAAA,EAAS,CACvD,CAGA,IAAI,KAA4B,CAC5B,OAAO,KAAK,QAChB,CAQA,MAAM,IAAI,EAAwE,CAC9E,GAAI,CAEA,OAAO,MADc,KAAK,SAAS,IAAI,CAAK,CAEhD,OAAS,EAAK,CACV,MAAM,IAAI,EAAA,eAAe,qBAAsB,EAAc,UAAW,CAAE,MAAO,CAAI,CAAC,CAC1F,CACJ,CACJ"}
@@ -1,38 +1,45 @@
1
1
  import { InferenceError as e, ModelLoadError as t } from "./exceptions.js";
2
2
  import { declaredShapesFrom as n } from "./graph.js";
3
3
  import { readModelMetadata as r } from "./metadata.js";
4
- import { resolveProviders as i } from "./providers.js";
5
- import * as a from "onnxruntime-web";
4
+ import { FALLBACK_PROVIDER as i, detectProviders as a, resolveProviders as o } from "./providers.js";
5
+ import * as s from "onnxruntime-web";
6
6
  //#region src/vision/core/session.ts
7
- async function o(e) {
7
+ async function c(e) {
8
8
  try {
9
9
  let t = await fetch(e);
10
- return t.ok ? new Uint8Array(await t.arrayBuffer()) : (s(e, `HTTP ${t.status} ${t.statusText}`), e);
10
+ return t.ok ? new Uint8Array(await t.arrayBuffer()) : (l(e, `HTTP ${t.status} ${t.statusText}`), e);
11
11
  } catch (t) {
12
- return s(e, t.message), e;
12
+ return l(e, t.message), e;
13
13
  }
14
14
  }
15
- function s(e, t) {
15
+ function l(e, t) {
16
16
  console.warn(`[@ort-vision-sdk/web] Could not fetch ${e} to read its metadata (${t}). Letting ONNX Runtime load it instead: the model will work, but its baked-in class names are unavailable, so labels fall back to class_0, class_1, ... Pass \`labels\` explicitly to name them.`);
17
17
  }
18
- var c = class s {
18
+ function u(e, t) {
19
+ let n = e.filter((e) => !t.includes(e));
20
+ n.length !== 0 && console.warn(`This browser cannot offer the requested execution provider(s) ${JSON.stringify(n)}; the session will run on ${JSON.stringify(t)}. Inference still produces correct results, on the fallback provider.`);
21
+ }
22
+ var d = class l {
19
23
  _session;
20
24
  providers;
21
25
  _metadata;
22
- constructor(e, t, n) {
23
- this._session = e, this.providers = t, this._metadata = n;
26
+ requestedProviders;
27
+ constructor(e, t, n, r) {
28
+ this._session = e, this.providers = t, this._metadata = n, this.requestedProviders = r;
24
29
  }
25
30
  static async create(e, n = {}) {
26
- let c = i(n.providers), l = {
31
+ let d = o(n.providers), f = await a(d), p = f.length > 0 ? f : [i];
32
+ n.providers !== void 0 && n.providers.length > 0 && u(d, p);
33
+ let m = {
27
34
  ...n.sessionOptions ?? {},
28
- executionProviders: c
29
- }, u = n.readMetadata !== !1, d = typeof e == "string" && u ? await o(e) : e, f = u && typeof d != "string" ? r(d) : {}, p;
35
+ executionProviders: p
36
+ }, h = n.readMetadata !== !1, g = typeof e == "string" && h ? await c(e) : e, _ = h && typeof g != "string" ? r(g) : {}, v;
30
37
  try {
31
- p = (typeof d == "string" || d instanceof Uint8Array, await a.InferenceSession.create(d, l));
38
+ v = (typeof g == "string" || g instanceof Uint8Array, await s.InferenceSession.create(g, m));
32
39
  } catch (e) {
33
40
  throw new t(`Failed to load ONNX model: ${e.message}`, { cause: e });
34
41
  }
35
- return new s(p, c, f);
42
+ return new l(v, p, _, d);
36
43
  }
37
44
  get inputNames() {
38
45
  return this._session.inputNames;
@@ -75,6 +82,6 @@ var c = class s {
75
82
  }
76
83
  };
77
84
  //#endregion
78
- export { c as OrtSession };
85
+ export { d as OrtSession };
79
86
 
80
87
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","names":[],"sources":["../../../src/vision/core/session.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Thin wrapper around `onnxruntime-web` `InferenceSession` with typed metadata.\n */\n\nimport type * as ort from \"onnxruntime-web\";\nimport * as ortRuntime from \"onnxruntime-web\";\n\nimport { InferenceError, ModelLoadError } from \"./exceptions\";\nimport { type DeclaredShape, declaredShapesFrom } from \"./graph\";\nimport { readModelMetadata } from \"./metadata\";\nimport { resolveProviders } from \"./providers\";\n\n/** Anything `InferenceSession.create` accepts. */\nexport type ModelSource = string | ArrayBufferLike | Uint8Array;\n\n/**\n * Fetch a model URL as bytes so its metadata can be read.\n *\n * Falls back to the URL itself when the fetch fails, letting ORT try its own\n * load path: losing the metadata map is a downgrade, but failing to load a model\n * that ORT could have fetched would be a regression.\n *\n * @param url Where the `.onnx` lives.\n * @returns The model bytes, or the original URL when they could not be fetched.\n */\nasync function fetchModel(url: string): Promise<Uint8Array | string> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n warnMetadataUnavailable(url, `HTTP ${response.status} ${response.statusText}`);\n return url;\n }\n return new Uint8Array(await response.arrayBuffer());\n } catch (err) {\n warnMetadataUnavailable(url, (err as Error).message);\n return url;\n }\n}\n\n/**\n * Warn that a model's metadata could not be read, and say what that costs.\n *\n * The fallback itself is right — losing the metadata beats failing a load that\n * ORT could have completed on its own — but it used to be silent, and the\n * symptom it produces is remote from the cause: class names come back as\n * `class_0`, `class_1`, ... with nothing anywhere explaining why. Whoever hits\n * this needs to be told that passing `labels` is the way out.\n *\n * @param url The model URL that could not be fetched here.\n * @param reason What went wrong, as reported by `fetch`.\n */\nfunction warnMetadataUnavailable(url: string, reason: string): void {\n console.warn(\n `[@ort-vision-sdk/web] Could not fetch ${url} to read its metadata (${reason}). ` +\n \"Letting ONNX Runtime load it instead: the model will work, but its baked-in \" +\n \"class names are unavailable, so labels fall back to class_0, class_1, ... \" +\n \"Pass `labels` explicitly to name them.\",\n );\n}\n\nexport interface OrtSessionOptions {\n /** Execution providers in preference order. `undefined` uses {@link DEFAULT_PROVIDERS}. */\n readonly providers?: readonly string[];\n /** Optional ORT session options forwarded to `InferenceSession.create`. */\n readonly sessionOptions?: ort.InferenceSession.SessionOptions;\n /**\n * Whether to read the model's custom metadata map (`names`, `task`, `imgsz`).\n * Defaults to `true`.\n *\n * The runtime does not expose that map, so it is read from the file itself —\n * which means a URL model is fetched here and handed to ORT as bytes instead\n * of letting ORT fetch it. That is the same single download either way, and\n * it is what lets a task resolve its labels off the model. Set to `false` to\n * keep the URL path untouched and leave {@link OrtSession.metadata} empty.\n *\n * `false` is also the escape hatch when a device cannot afford the bytes: the\n * fetched buffer is dropped before ORT builds the graph (see\n * {@link OrtSession.create}), but ORT's own load path still keeps the model out\n * of reach of anything the SDK holds. A session built this way resolves its\n * input size from the graph as usual — only the class names are lost, so a\n * caller taking this route has to pass `labels` itself.\n */\n readonly readMetadata?: boolean;\n}\n\n/**\n * Wrap an ONNX Runtime Web `InferenceSession` with convenient metadata access.\n *\n * The wrapper exposes input/output names and the shapes the graph declares,\n * manages execution-provider selection, provides a typed {@link OrtSession.run}\n * method, and releases the native session through {@link OrtSession.release}.\n */\nexport class OrtSession {\n private constructor(\n private readonly _session: ort.InferenceSession,\n public readonly providers: readonly string[],\n private readonly _metadata: Readonly<Record<string, string>>,\n ) {}\n\n /**\n * Load an ONNX model into an ORT inference session.\n *\n * The metadata map is read **before** the session is built, and that order is\n * load-bearing on memory-constrained devices. ORT copies the model into its\n * WASM heap and then allocates the graph and the weights on top of that copy;\n * a `readModelMetadata` call placed after `InferenceSession.create` keeps the\n * JavaScript-side buffer reachable across the whole build, so a 5 MB model\n * costs 5 MB of JS heap plus 5 MB of WASM heap plus the weights at the same\n * instant. Reading first makes the buffer collectable as soon as ORT has copied\n * it — on a phone that was the difference between a session and\n * `Can't create a session. failed to allocate a buffer of size N`.\n *\n * @param model Either a URL string, or a `Uint8Array`/`ArrayBuffer` containing the model bytes.\n * @param options Provider list, pass-through `SessionOptions`, and whether to\n * read the model's metadata map (see {@link OrtSessionOptions.readMetadata}).\n * @throws {@link ModelLoadError} if the model cannot be loaded.\n */\n static async create(model: ModelSource, options: OrtSessionOptions = {}): Promise<OrtSession> {\n const providers = resolveProviders(options.providers);\n const sessionOptions: ort.InferenceSession.SessionOptions = {\n ...(options.sessionOptions ?? {}),\n executionProviders:\n providers as ort.InferenceSession.SessionOptions[\"executionProviders\"],\n };\n const wantsMetadata = options.readMetadata !== false;\n const source = typeof model === \"string\" && wantsMetadata ? await fetchModel(model) : model;\n const metadata =\n wantsMetadata && typeof source !== \"string\" ? readModelMetadata(source) : {};\n\n let session: ort.InferenceSession;\n try {\n if (typeof source === \"string\") {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else if (source instanceof Uint8Array) {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else {\n session = await ortRuntime.InferenceSession.create(\n source as ArrayBuffer,\n sessionOptions,\n );\n }\n } catch (err) {\n throw new ModelLoadError(`Failed to load ONNX model: ${(err as Error).message}`, {\n cause: err,\n });\n }\n\n return new OrtSession(session, providers, metadata);\n }\n\n /** Names of the model's inputs, in declaration order. */\n get inputNames(): readonly string[] {\n return this._session.inputNames;\n }\n\n /** Name of the first (and usually only) input. */\n get inputName(): string {\n const name = this._session.inputNames[0];\n if (name === undefined) {\n throw new InferenceError(\"Model has no inputs.\");\n }\n return name;\n }\n\n /** Names of the model's outputs, in declaration order. */\n get outputNames(): readonly string[] {\n return this._session.outputNames;\n }\n\n /**\n * Shapes the graph declares for its inputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Empty shapes mean the runtime\n * reported no metadata — either a non-tensor input, or an `onnxruntime-web`\n * older than 1.21, which predates input metadata.\n */\n get inputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.inputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first input, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get inputShape(): DeclaredShape {\n return this.inputShapes[0] ?? [];\n }\n\n /**\n * Shapes the graph declares for its outputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Reading them is how a task can\n * tell how many classes a head emits without being told.\n */\n get outputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.outputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first output, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get outputShape(): DeclaredShape {\n return this.outputShapes[0] ?? [];\n }\n\n /**\n * The model's custom metadata map — `names`, `task`, `imgsz`, ... for an\n * Ultralytics export.\n *\n * Read from the model's bytes at load time, since the runtime does not expose\n * it. Empty when the session was created with `readMetadata: false`, from a\n * URL that could not be fetched here, or from a model carrying no metadata.\n */\n get metadata(): Readonly<Record<string, string>> {\n return this._metadata;\n }\n\n /**\n * Release the native session and free its memory.\n *\n * Call it when a session is discarded while the page lives on — rebuilding a\n * task at a different input size, swapping in a newer model. A failure from\n * the runtime is ignored: a session being torn down has nothing left to fail\n * at, and the caller is already moving on.\n */\n async release(): Promise<void> {\n await this._session.release().catch(() => undefined);\n }\n\n /** The underlying `onnxruntime-web` session, for advanced use cases. */\n get raw(): ort.InferenceSession {\n return this._session;\n }\n\n /**\n * Run inference and return all outputs.\n *\n * @param feeds Map of input name to `ort.Tensor`. Keys must match {@link inputNames}.\n * @throws {@link InferenceError} if ORT raises any error during execution.\n */\n async run(feeds: Record<string, ort.Tensor>): Promise<Record<string, ort.Tensor>> {\n try {\n const result = await this._session.run(feeds);\n return result as Record<string, ort.Tensor>;\n } catch (err) {\n throw new InferenceError(`Inference failed: ${(err as Error).message}`, { cause: err });\n }\n }\n}\n"],"mappings":";;;;;;AA0BA,eAAe,EAAW,GAA2C;CACjE,IAAI;EACA,IAAM,IAAW,MAAM,MAAM,CAAG;EAKhC,OAJK,EAAS,KAIP,IAAI,WAAW,MAAM,EAAS,YAAY,CAAC,KAH9C,EAAwB,GAAK,QAAQ,EAAS,OAAO,GAAG,EAAS,YAAY,GACtE;CAGf,SAAS,GAAK;EAEV,OADA,EAAwB,GAAM,EAAc,OAAO,GAC5C;CACX;AACJ;AAcA,SAAS,EAAwB,GAAa,GAAsB;CAChE,QAAQ,KACJ,yCAAyC,EAAI,yBAAyB,EAAO,kMAIjF;AACJ;AAkCA,IAAa,IAAb,MAAa,EAAW;CAEC;CACD;CACC;CAHrB,YACI,GACA,GACA,GACF;EADmB,AAFA,KAAA,WAAA,GACD,KAAA,YAAA,GACC,KAAA,YAAA;CAClB;CAoBH,aAAa,OAAO,GAAoB,IAA6B,CAAC,GAAwB;EAC1F,IAAM,IAAY,EAAiB,EAAQ,SAAS,GAC9C,IAAsD;GACxD,GAAI,EAAQ,kBAAkB,CAAC;GAC/B,oBACI;EACR,GACM,IAAgB,EAAQ,iBAAiB,IACzC,IAAS,OAAO,KAAU,YAAY,IAAgB,MAAM,EAAW,CAAK,IAAI,GAChF,IACF,KAAiB,OAAO,KAAW,WAAW,EAAkB,CAAM,IAAI,CAAC,GAE3E;EACJ,IAAI;GACA,AAKI,KALA,OAAO,KAAW,YAEX,aAAkB,YADf,MAAM,EAAW,iBAAiB,OAAO,GAAQ,CAAc;EASjF,SAAS,GAAK;GACV,MAAM,IAAI,EAAe,8BAA+B,EAAc,WAAW,EAC7E,OAAO,EACX,CAAC;EACL;EAEA,OAAO,IAAI,EAAW,GAAS,GAAW,CAAQ;CACtD;CAGA,IAAI,aAAgC;EAChC,OAAO,KAAK,SAAS;CACzB;CAGA,IAAI,YAAoB;EACpB,IAAM,IAAO,KAAK,SAAS,WAAW;EACtC,IAAI,MAAS,KAAA,GACT,MAAM,IAAI,EAAe,sBAAsB;EAEnD,OAAO;CACX;CAGA,IAAI,cAAiC;EACjC,OAAO,KAAK,SAAS;CACzB;CASA,IAAI,cAAwC;EACxC,OAAO,EACH,KAAK,SAAS,aAElB;CACJ;CAOA,IAAI,aAA4B;EAC5B,OAAO,KAAK,YAAY,MAAM,CAAC;CACnC;CAQA,IAAI,eAAyC;EACzC,OAAO,EACH,KAAK,SAAS,cAElB;CACJ;CAOA,IAAI,cAA6B;EAC7B,OAAO,KAAK,aAAa,MAAM,CAAC;CACpC;CAUA,IAAI,WAA6C;EAC7C,OAAO,KAAK;CAChB;CAUA,MAAM,UAAyB;EAC3B,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS;CACvD;CAGA,IAAI,MAA4B;EAC5B,OAAO,KAAK;CAChB;CAQA,MAAM,IAAI,GAAwE;EAC9E,IAAI;GAEA,OAAO,MADc,KAAK,SAAS,IAAI,CAAK;EAEhD,SAAS,GAAK;GACV,MAAM,IAAI,EAAe,qBAAsB,EAAc,WAAW,EAAE,OAAO,EAAI,CAAC;EAC1F;CACJ;AACJ"}
1
+ {"version":3,"file":"session.js","names":[],"sources":["../../../src/vision/core/session.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Thin wrapper around `onnxruntime-web` `InferenceSession` with typed metadata.\n */\n\nimport type * as ort from \"onnxruntime-web\";\nimport * as ortRuntime from \"onnxruntime-web\";\n\nimport { InferenceError, ModelLoadError } from \"./exceptions\";\nimport { type DeclaredShape, declaredShapesFrom } from \"./graph\";\nimport { readModelMetadata } from \"./metadata\";\nimport { FALLBACK_PROVIDER, detectProviders, resolveProviders } from \"./providers\";\n\n/** Anything `InferenceSession.create` accepts. */\nexport type ModelSource = string | ArrayBufferLike | Uint8Array;\n\n/**\n * Fetch a model URL as bytes so its metadata can be read.\n *\n * Falls back to the URL itself when the fetch fails, letting ORT try its own\n * load path: losing the metadata map is a downgrade, but failing to load a model\n * that ORT could have fetched would be a regression.\n *\n * @param url Where the `.onnx` lives.\n * @returns The model bytes, or the original URL when they could not be fetched.\n */\nasync function fetchModel(url: string): Promise<Uint8Array | string> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n warnMetadataUnavailable(url, `HTTP ${response.status} ${response.statusText}`);\n return url;\n }\n return new Uint8Array(await response.arrayBuffer());\n } catch (err) {\n warnMetadataUnavailable(url, (err as Error).message);\n return url;\n }\n}\n\n/**\n * Warn that a model's metadata could not be read, and say what that costs.\n *\n * The fallback itself is right — losing the metadata beats failing a load that\n * ORT could have completed on its own — but it used to be silent, and the\n * symptom it produces is remote from the cause: class names come back as\n * `class_0`, `class_1`, ... with nothing anywhere explaining why. Whoever hits\n * this needs to be told that passing `labels` is the way out.\n *\n * @param url The model URL that could not be fetched here.\n * @param reason What went wrong, as reported by `fetch`.\n */\nfunction warnMetadataUnavailable(url: string, reason: string): void {\n console.warn(\n `[@ort-vision-sdk/web] Could not fetch ${url} to read its metadata (${reason}). ` +\n \"Letting ONNX Runtime load it instead: the model will work, but its baked-in \" +\n \"class names are unavailable, so labels fall back to class_0, class_1, ... \" +\n \"Pass `labels` explicitly to name them.\",\n );\n}\n\nexport interface OrtSessionOptions {\n /**\n * Execution providers in preference order. `undefined` uses {@link DEFAULT_PROVIDERS}.\n *\n * Naming one explicitly also opts into a `console.warn` when this browser\n * cannot offer it, instead of falling back in silence.\n */\n readonly providers?: readonly string[];\n /** Optional ORT session options forwarded to `InferenceSession.create`. */\n readonly sessionOptions?: ort.InferenceSession.SessionOptions;\n /**\n * Whether to read the model's custom metadata map (`names`, `task`, `imgsz`).\n * Defaults to `true`.\n *\n * The runtime does not expose that map, so it is read from the file itself —\n * which means a URL model is fetched here and handed to ORT as bytes instead\n * of letting ORT fetch it. That is the same single download either way, and\n * it is what lets a task resolve its labels off the model. Set to `false` to\n * keep the URL path untouched and leave {@link OrtSession.metadata} empty.\n *\n * `false` is also the escape hatch when a device cannot afford the bytes: the\n * fetched buffer is dropped before ORT builds the graph (see\n * {@link OrtSession.create}), but ORT's own load path still keeps the model out\n * of reach of anything the SDK holds. A session built this way resolves its\n * input size from the graph as usual — only the class names are lost, so a\n * caller taking this route has to pass `labels` itself.\n */\n readonly readMetadata?: boolean;\n}\n\n/**\n * Warn when a provider named explicitly by the caller is not going to run.\n *\n * Only explicit requests are worth a warning. The default list exists precisely\n * so that falling from `webgpu` to `wasm` is the expected outcome — but a caller\n * who wrote `providers: [\"webgpu\"]` and lands on WASM has a page several times\n * slower than intended and nothing in the console to explain it.\n *\n * @param requested Providers that were asked for.\n * @param effective Providers that survived capability detection.\n */\nfunction warnOnDroppedProviders(requested: readonly string[], effective: readonly string[]): void {\n const dropped = requested.filter((provider) => !effective.includes(provider));\n if (dropped.length === 0) {\n return;\n }\n console.warn(\n `This browser cannot offer the requested execution provider(s) ${JSON.stringify(dropped)}; ` +\n `the session will run on ${JSON.stringify(effective)}. Inference still produces correct ` +\n \"results, on the fallback provider.\",\n );\n}\n\n/**\n * Wrap an ONNX Runtime Web `InferenceSession` with convenient metadata access.\n *\n * The wrapper exposes input/output names and the shapes the graph declares,\n * manages execution-provider selection, provides a typed {@link OrtSession.run}\n * method, and releases the native session through {@link OrtSession.release}.\n */\nexport class OrtSession {\n private constructor(\n private readonly _session: ort.InferenceSession,\n /**\n * Execution providers this session is expected to run on.\n *\n * The requested list narrowed to what this browser can actually offer — a\n * `webgpu` entry survives only where an adapter exists. Best-effort: ORT-Web\n * exposes no way to ask which provider a session ended up on, so an entry\n * here means \"not ruled out\", not \"confirmed\". See\n * {@link requestedProviders} for what was asked for.\n *\n * When nothing survives — a caller asking for `webgpu` alone on a device\n * without it — this falls back to {@link FALLBACK_PROVIDER}, which ORT-Web\n * can always run. Handing ORT the unsatisfiable list instead makes\n * `InferenceSession.create` reject with \"no available backend found\", so the\n * page gets no inference at all rather than the slow-but-working fallback\n * the `console.warn` describes. Measured in a real Chromium, where\n * `navigator.gpu` exists but yields no adapter.\n */\n public readonly providers: readonly string[],\n private readonly _metadata: Readonly<Record<string, string>>,\n /**\n * Execution providers that were asked for, after defaults were applied.\n *\n * Kept separate because ORT-Web falls back silently: a page that asks for\n * `webgpu` on a device without it runs on WASM and is told nothing.\n */\n public readonly requestedProviders: readonly string[],\n ) {}\n\n /**\n * Load an ONNX model into an ORT inference session.\n *\n * The metadata map is read **before** the session is built, and that order is\n * load-bearing on memory-constrained devices. ORT copies the model into its\n * WASM heap and then allocates the graph and the weights on top of that copy;\n * a `readModelMetadata` call placed after `InferenceSession.create` keeps the\n * JavaScript-side buffer reachable across the whole build, so a 5 MB model\n * costs 5 MB of JS heap plus 5 MB of WASM heap plus the weights at the same\n * instant. Reading first makes the buffer collectable as soon as ORT has copied\n * it — on a phone that was the difference between a session and\n * `Can't create a session. failed to allocate a buffer of size N`.\n *\n * @param model Either a URL string, or a `Uint8Array`/`ArrayBuffer` containing the model bytes.\n * @param options Provider list, pass-through `SessionOptions`, and whether to\n * read the model's metadata map (see {@link OrtSessionOptions.readMetadata}).\n * @throws {@link ModelLoadError} if the model cannot be loaded.\n */\n static async create(model: ModelSource, options: OrtSessionOptions = {}): Promise<OrtSession> {\n const requested = resolveProviders(options.providers);\n const detected = await detectProviders(requested);\n const providers = detected.length > 0 ? detected : [FALLBACK_PROVIDER];\n if (options.providers !== undefined && options.providers.length > 0) {\n warnOnDroppedProviders(requested, providers);\n }\n const sessionOptions: ort.InferenceSession.SessionOptions = {\n ...(options.sessionOptions ?? {}),\n executionProviders:\n providers as ort.InferenceSession.SessionOptions[\"executionProviders\"],\n };\n const wantsMetadata = options.readMetadata !== false;\n const source = typeof model === \"string\" && wantsMetadata ? await fetchModel(model) : model;\n const metadata =\n wantsMetadata && typeof source !== \"string\" ? readModelMetadata(source) : {};\n\n let session: ort.InferenceSession;\n try {\n if (typeof source === \"string\") {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else if (source instanceof Uint8Array) {\n session = await ortRuntime.InferenceSession.create(source, sessionOptions);\n } else {\n session = await ortRuntime.InferenceSession.create(\n source as ArrayBuffer,\n sessionOptions,\n );\n }\n } catch (err) {\n throw new ModelLoadError(`Failed to load ONNX model: ${(err as Error).message}`, {\n cause: err,\n });\n }\n\n return new OrtSession(session, providers, metadata, requested);\n }\n\n /** Names of the model's inputs, in declaration order. */\n get inputNames(): readonly string[] {\n return this._session.inputNames;\n }\n\n /** Name of the first (and usually only) input. */\n get inputName(): string {\n const name = this._session.inputNames[0];\n if (name === undefined) {\n throw new InferenceError(\"Model has no inputs.\");\n }\n return name;\n }\n\n /** Names of the model's outputs, in declaration order. */\n get outputNames(): readonly string[] {\n return this._session.outputNames;\n }\n\n /**\n * Shapes the graph declares for its inputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Empty shapes mean the runtime\n * reported no metadata — either a non-tensor input, or an `onnxruntime-web`\n * older than 1.21, which predates input metadata.\n */\n get inputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.inputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first input, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get inputShape(): DeclaredShape {\n return this.inputShapes[0] ?? [];\n }\n\n /**\n * Shapes the graph declares for its outputs, in declaration order.\n *\n * Dynamic (symbolic) axes appear as `null`. Reading them is how a task can\n * tell how many classes a head emits without being told.\n */\n get outputShapes(): readonly DeclaredShape[] {\n return declaredShapesFrom(\n this._session.outputMetadata as\n readonly ort.InferenceSession.ValueMetadata[] | undefined,\n );\n }\n\n /**\n * Shape the graph declares for its first output, dynamic axes as `null`.\n *\n * Empty when the runtime reports no metadata for it.\n */\n get outputShape(): DeclaredShape {\n return this.outputShapes[0] ?? [];\n }\n\n /**\n * The model's custom metadata map — `names`, `task`, `imgsz`, ... for an\n * Ultralytics export.\n *\n * Read from the model's bytes at load time, since the runtime does not expose\n * it. Empty when the session was created with `readMetadata: false`, from a\n * URL that could not be fetched here, or from a model carrying no metadata.\n */\n get metadata(): Readonly<Record<string, string>> {\n return this._metadata;\n }\n\n /**\n * Release the native session and free its memory.\n *\n * Call it when a session is discarded while the page lives on — rebuilding a\n * task at a different input size, swapping in a newer model. A failure from\n * the runtime is ignored: a session being torn down has nothing left to fail\n * at, and the caller is already moving on.\n */\n async release(): Promise<void> {\n await this._session.release().catch(() => undefined);\n }\n\n /** The underlying `onnxruntime-web` session, for advanced use cases. */\n get raw(): ort.InferenceSession {\n return this._session;\n }\n\n /**\n * Run inference and return all outputs.\n *\n * @param feeds Map of input name to `ort.Tensor`. Keys must match {@link inputNames}.\n * @throws {@link InferenceError} if ORT raises any error during execution.\n */\n async run(feeds: Record<string, ort.Tensor>): Promise<Record<string, ort.Tensor>> {\n try {\n const result = await this._session.run(feeds);\n return result as Record<string, ort.Tensor>;\n } catch (err) {\n throw new InferenceError(`Inference failed: ${(err as Error).message}`, { cause: err });\n }\n }\n}\n"],"mappings":";;;;;;AA0BA,eAAe,EAAW,GAA2C;CACjE,IAAI;EACA,IAAM,IAAW,MAAM,MAAM,CAAG;EAKhC,OAJK,EAAS,KAIP,IAAI,WAAW,MAAM,EAAS,YAAY,CAAC,KAH9C,EAAwB,GAAK,QAAQ,EAAS,OAAO,GAAG,EAAS,YAAY,GACtE;CAGf,SAAS,GAAK;EAEV,OADA,EAAwB,GAAM,EAAc,OAAO,GAC5C;CACX;AACJ;AAcA,SAAS,EAAwB,GAAa,GAAsB;CAChE,QAAQ,KACJ,yCAAyC,EAAI,yBAAyB,EAAO,kMAIjF;AACJ;AA2CA,SAAS,EAAuB,GAA8B,GAAoC;CAC9F,IAAM,IAAU,EAAU,QAAQ,MAAa,CAAC,EAAU,SAAS,CAAQ,CAAC;CACxE,EAAQ,WAAW,KAGvB,QAAQ,KACJ,iEAAiE,KAAK,UAAU,CAAO,EAAE,4BAC1D,KAAK,UAAU,CAAS,EAAE,sEAE7D;AACJ;AASA,IAAa,IAAb,MAAa,EAAW;CAEC;CAkBD;CACC;CAOD;CA3BpB,YACI,GAkBA,GACA,GAOA,GACF;EADkB,AA1BC,KAAA,WAAA,GAkBD,KAAA,YAAA,GACC,KAAA,YAAA,GAOD,KAAA,qBAAA;CACjB;CAoBH,aAAa,OAAO,GAAoB,IAA6B,CAAC,GAAwB;EAC1F,IAAM,IAAY,EAAiB,EAAQ,SAAS,GAC9C,IAAW,MAAM,EAAgB,CAAS,GAC1C,IAAY,EAAS,SAAS,IAAI,IAAW,CAAC,CAAiB;EACrE,AAAI,EAAQ,cAAc,KAAA,KAAa,EAAQ,UAAU,SAAS,KAC9D,EAAuB,GAAW,CAAS;EAE/C,IAAM,IAAsD;GACxD,GAAI,EAAQ,kBAAkB,CAAC;GAC/B,oBACI;EACR,GACM,IAAgB,EAAQ,iBAAiB,IACzC,IAAS,OAAO,KAAU,YAAY,IAAgB,MAAM,EAAW,CAAK,IAAI,GAChF,IACF,KAAiB,OAAO,KAAW,WAAW,EAAkB,CAAM,IAAI,CAAC,GAE3E;EACJ,IAAI;GACA,AAKI,KALA,OAAO,KAAW,YAEX,aAAkB,YADf,MAAM,EAAW,iBAAiB,OAAO,GAAQ,CAAc;EASjF,SAAS,GAAK;GACV,MAAM,IAAI,EAAe,8BAA+B,EAAc,WAAW,EAC7E,OAAO,EACX,CAAC;EACL;EAEA,OAAO,IAAI,EAAW,GAAS,GAAW,GAAU,CAAS;CACjE;CAGA,IAAI,aAAgC;EAChC,OAAO,KAAK,SAAS;CACzB;CAGA,IAAI,YAAoB;EACpB,IAAM,IAAO,KAAK,SAAS,WAAW;EACtC,IAAI,MAAS,KAAA,GACT,MAAM,IAAI,EAAe,sBAAsB;EAEnD,OAAO;CACX;CAGA,IAAI,cAAiC;EACjC,OAAO,KAAK,SAAS;CACzB;CASA,IAAI,cAAwC;EACxC,OAAO,EACH,KAAK,SAAS,aAElB;CACJ;CAOA,IAAI,aAA4B;EAC5B,OAAO,KAAK,YAAY,MAAM,CAAC;CACnC;CAQA,IAAI,eAAyC;EACzC,OAAO,EACH,KAAK,SAAS,cAElB;CACJ;CAOA,IAAI,cAA6B;EAC7B,OAAO,KAAK,aAAa,MAAM,CAAC;CACpC;CAUA,IAAI,WAA6C;EAC7C,OAAO,KAAK;CAChB;CAUA,MAAM,UAAyB;EAC3B,MAAM,KAAK,SAAS,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS;CACvD;CAGA,IAAI,MAA4B;EAC5B,OAAO,KAAK;CAChB;CAQA,MAAM,IAAI,GAAwE;EAC9E,IAAI;GAEA,OAAO,MADc,KAAK,SAAS,IAAI,CAAK;EAEhD,SAAS,GAAK;GACV,MAAM,IAAI,EAAe,qBAAsB,EAAc,WAAW,EAAE,OAAO,EAAI,CAAC;EAC1F;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"fusion.cjs","names":[],"sources":["../../src/vision/fusion.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * The contract a fused pipeline carries inside its own `.onnx` file.\n *\n * A pipeline built by the Python SDK's `ort_vision_sdk.compose` is a single\n * graph that already contains the detector, the crop-and-resize bridge and the\n * classifier. Everything the runtime needs to drive it — the letterbox\n * resolution, the crop resolution, where the crops come from, how many\n * detections the graph emits, the class names of both stages — was decided at\n * fusion time and written into the model's metadata.\n *\n * This module reads it back. It is the browser half of a contract whose other\n * half lives in `ort_vision_sdk/fusion.py`: the same keys, the same encodings,\n * the same fallbacks. A pipeline fused once therefore runs identically in\n * Python and in a browser tab, off the same file.\n *\n * Building a pipeline stays a Python-side build step — there is no ONNX\n * protobuf writer here, and there is no reason for one: fusing is something you\n * do once next to your export pipeline, not in a page load.\n */\n\nimport { parseNames } from \"./core/metadata\";\n\n/**\n * Which tensor the bridge crops the detected boxes out of.\n *\n * - `\"detector_input\"`: the letterboxed tensor already fed to the detector.\n * The fused graph then has a **single** image input, but a small object is\n * cropped out of its downscaled copy.\n * - `\"original\"`: a second, full-resolution image input. The bridge undoes the\n * letterbox transform in-graph and crops at native resolution. Two tensors to\n * feed, still one session and one model load.\n */\nexport type CropSource = \"detector_input\" | \"original\";\n\n/** Value of the `ovs.kind` metadata key for a detector→classifier pipeline. */\nexport const FUSION_KIND_DETECT_CLASSIFY = \"detect_classify\";\n\n/**\n * Namespace for every metadata key the fusion writes.\n *\n * Namespaced on purpose: the detector's own Ultralytics metadata (`names`,\n * `task`, `imgsz`) is carried over into the fused model, and an un-prefixed key\n * would either collide with it or be mistaken for it.\n */\nexport const METADATA_PREFIX = \"ovs.\";\n\n/** Name of the fused graph's letterboxed detector input, `[1, 3, H, W]` float32 in `[0, 1]`. */\nexport const INPUT_IMAGE = \"images\";\n\n/** Name of the full-resolution input. Present only when `cropSource === \"original\"`. */\nexport const INPUT_SOURCE = \"source_image\";\n\n/** Name of the `[1]` float32 letterbox scale factor. Only with `cropSource === \"original\"`. */\nexport const INPUT_SCALE = \"letterbox_scale\";\n\n/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === \"original\"`. */\nexport const INPUT_PAD = \"letterbox_pad\";\n\n/** Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels. */\nexport const OUTPUT_BOXES = \"boxes\";\n\n/** Name of the `[K]` float32 detection-confidence output. */\nexport const OUTPUT_SCORES = \"scores\";\n\n/** Name of the `[K]` int64 detector-class output. */\nexport const OUTPUT_CLASSES = \"classes\";\n\n/** Name of the `[1]` int64 output holding how many of the `K` rows are real. */\nexport const OUTPUT_NUM_DETECTIONS = \"num_detections\";\n\n/** Name of the `[K, numClassifierClasses]` float32 classifier output, one row per box. */\nexport const OUTPUT_PROBS = \"probs\";\n\n/** Everything a fused pipeline declares about how it must be driven. */\nexport interface FusionSpec {\n /** Pipeline family. Only `\"detect_classify\"` exists today. */\n readonly kind: string;\n /** `[width, height]` the detector stage expects — the resolution to letterbox to. */\n readonly inputSize: readonly [number, number];\n /** `[width, height]` every crop is resampled to inside the graph. */\n readonly cropSize: readonly [number, number];\n /** Which tensor the crops are taken from. */\n readonly cropSource: CropSource;\n /**\n * Fixed number of rows `K` every output carries, surplus zero-padded and\n * counted by {@link OUTPUT_NUM_DETECTIONS}. `null` means the graph emits\n * exactly as many rows as survived NMS.\n */\n readonly maxDetections: number | null;\n /** Score threshold baked into the graph's NMS node. */\n readonly confThreshold: number;\n /** IoU threshold baked into the graph's NMS node. */\n readonly iouThreshold: number;\n /** Whether the classifier stage emits logits that still need a softmax. */\n readonly applySoftmax: boolean;\n /** Detector class names in class-id order, or `null` when the fusion recorded none. */\n readonly detectorNames: readonly string[] | null;\n /** Classifier class names in class-id order, or `null`. */\n readonly classifierNames: readonly string[] | null;\n /** Version of `ort-vision-sdk` that produced the file. */\n readonly sdkVersion: string;\n /** Whether driving this pipeline requires feeding the full-resolution input. */\n readonly needsSourceImage: boolean;\n}\n\nconst KEY_KIND = \"kind\";\nconst KEY_SDK_VERSION = \"sdk_version\";\nconst KEY_INPUT_SIZE = \"input_size\";\nconst KEY_CROP_SIZE = \"crop_size\";\nconst KEY_CROP_SOURCE = \"crop_source\";\nconst KEY_MAX_DETECTIONS = \"max_detections\";\nconst KEY_CONF_THRESHOLD = \"conf_threshold\";\nconst KEY_IOU_THRESHOLD = \"iou_threshold\";\nconst KEY_APPLY_SOFTMAX = \"apply_softmax\";\nconst KEY_DETECTOR_NAMES = \"detector_names\";\nconst KEY_CLASSIFIER_NAMES = \"classifier_names\";\n\nconst DYNAMIC = \"dynamic\";\n\n/**\n * Decode a `\"640,640\"` pair.\n *\n * @param raw The encoded pair.\n * @returns `[width, height]`, or `null` when the value is missing or malformed.\n */\nfunction decodeSize(raw: string | undefined): readonly [number, number] | null {\n if (!raw) return null;\n const parts = raw.split(\",\");\n if (parts.length !== 2) return null;\n const width = Number(parts[0]);\n const height = Number(parts[1]);\n if (!Number.isInteger(width) || !Number.isInteger(height)) return null;\n if (width < 1 || height < 1) return null;\n return [width, height];\n}\n\n/**\n * Decode a float, falling back when the value is missing or malformed.\n *\n * @param raw The encoded value.\n * @param fallback Value to use when `raw` cannot be read.\n * @returns The parsed number, or `fallback`.\n */\nfunction decodeFloat(raw: string | undefined, fallback: number): number {\n if (!raw) return fallback;\n const value = Number(raw);\n return Number.isFinite(value) ? value : fallback;\n}\n\n/**\n * Read a pipeline spec out of a model's custom metadata.\n *\n * Individual malformed entries fall back to the value a fusion would have used\n * by default — a single bad float is not a reason to reject an otherwise\n * loadable pipeline. A malformed resolution is fatal, because there is no safe\n * default for one.\n *\n * @param metadata A model's custom metadata map, as read by\n * {@link readModelMetadata}.\n * @returns The decoded spec, or `null` when the model is not a fused pipeline —\n * it carries no `ovs.kind` entry, or one naming a pipeline kind this version\n * does not know how to drive.\n */\nexport function readFusionSpec(\n metadata: Readonly<Record<string, string>> | undefined,\n): FusionSpec | null {\n if (!metadata) return null;\n\n const read: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata)) {\n if (key.startsWith(METADATA_PREFIX)) read[key.slice(METADATA_PREFIX.length)] = value;\n }\n if (read[KEY_KIND] !== FUSION_KIND_DETECT_CLASSIFY) return null;\n\n const inputSize = decodeSize(read[KEY_INPUT_SIZE]);\n const cropSize = decodeSize(read[KEY_CROP_SIZE]);\n if (inputSize === null || cropSize === null) return null;\n\n const rawMax = read[KEY_MAX_DETECTIONS] ?? DYNAMIC;\n const parsedMax = Number(rawMax);\n const maxDetections =\n rawMax === DYNAMIC || !Number.isInteger(parsedMax) || parsedMax < 1 ? null : parsedMax;\n\n const cropSource: CropSource =\n read[KEY_CROP_SOURCE] === \"original\" ? \"original\" : \"detector_input\";\n\n return {\n kind: FUSION_KIND_DETECT_CLASSIFY,\n inputSize,\n cropSize,\n cropSource,\n maxDetections,\n confThreshold: decodeFloat(read[KEY_CONF_THRESHOLD], 0.25),\n iouThreshold: decodeFloat(read[KEY_IOU_THRESHOLD], 0.45),\n applySoftmax: (read[KEY_APPLY_SOFTMAX] ?? \"1\") !== \"0\",\n detectorNames: parseNames(read[KEY_DETECTOR_NAMES]),\n classifierNames: parseNames(read[KEY_CLASSIFIER_NAMES]),\n sdkVersion: read[KEY_SDK_VERSION] ?? \"\",\n needsSourceImage: cropSource === \"original\",\n };\n}\n"],"mappings":"uCAoCA,IAAa,EAA8B,kBAS9B,EAAkB,OAGlB,EAAc,SAGd,EAAe,eAGf,EAAc,kBAGd,EAAY,gBAGZ,EAAe,QAGf,EAAgB,SAGhB,EAAiB,UAGjB,EAAwB,iBAGxB,EAAe,QAkCtB,EAAW,OACX,EAAkB,cAClB,EAAiB,aACjB,EAAgB,YAChB,EAAkB,cAClB,EAAqB,iBACrB,EAAqB,iBACrB,EAAoB,gBACpB,EAAoB,gBACpB,EAAqB,iBACrB,EAAuB,mBAEvB,EAAU,UAQhB,SAAS,EAAW,EAA2D,CAC3E,GAAI,CAAC,EAAK,OAAO,KACjB,IAAM,EAAQ,EAAI,MAAM,GAAG,EAC3B,GAAI,EAAM,SAAW,EAAG,OAAO,KAC/B,IAAM,EAAQ,OAAO,EAAM,EAAE,EACvB,EAAS,OAAO,EAAM,EAAE,EAG9B,MAFI,CAAC,OAAO,UAAU,CAAK,GAAK,CAAC,OAAO,UAAU,CAAM,GACpD,EAAQ,GAAK,EAAS,EAAU,KAC7B,CAAC,EAAO,CAAM,CACzB,CASA,SAAS,EAAY,EAAyB,EAA0B,CACpE,GAAI,CAAC,EAAK,OAAO,EACjB,IAAM,EAAQ,OAAO,CAAG,EACxB,OAAO,OAAO,SAAS,CAAK,EAAI,EAAQ,CAC5C,CAgBA,SAAgB,EACZ,EACiB,CACjB,GAAI,CAAC,EAAU,OAAO,KAEtB,IAAM,EAA+B,CAAC,EACtC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAQ,EAC1C,EAAI,WAAA,MAA0B,IAAG,EAAK,EAAI,MAAM,CAAsB,GAAK,GAEnF,GAAI,EAAK,KAAA,kBAA2C,OAAO,KAE3D,IAAM,EAAY,EAAW,EAAK,EAAe,EAC3C,EAAW,EAAW,EAAK,EAAc,EAC/C,GAAI,IAAc,MAAQ,IAAa,KAAM,OAAO,KAEpD,IAAM,EAAS,EAAK,IAAuB,EACrC,EAAY,OAAO,CAAM,EACzB,EACF,IAAW,GAAW,CAAC,OAAO,UAAU,CAAS,GAAK,EAAY,EAAI,KAAO,EAE3E,EACF,EAAK,KAAqB,WAAa,WAAa,iBAExD,MAAO,CACH,KAAM,EACN,YACA,WACA,aACA,gBACA,cAAe,EAAY,EAAK,GAAqB,GAAI,EACzD,aAAc,EAAY,EAAK,GAAoB,GAAI,EACvD,cAAe,EAAK,IAAsB,OAAS,IACnD,cAAe,EAAA,WAAW,EAAK,EAAmB,EAClD,gBAAiB,EAAA,WAAW,EAAK,EAAqB,EACtD,WAAY,EAAK,IAAoB,GACrC,iBAAkB,IAAe,UACrC,CACJ"}
1
+ {"version":3,"file":"fusion.cjs","names":[],"sources":["../../src/vision/fusion.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * The contract a fused pipeline carries inside its own `.onnx` file.\n *\n * A pipeline built by the Python SDK's `ort_vision_sdk.compose` is a single\n * graph that already contains the detector, the crop-and-resize bridge and the\n * classifier. Everything the runtime needs to drive it — the letterbox\n * resolution, the crop resolution, where the crops come from, how many\n * detections the graph emits, the class names of both stages — was decided at\n * fusion time and written into the model's metadata.\n *\n * This module reads it back. It is the browser half of a contract whose other\n * half lives in `ort_vision_sdk/fusion.py`: the same keys, the same encodings,\n * the same fallbacks. A pipeline fused once therefore runs identically in\n * Python and in a browser tab, off the same file.\n *\n * Building a pipeline stays a Python-side build step — there is no ONNX\n * protobuf writer here, and there is no reason for one: fusing is something you\n * do once next to your export pipeline, not in a page load.\n */\n\nimport { parseNames } from \"./core/metadata\";\n\n/**\n * Which tensor the bridge crops the detected boxes out of.\n *\n * - `\"detector_input\"`: the letterboxed tensor already fed to the detector.\n * The fused graph then has a **single** image input, but a small object is\n * cropped out of its downscaled copy.\n * - `\"original\"`: a second, full-resolution image input. The bridge undoes the\n * letterbox transform in-graph and crops at native resolution. Two tensors to\n * feed, still one session and one model load.\n */\nexport type CropSource = \"detector_input\" | \"original\";\n\n/** Value of the `ovs.kind` metadata key for a detector→classifier pipeline. */\nexport const FUSION_KIND_DETECT_CLASSIFY = \"detect_classify\";\n\n/**\n * Namespace for every metadata key the fusion writes.\n *\n * Namespaced on purpose: the detector's own Ultralytics metadata (`names`,\n * `task`, `imgsz`) is carried over into the fused model, and an un-prefixed key\n * would either collide with it or be mistaken for it.\n */\nexport const METADATA_PREFIX = \"ovs.\";\n\n/** Name of the fused graph's letterboxed detector input, `[1, 3, H, W]` float32 in `[0, 1]`. */\nexport const INPUT_IMAGE = \"images\";\n\n/** Name of the full-resolution input. Present only when `cropSource === \"original\"`. */\nexport const INPUT_SOURCE = \"source_image\";\n\n/** Name of the `[1]` float32 letterbox scale factor. Only with `cropSource === \"original\"`. */\nexport const INPUT_SCALE = \"letterbox_scale\";\n\n/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === \"original\"`. */\nexport const INPUT_PAD = \"letterbox_pad\";\n\n/**\n * Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels.\n *\n * A file fused by `ort-vision-sdk` 0.9.0 or later reports the box that was\n * actually classified: clamped to the image the crop came from, exactly as\n * RoiAlign received it. Older files report the raw box, so one that ran off the\n * frame draws a rectangle wider than the region the classifier saw.\n */\nexport const OUTPUT_BOXES = \"boxes\";\n\n/** Name of the `[K]` float32 detection-confidence output. */\nexport const OUTPUT_SCORES = \"scores\";\n\n/** Name of the `[K]` int64 detector-class output. */\nexport const OUTPUT_CLASSES = \"classes\";\n\n/** Name of the `[1]` int64 output holding how many of the `K` rows are real. */\nexport const OUTPUT_NUM_DETECTIONS = \"num_detections\";\n\n/** Name of the `[K, numClassifierClasses]` float32 classifier output, one row per box. */\nexport const OUTPUT_PROBS = \"probs\";\n\n/** Everything a fused pipeline declares about how it must be driven. */\nexport interface FusionSpec {\n /** Pipeline family. Only `\"detect_classify\"` exists today. */\n readonly kind: string;\n /** `[width, height]` the detector stage expects — the resolution to letterbox to. */\n readonly inputSize: readonly [number, number];\n /** `[width, height]` every crop is resampled to inside the graph. */\n readonly cropSize: readonly [number, number];\n /** Which tensor the crops are taken from. */\n readonly cropSource: CropSource;\n /**\n * Fixed number of rows `K` every output carries, surplus zero-padded and\n * counted by {@link OUTPUT_NUM_DETECTIONS}. `null` means the graph emits\n * exactly as many rows as survived NMS.\n */\n readonly maxDetections: number | null;\n /** Score threshold baked into the graph's NMS node. */\n readonly confThreshold: number;\n /** IoU threshold baked into the graph's NMS node. */\n readonly iouThreshold: number;\n /** Whether the classifier stage emits logits that still need a softmax. */\n readonly applySoftmax: boolean;\n /** Detector class names in class-id order, or `null` when the fusion recorded none. */\n readonly detectorNames: readonly string[] | null;\n /** Classifier class names in class-id order, or `null`. */\n readonly classifierNames: readonly string[] | null;\n /** Version of `ort-vision-sdk` that produced the file. */\n readonly sdkVersion: string;\n /** Whether driving this pipeline requires feeding the full-resolution input. */\n readonly needsSourceImage: boolean;\n}\n\nconst KEY_KIND = \"kind\";\nconst KEY_SDK_VERSION = \"sdk_version\";\nconst KEY_INPUT_SIZE = \"input_size\";\nconst KEY_CROP_SIZE = \"crop_size\";\nconst KEY_CROP_SOURCE = \"crop_source\";\nconst KEY_MAX_DETECTIONS = \"max_detections\";\nconst KEY_CONF_THRESHOLD = \"conf_threshold\";\nconst KEY_IOU_THRESHOLD = \"iou_threshold\";\nconst KEY_APPLY_SOFTMAX = \"apply_softmax\";\nconst KEY_DETECTOR_NAMES = \"detector_names\";\nconst KEY_CLASSIFIER_NAMES = \"classifier_names\";\n\nconst DYNAMIC = \"dynamic\";\n\n/**\n * Decode a `\"640,640\"` pair.\n *\n * @param raw The encoded pair.\n * @returns `[width, height]`, or `null` when the value is missing or malformed.\n */\nfunction decodeSize(raw: string | undefined): readonly [number, number] | null {\n if (!raw) return null;\n const parts = raw.split(\",\");\n if (parts.length !== 2) return null;\n const width = Number(parts[0]);\n const height = Number(parts[1]);\n if (!Number.isInteger(width) || !Number.isInteger(height)) return null;\n if (width < 1 || height < 1) return null;\n return [width, height];\n}\n\n/**\n * Decode a float, falling back when the value is missing or malformed.\n *\n * @param raw The encoded value.\n * @param fallback Value to use when `raw` cannot be read.\n * @returns The parsed number, or `fallback`.\n */\nfunction decodeFloat(raw: string | undefined, fallback: number): number {\n if (!raw) return fallback;\n const value = Number(raw);\n return Number.isFinite(value) ? value : fallback;\n}\n\n/**\n * Read a pipeline spec out of a model's custom metadata.\n *\n * Individual malformed entries fall back to the value a fusion would have used\n * by default — a single bad float is not a reason to reject an otherwise\n * loadable pipeline. A malformed resolution is fatal, because there is no safe\n * default for one.\n *\n * @param metadata A model's custom metadata map, as read by\n * {@link readModelMetadata}.\n * @returns The decoded spec, or `null` when the model is not a fused pipeline —\n * it carries no `ovs.kind` entry, or one naming a pipeline kind this version\n * does not know how to drive.\n */\nexport function readFusionSpec(\n metadata: Readonly<Record<string, string>> | undefined,\n): FusionSpec | null {\n if (!metadata) return null;\n\n const read: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata)) {\n if (key.startsWith(METADATA_PREFIX)) read[key.slice(METADATA_PREFIX.length)] = value;\n }\n if (read[KEY_KIND] !== FUSION_KIND_DETECT_CLASSIFY) return null;\n\n const inputSize = decodeSize(read[KEY_INPUT_SIZE]);\n const cropSize = decodeSize(read[KEY_CROP_SIZE]);\n if (inputSize === null || cropSize === null) return null;\n\n const rawMax = read[KEY_MAX_DETECTIONS] ?? DYNAMIC;\n const parsedMax = Number(rawMax);\n const maxDetections =\n rawMax === DYNAMIC || !Number.isInteger(parsedMax) || parsedMax < 1 ? null : parsedMax;\n\n const cropSource: CropSource =\n read[KEY_CROP_SOURCE] === \"original\" ? \"original\" : \"detector_input\";\n\n return {\n kind: FUSION_KIND_DETECT_CLASSIFY,\n inputSize,\n cropSize,\n cropSource,\n maxDetections,\n confThreshold: decodeFloat(read[KEY_CONF_THRESHOLD], 0.25),\n iouThreshold: decodeFloat(read[KEY_IOU_THRESHOLD], 0.45),\n applySoftmax: (read[KEY_APPLY_SOFTMAX] ?? \"1\") !== \"0\",\n detectorNames: parseNames(read[KEY_DETECTOR_NAMES]),\n classifierNames: parseNames(read[KEY_CLASSIFIER_NAMES]),\n sdkVersion: read[KEY_SDK_VERSION] ?? \"\",\n needsSourceImage: cropSource === \"original\",\n };\n}\n"],"mappings":"uCAoCA,IAAa,EAA8B,kBAS9B,EAAkB,OAGlB,EAAc,SAGd,EAAe,eAGf,EAAc,kBAGd,EAAY,gBAUZ,EAAe,QAGf,EAAgB,SAGhB,EAAiB,UAGjB,EAAwB,iBAGxB,EAAe,QAkCtB,EAAW,OACX,EAAkB,cAClB,EAAiB,aACjB,EAAgB,YAChB,EAAkB,cAClB,EAAqB,iBACrB,EAAqB,iBACrB,EAAoB,gBACpB,EAAoB,gBACpB,EAAqB,iBACrB,EAAuB,mBAEvB,EAAU,UAQhB,SAAS,EAAW,EAA2D,CAC3E,GAAI,CAAC,EAAK,OAAO,KACjB,IAAM,EAAQ,EAAI,MAAM,GAAG,EAC3B,GAAI,EAAM,SAAW,EAAG,OAAO,KAC/B,IAAM,EAAQ,OAAO,EAAM,EAAE,EACvB,EAAS,OAAO,EAAM,EAAE,EAG9B,MAFI,CAAC,OAAO,UAAU,CAAK,GAAK,CAAC,OAAO,UAAU,CAAM,GACpD,EAAQ,GAAK,EAAS,EAAU,KAC7B,CAAC,EAAO,CAAM,CACzB,CASA,SAAS,EAAY,EAAyB,EAA0B,CACpE,GAAI,CAAC,EAAK,OAAO,EACjB,IAAM,EAAQ,OAAO,CAAG,EACxB,OAAO,OAAO,SAAS,CAAK,EAAI,EAAQ,CAC5C,CAgBA,SAAgB,EACZ,EACiB,CACjB,GAAI,CAAC,EAAU,OAAO,KAEtB,IAAM,EAA+B,CAAC,EACtC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAQ,EAC1C,EAAI,WAAA,MAA0B,IAAG,EAAK,EAAI,MAAM,CAAsB,GAAK,GAEnF,GAAI,EAAK,KAAA,kBAA2C,OAAO,KAE3D,IAAM,EAAY,EAAW,EAAK,EAAe,EAC3C,EAAW,EAAW,EAAK,EAAc,EAC/C,GAAI,IAAc,MAAQ,IAAa,KAAM,OAAO,KAEpD,IAAM,EAAS,EAAK,IAAuB,EACrC,EAAY,OAAO,CAAM,EACzB,EACF,IAAW,GAAW,CAAC,OAAO,UAAU,CAAS,GAAK,EAAY,EAAI,KAAO,EAE3E,EACF,EAAK,KAAqB,WAAa,WAAa,iBAExD,MAAO,CACH,KAAM,EACN,YACA,WACA,aACA,gBACA,cAAe,EAAY,EAAK,GAAqB,GAAI,EACzD,aAAc,EAAY,EAAK,GAAoB,GAAI,EACvD,cAAe,EAAK,IAAsB,OAAS,IACnD,cAAe,EAAA,WAAW,EAAK,EAAmB,EAClD,gBAAiB,EAAA,WAAW,EAAK,EAAqB,EACtD,WAAY,EAAK,IAAoB,GACrC,iBAAkB,IAAe,UACrC,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"fusion.js","names":[],"sources":["../../src/vision/fusion.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * The contract a fused pipeline carries inside its own `.onnx` file.\n *\n * A pipeline built by the Python SDK's `ort_vision_sdk.compose` is a single\n * graph that already contains the detector, the crop-and-resize bridge and the\n * classifier. Everything the runtime needs to drive it — the letterbox\n * resolution, the crop resolution, where the crops come from, how many\n * detections the graph emits, the class names of both stages — was decided at\n * fusion time and written into the model's metadata.\n *\n * This module reads it back. It is the browser half of a contract whose other\n * half lives in `ort_vision_sdk/fusion.py`: the same keys, the same encodings,\n * the same fallbacks. A pipeline fused once therefore runs identically in\n * Python and in a browser tab, off the same file.\n *\n * Building a pipeline stays a Python-side build step — there is no ONNX\n * protobuf writer here, and there is no reason for one: fusing is something you\n * do once next to your export pipeline, not in a page load.\n */\n\nimport { parseNames } from \"./core/metadata\";\n\n/**\n * Which tensor the bridge crops the detected boxes out of.\n *\n * - `\"detector_input\"`: the letterboxed tensor already fed to the detector.\n * The fused graph then has a **single** image input, but a small object is\n * cropped out of its downscaled copy.\n * - `\"original\"`: a second, full-resolution image input. The bridge undoes the\n * letterbox transform in-graph and crops at native resolution. Two tensors to\n * feed, still one session and one model load.\n */\nexport type CropSource = \"detector_input\" | \"original\";\n\n/** Value of the `ovs.kind` metadata key for a detector→classifier pipeline. */\nexport const FUSION_KIND_DETECT_CLASSIFY = \"detect_classify\";\n\n/**\n * Namespace for every metadata key the fusion writes.\n *\n * Namespaced on purpose: the detector's own Ultralytics metadata (`names`,\n * `task`, `imgsz`) is carried over into the fused model, and an un-prefixed key\n * would either collide with it or be mistaken for it.\n */\nexport const METADATA_PREFIX = \"ovs.\";\n\n/** Name of the fused graph's letterboxed detector input, `[1, 3, H, W]` float32 in `[0, 1]`. */\nexport const INPUT_IMAGE = \"images\";\n\n/** Name of the full-resolution input. Present only when `cropSource === \"original\"`. */\nexport const INPUT_SOURCE = \"source_image\";\n\n/** Name of the `[1]` float32 letterbox scale factor. Only with `cropSource === \"original\"`. */\nexport const INPUT_SCALE = \"letterbox_scale\";\n\n/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === \"original\"`. */\nexport const INPUT_PAD = \"letterbox_pad\";\n\n/** Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels. */\nexport const OUTPUT_BOXES = \"boxes\";\n\n/** Name of the `[K]` float32 detection-confidence output. */\nexport const OUTPUT_SCORES = \"scores\";\n\n/** Name of the `[K]` int64 detector-class output. */\nexport const OUTPUT_CLASSES = \"classes\";\n\n/** Name of the `[1]` int64 output holding how many of the `K` rows are real. */\nexport const OUTPUT_NUM_DETECTIONS = \"num_detections\";\n\n/** Name of the `[K, numClassifierClasses]` float32 classifier output, one row per box. */\nexport const OUTPUT_PROBS = \"probs\";\n\n/** Everything a fused pipeline declares about how it must be driven. */\nexport interface FusionSpec {\n /** Pipeline family. Only `\"detect_classify\"` exists today. */\n readonly kind: string;\n /** `[width, height]` the detector stage expects — the resolution to letterbox to. */\n readonly inputSize: readonly [number, number];\n /** `[width, height]` every crop is resampled to inside the graph. */\n readonly cropSize: readonly [number, number];\n /** Which tensor the crops are taken from. */\n readonly cropSource: CropSource;\n /**\n * Fixed number of rows `K` every output carries, surplus zero-padded and\n * counted by {@link OUTPUT_NUM_DETECTIONS}. `null` means the graph emits\n * exactly as many rows as survived NMS.\n */\n readonly maxDetections: number | null;\n /** Score threshold baked into the graph's NMS node. */\n readonly confThreshold: number;\n /** IoU threshold baked into the graph's NMS node. */\n readonly iouThreshold: number;\n /** Whether the classifier stage emits logits that still need a softmax. */\n readonly applySoftmax: boolean;\n /** Detector class names in class-id order, or `null` when the fusion recorded none. */\n readonly detectorNames: readonly string[] | null;\n /** Classifier class names in class-id order, or `null`. */\n readonly classifierNames: readonly string[] | null;\n /** Version of `ort-vision-sdk` that produced the file. */\n readonly sdkVersion: string;\n /** Whether driving this pipeline requires feeding the full-resolution input. */\n readonly needsSourceImage: boolean;\n}\n\nconst KEY_KIND = \"kind\";\nconst KEY_SDK_VERSION = \"sdk_version\";\nconst KEY_INPUT_SIZE = \"input_size\";\nconst KEY_CROP_SIZE = \"crop_size\";\nconst KEY_CROP_SOURCE = \"crop_source\";\nconst KEY_MAX_DETECTIONS = \"max_detections\";\nconst KEY_CONF_THRESHOLD = \"conf_threshold\";\nconst KEY_IOU_THRESHOLD = \"iou_threshold\";\nconst KEY_APPLY_SOFTMAX = \"apply_softmax\";\nconst KEY_DETECTOR_NAMES = \"detector_names\";\nconst KEY_CLASSIFIER_NAMES = \"classifier_names\";\n\nconst DYNAMIC = \"dynamic\";\n\n/**\n * Decode a `\"640,640\"` pair.\n *\n * @param raw The encoded pair.\n * @returns `[width, height]`, or `null` when the value is missing or malformed.\n */\nfunction decodeSize(raw: string | undefined): readonly [number, number] | null {\n if (!raw) return null;\n const parts = raw.split(\",\");\n if (parts.length !== 2) return null;\n const width = Number(parts[0]);\n const height = Number(parts[1]);\n if (!Number.isInteger(width) || !Number.isInteger(height)) return null;\n if (width < 1 || height < 1) return null;\n return [width, height];\n}\n\n/**\n * Decode a float, falling back when the value is missing or malformed.\n *\n * @param raw The encoded value.\n * @param fallback Value to use when `raw` cannot be read.\n * @returns The parsed number, or `fallback`.\n */\nfunction decodeFloat(raw: string | undefined, fallback: number): number {\n if (!raw) return fallback;\n const value = Number(raw);\n return Number.isFinite(value) ? value : fallback;\n}\n\n/**\n * Read a pipeline spec out of a model's custom metadata.\n *\n * Individual malformed entries fall back to the value a fusion would have used\n * by default — a single bad float is not a reason to reject an otherwise\n * loadable pipeline. A malformed resolution is fatal, because there is no safe\n * default for one.\n *\n * @param metadata A model's custom metadata map, as read by\n * {@link readModelMetadata}.\n * @returns The decoded spec, or `null` when the model is not a fused pipeline —\n * it carries no `ovs.kind` entry, or one naming a pipeline kind this version\n * does not know how to drive.\n */\nexport function readFusionSpec(\n metadata: Readonly<Record<string, string>> | undefined,\n): FusionSpec | null {\n if (!metadata) return null;\n\n const read: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata)) {\n if (key.startsWith(METADATA_PREFIX)) read[key.slice(METADATA_PREFIX.length)] = value;\n }\n if (read[KEY_KIND] !== FUSION_KIND_DETECT_CLASSIFY) return null;\n\n const inputSize = decodeSize(read[KEY_INPUT_SIZE]);\n const cropSize = decodeSize(read[KEY_CROP_SIZE]);\n if (inputSize === null || cropSize === null) return null;\n\n const rawMax = read[KEY_MAX_DETECTIONS] ?? DYNAMIC;\n const parsedMax = Number(rawMax);\n const maxDetections =\n rawMax === DYNAMIC || !Number.isInteger(parsedMax) || parsedMax < 1 ? null : parsedMax;\n\n const cropSource: CropSource =\n read[KEY_CROP_SOURCE] === \"original\" ? \"original\" : \"detector_input\";\n\n return {\n kind: FUSION_KIND_DETECT_CLASSIFY,\n inputSize,\n cropSize,\n cropSource,\n maxDetections,\n confThreshold: decodeFloat(read[KEY_CONF_THRESHOLD], 0.25),\n iouThreshold: decodeFloat(read[KEY_IOU_THRESHOLD], 0.45),\n applySoftmax: (read[KEY_APPLY_SOFTMAX] ?? \"1\") !== \"0\",\n detectorNames: parseNames(read[KEY_DETECTOR_NAMES]),\n classifierNames: parseNames(read[KEY_CLASSIFIER_NAMES]),\n sdkVersion: read[KEY_SDK_VERSION] ?? \"\",\n needsSourceImage: cropSource === \"original\",\n };\n}\n"],"mappings":";;AAoCA,IAAa,IAA8B,mBAS9B,IAAkB,QAGlB,IAAc,UAGd,IAAe,gBAGf,IAAc,mBAGd,IAAY,iBAGZ,IAAe,SAGf,IAAgB,UAGhB,IAAiB,WAGjB,IAAwB,kBAGxB,IAAe,SAkCtB,IAAW,QACX,IAAkB,eAClB,IAAiB,cACjB,IAAgB,aAChB,IAAkB,eAClB,IAAqB,kBACrB,IAAqB,kBACrB,IAAoB,iBACpB,IAAoB,iBACpB,IAAqB,kBACrB,IAAuB,oBAEvB,IAAU;AAQhB,SAAS,EAAW,GAA2D;CAC3E,IAAI,CAAC,GAAK,OAAO;CACjB,IAAM,IAAQ,EAAI,MAAM,GAAG;CAC3B,IAAI,EAAM,WAAW,GAAG,OAAO;CAC/B,IAAM,IAAQ,OAAO,EAAM,EAAE,GACvB,IAAS,OAAO,EAAM,EAAE;CAG9B,OAFI,CAAC,OAAO,UAAU,CAAK,KAAK,CAAC,OAAO,UAAU,CAAM,KACpD,IAAQ,KAAK,IAAS,IAAU,OAC7B,CAAC,GAAO,CAAM;AACzB;AASA,SAAS,EAAY,GAAyB,GAA0B;CACpE,IAAI,CAAC,GAAK,OAAO;CACjB,IAAM,IAAQ,OAAO,CAAG;CACxB,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;AAC5C;AAgBA,SAAgB,EACZ,GACiB;CACjB,IAAI,CAAC,GAAU,OAAO;CAEtB,IAAM,IAA+B,CAAC;CACtC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAQ,GAC9C,AAAI,EAAI,WAAA,MAA0B,MAAG,EAAK,EAAI,MAAM,CAAsB,KAAK;CAEnF,IAAI,EAAK,OAAA,mBAA2C,OAAO;CAE3D,IAAM,IAAY,EAAW,EAAK,EAAe,GAC3C,IAAW,EAAW,EAAK,EAAc;CAC/C,IAAI,MAAc,QAAQ,MAAa,MAAM,OAAO;CAEpD,IAAM,IAAS,EAAK,MAAuB,GACrC,IAAY,OAAO,CAAM,GACzB,IACF,MAAW,KAAW,CAAC,OAAO,UAAU,CAAS,KAAK,IAAY,IAAI,OAAO,GAE3E,IACF,EAAK,OAAqB,aAAa,aAAa;CAExD,OAAO;EACH,MAAM;EACN;EACA;EACA;EACA;EACA,eAAe,EAAY,EAAK,IAAqB,GAAI;EACzD,cAAc,EAAY,EAAK,IAAoB,GAAI;EACvD,eAAe,EAAK,MAAsB,SAAS;EACnD,eAAe,EAAW,EAAK,EAAmB;EAClD,iBAAiB,EAAW,EAAK,EAAqB;EACtD,YAAY,EAAK,MAAoB;EACrC,kBAAkB,MAAe;CACrC;AACJ"}
1
+ {"version":3,"file":"fusion.js","names":[],"sources":["../../src/vision/fusion.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * The contract a fused pipeline carries inside its own `.onnx` file.\n *\n * A pipeline built by the Python SDK's `ort_vision_sdk.compose` is a single\n * graph that already contains the detector, the crop-and-resize bridge and the\n * classifier. Everything the runtime needs to drive it — the letterbox\n * resolution, the crop resolution, where the crops come from, how many\n * detections the graph emits, the class names of both stages — was decided at\n * fusion time and written into the model's metadata.\n *\n * This module reads it back. It is the browser half of a contract whose other\n * half lives in `ort_vision_sdk/fusion.py`: the same keys, the same encodings,\n * the same fallbacks. A pipeline fused once therefore runs identically in\n * Python and in a browser tab, off the same file.\n *\n * Building a pipeline stays a Python-side build step — there is no ONNX\n * protobuf writer here, and there is no reason for one: fusing is something you\n * do once next to your export pipeline, not in a page load.\n */\n\nimport { parseNames } from \"./core/metadata\";\n\n/**\n * Which tensor the bridge crops the detected boxes out of.\n *\n * - `\"detector_input\"`: the letterboxed tensor already fed to the detector.\n * The fused graph then has a **single** image input, but a small object is\n * cropped out of its downscaled copy.\n * - `\"original\"`: a second, full-resolution image input. The bridge undoes the\n * letterbox transform in-graph and crops at native resolution. Two tensors to\n * feed, still one session and one model load.\n */\nexport type CropSource = \"detector_input\" | \"original\";\n\n/** Value of the `ovs.kind` metadata key for a detector→classifier pipeline. */\nexport const FUSION_KIND_DETECT_CLASSIFY = \"detect_classify\";\n\n/**\n * Namespace for every metadata key the fusion writes.\n *\n * Namespaced on purpose: the detector's own Ultralytics metadata (`names`,\n * `task`, `imgsz`) is carried over into the fused model, and an un-prefixed key\n * would either collide with it or be mistaken for it.\n */\nexport const METADATA_PREFIX = \"ovs.\";\n\n/** Name of the fused graph's letterboxed detector input, `[1, 3, H, W]` float32 in `[0, 1]`. */\nexport const INPUT_IMAGE = \"images\";\n\n/** Name of the full-resolution input. Present only when `cropSource === \"original\"`. */\nexport const INPUT_SOURCE = \"source_image\";\n\n/** Name of the `[1]` float32 letterbox scale factor. Only with `cropSource === \"original\"`. */\nexport const INPUT_SCALE = \"letterbox_scale\";\n\n/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === \"original\"`. */\nexport const INPUT_PAD = \"letterbox_pad\";\n\n/**\n * Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels.\n *\n * A file fused by `ort-vision-sdk` 0.9.0 or later reports the box that was\n * actually classified: clamped to the image the crop came from, exactly as\n * RoiAlign received it. Older files report the raw box, so one that ran off the\n * frame draws a rectangle wider than the region the classifier saw.\n */\nexport const OUTPUT_BOXES = \"boxes\";\n\n/** Name of the `[K]` float32 detection-confidence output. */\nexport const OUTPUT_SCORES = \"scores\";\n\n/** Name of the `[K]` int64 detector-class output. */\nexport const OUTPUT_CLASSES = \"classes\";\n\n/** Name of the `[1]` int64 output holding how many of the `K` rows are real. */\nexport const OUTPUT_NUM_DETECTIONS = \"num_detections\";\n\n/** Name of the `[K, numClassifierClasses]` float32 classifier output, one row per box. */\nexport const OUTPUT_PROBS = \"probs\";\n\n/** Everything a fused pipeline declares about how it must be driven. */\nexport interface FusionSpec {\n /** Pipeline family. Only `\"detect_classify\"` exists today. */\n readonly kind: string;\n /** `[width, height]` the detector stage expects — the resolution to letterbox to. */\n readonly inputSize: readonly [number, number];\n /** `[width, height]` every crop is resampled to inside the graph. */\n readonly cropSize: readonly [number, number];\n /** Which tensor the crops are taken from. */\n readonly cropSource: CropSource;\n /**\n * Fixed number of rows `K` every output carries, surplus zero-padded and\n * counted by {@link OUTPUT_NUM_DETECTIONS}. `null` means the graph emits\n * exactly as many rows as survived NMS.\n */\n readonly maxDetections: number | null;\n /** Score threshold baked into the graph's NMS node. */\n readonly confThreshold: number;\n /** IoU threshold baked into the graph's NMS node. */\n readonly iouThreshold: number;\n /** Whether the classifier stage emits logits that still need a softmax. */\n readonly applySoftmax: boolean;\n /** Detector class names in class-id order, or `null` when the fusion recorded none. */\n readonly detectorNames: readonly string[] | null;\n /** Classifier class names in class-id order, or `null`. */\n readonly classifierNames: readonly string[] | null;\n /** Version of `ort-vision-sdk` that produced the file. */\n readonly sdkVersion: string;\n /** Whether driving this pipeline requires feeding the full-resolution input. */\n readonly needsSourceImage: boolean;\n}\n\nconst KEY_KIND = \"kind\";\nconst KEY_SDK_VERSION = \"sdk_version\";\nconst KEY_INPUT_SIZE = \"input_size\";\nconst KEY_CROP_SIZE = \"crop_size\";\nconst KEY_CROP_SOURCE = \"crop_source\";\nconst KEY_MAX_DETECTIONS = \"max_detections\";\nconst KEY_CONF_THRESHOLD = \"conf_threshold\";\nconst KEY_IOU_THRESHOLD = \"iou_threshold\";\nconst KEY_APPLY_SOFTMAX = \"apply_softmax\";\nconst KEY_DETECTOR_NAMES = \"detector_names\";\nconst KEY_CLASSIFIER_NAMES = \"classifier_names\";\n\nconst DYNAMIC = \"dynamic\";\n\n/**\n * Decode a `\"640,640\"` pair.\n *\n * @param raw The encoded pair.\n * @returns `[width, height]`, or `null` when the value is missing or malformed.\n */\nfunction decodeSize(raw: string | undefined): readonly [number, number] | null {\n if (!raw) return null;\n const parts = raw.split(\",\");\n if (parts.length !== 2) return null;\n const width = Number(parts[0]);\n const height = Number(parts[1]);\n if (!Number.isInteger(width) || !Number.isInteger(height)) return null;\n if (width < 1 || height < 1) return null;\n return [width, height];\n}\n\n/**\n * Decode a float, falling back when the value is missing or malformed.\n *\n * @param raw The encoded value.\n * @param fallback Value to use when `raw` cannot be read.\n * @returns The parsed number, or `fallback`.\n */\nfunction decodeFloat(raw: string | undefined, fallback: number): number {\n if (!raw) return fallback;\n const value = Number(raw);\n return Number.isFinite(value) ? value : fallback;\n}\n\n/**\n * Read a pipeline spec out of a model's custom metadata.\n *\n * Individual malformed entries fall back to the value a fusion would have used\n * by default — a single bad float is not a reason to reject an otherwise\n * loadable pipeline. A malformed resolution is fatal, because there is no safe\n * default for one.\n *\n * @param metadata A model's custom metadata map, as read by\n * {@link readModelMetadata}.\n * @returns The decoded spec, or `null` when the model is not a fused pipeline —\n * it carries no `ovs.kind` entry, or one naming a pipeline kind this version\n * does not know how to drive.\n */\nexport function readFusionSpec(\n metadata: Readonly<Record<string, string>> | undefined,\n): FusionSpec | null {\n if (!metadata) return null;\n\n const read: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata)) {\n if (key.startsWith(METADATA_PREFIX)) read[key.slice(METADATA_PREFIX.length)] = value;\n }\n if (read[KEY_KIND] !== FUSION_KIND_DETECT_CLASSIFY) return null;\n\n const inputSize = decodeSize(read[KEY_INPUT_SIZE]);\n const cropSize = decodeSize(read[KEY_CROP_SIZE]);\n if (inputSize === null || cropSize === null) return null;\n\n const rawMax = read[KEY_MAX_DETECTIONS] ?? DYNAMIC;\n const parsedMax = Number(rawMax);\n const maxDetections =\n rawMax === DYNAMIC || !Number.isInteger(parsedMax) || parsedMax < 1 ? null : parsedMax;\n\n const cropSource: CropSource =\n read[KEY_CROP_SOURCE] === \"original\" ? \"original\" : \"detector_input\";\n\n return {\n kind: FUSION_KIND_DETECT_CLASSIFY,\n inputSize,\n cropSize,\n cropSource,\n maxDetections,\n confThreshold: decodeFloat(read[KEY_CONF_THRESHOLD], 0.25),\n iouThreshold: decodeFloat(read[KEY_IOU_THRESHOLD], 0.45),\n applySoftmax: (read[KEY_APPLY_SOFTMAX] ?? \"1\") !== \"0\",\n detectorNames: parseNames(read[KEY_DETECTOR_NAMES]),\n classifierNames: parseNames(read[KEY_CLASSIFIER_NAMES]),\n sdkVersion: read[KEY_SDK_VERSION] ?? \"\",\n needsSourceImage: cropSource === \"original\",\n };\n}\n"],"mappings":";;AAoCA,IAAa,IAA8B,mBAS9B,IAAkB,QAGlB,IAAc,UAGd,IAAe,gBAGf,IAAc,mBAGd,IAAY,iBAUZ,IAAe,SAGf,IAAgB,UAGhB,IAAiB,WAGjB,IAAwB,kBAGxB,IAAe,SAkCtB,IAAW,QACX,IAAkB,eAClB,IAAiB,cACjB,IAAgB,aAChB,IAAkB,eAClB,IAAqB,kBACrB,IAAqB,kBACrB,IAAoB,iBACpB,IAAoB,iBACpB,IAAqB,kBACrB,IAAuB,oBAEvB,IAAU;AAQhB,SAAS,EAAW,GAA2D;CAC3E,IAAI,CAAC,GAAK,OAAO;CACjB,IAAM,IAAQ,EAAI,MAAM,GAAG;CAC3B,IAAI,EAAM,WAAW,GAAG,OAAO;CAC/B,IAAM,IAAQ,OAAO,EAAM,EAAE,GACvB,IAAS,OAAO,EAAM,EAAE;CAG9B,OAFI,CAAC,OAAO,UAAU,CAAK,KAAK,CAAC,OAAO,UAAU,CAAM,KACpD,IAAQ,KAAK,IAAS,IAAU,OAC7B,CAAC,GAAO,CAAM;AACzB;AASA,SAAS,EAAY,GAAyB,GAA0B;CACpE,IAAI,CAAC,GAAK,OAAO;CACjB,IAAM,IAAQ,OAAO,CAAG;CACxB,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;AAC5C;AAgBA,SAAgB,EACZ,GACiB;CACjB,IAAI,CAAC,GAAU,OAAO;CAEtB,IAAM,IAA+B,CAAC;CACtC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAQ,GAC9C,AAAI,EAAI,WAAA,MAA0B,MAAG,EAAK,EAAI,MAAM,CAAsB,KAAK;CAEnF,IAAI,EAAK,OAAA,mBAA2C,OAAO;CAE3D,IAAM,IAAY,EAAW,EAAK,EAAe,GAC3C,IAAW,EAAW,EAAK,EAAc;CAC/C,IAAI,MAAc,QAAQ,MAAa,MAAM,OAAO;CAEpD,IAAM,IAAS,EAAK,MAAuB,GACrC,IAAY,OAAO,CAAM,GACzB,IACF,MAAW,KAAW,CAAC,OAAO,UAAU,CAAS,KAAK,IAAY,IAAI,OAAO,GAE3E,IACF,EAAK,OAAqB,aAAa,aAAa;CAExD,OAAO;EACH,MAAM;EACN;EACA;EACA;EACA;EACA,eAAe,EAAY,EAAK,IAAqB,GAAI;EACzD,cAAc,EAAY,EAAK,IAAoB,GAAI;EACvD,eAAe,EAAK,MAAsB,SAAS;EACnD,eAAe,EAAW,EAAK,EAAmB;EAClD,iBAAiB,EAAW,EAAK,EAAqB;EACtD,YAAY,EAAK,MAAoB;EACrC,kBAAkB,MAAe;CACrC;AACJ"}
@@ -1,2 +1,2 @@
1
- const e=require("./core/exceptions.cjs"),t=require("./types.cjs"),n=require("./core/timing.cjs"),r=require("./results.cjs"),i=require("./labels.cjs"),a=require("./core/graph.cjs"),o=require("./core/metadata.cjs"),s=require("./core/providers.cjs"),c=require("./core/session.cjs"),l=require("./io/image.cjs"),u=require("./fusion.cjs"),d=require("./preprocess/image.cjs"),f=require("./preprocess/pipeline.cjs"),p=require("./postprocess/classification.cjs"),m=require("./postprocess/detection.cjs"),h=require("./postprocess/segmentation.cjs"),g=require("./tasks/base.cjs"),_=require("./tasks/classifier.cjs"),v=require("./tasks/detectClassify.cjs"),y=require("./tasks/detector.cjs"),b=require("./tasks/segmenter.cjs");var x=`0.7.1`;exports.BoundingBox=t.BoundingBox,exports.Boxes=r.Boxes,exports.COCO_CLASSES=i.COCO_CLASSES,exports.ClassificationResults=r.ClassificationResults,exports.Classifier=_.Classifier,exports.DEFAULT_PROVIDERS=s.DEFAULT_PROVIDERS,exports.DetectClassify=v.DetectClassify,exports.DetectClassifyResults=r.DetectClassifyResults,exports.DetectionResults=r.DetectionResults,exports.Detector=y.Detector,exports.FUSION_KIND_DETECT_CLASSIFY=u.FUSION_KIND_DETECT_CLASSIFY,exports.FusionError=e.FusionError,exports.INPUT_IMAGE=u.INPUT_IMAGE,exports.INPUT_PAD=u.INPUT_PAD,exports.INPUT_SCALE=u.INPUT_SCALE,exports.INPUT_SOURCE=u.INPUT_SOURCE,exports.ImageLoadError=e.ImageLoadError,exports.InferenceError=e.InferenceError,exports.LabelMapError=e.LabelMapError,exports.LetterboxPipeline=f.LetterboxPipeline,exports.METADATA_PREFIX=u.METADATA_PREFIX,exports.Mask=t.Mask,exports.Masks=r.Masks,exports.ModelLoadError=e.ModelLoadError,exports.NoDetectionsError=e.NoDetectionsError,exports.OUTPUT_BOXES=u.OUTPUT_BOXES,exports.OUTPUT_CLASSES=u.OUTPUT_CLASSES,exports.OUTPUT_NUM_DETECTIONS=u.OUTPUT_NUM_DETECTIONS,exports.OUTPUT_PROBS=u.OUTPUT_PROBS,exports.OUTPUT_SCORES=u.OUTPUT_SCORES,exports.OrtSession=c.OrtSession,exports.OrtVisionError=e.OrtVisionError,exports.Probs=r.Probs,exports.ProviderNotAvailableError=e.ProviderNotAvailableError,exports.RGBImage=t.RGBImage,exports.ResizePipeline=f.ResizePipeline,exports.SegmentationResults=r.SegmentationResults,exports.Segmenter=b.Segmenter,exports.SpeedTimer=n.SpeedTimer,exports.VERSION=x,exports.VisionTask=g.VisionTask,exports.batchedNms=m.batchedNms,exports.classificationNumClasses=a.classificationNumClasses,exports.declaredShapesFrom=a.declaredShapesFrom,exports.decodeYolo=m.decodeYolo,exports.decodeYoloAnchors=m.decodeYoloAnchors,exports.decodeYoloSeg=h.decodeYoloSeg,exports.defaultLabels=i.defaultLabels,exports.detectionNumClasses=a.detectionNumClasses,exports.fromCv2=d.fromCv2,exports.letterbox=d.letterbox,exports.letterboxToTensorData=f.letterboxToTensorData,exports.loadImage=l.loadImage,exports.modelNames=o.modelNames,exports.nms=m.nms,exports.normalize=d.normalize,exports.parseNames=o.parseNames,exports.readFusionSpec=u.readFusionSpec,exports.readModelMetadata=o.readModelMetadata,exports.requireDetections=g.requireDetections,exports.resize=d.resize,exports.resizeToTensorData=f.resizeToTensorData,exports.resolveInputSize=a.resolveInputSize,exports.resolveLabels=i.resolveLabels,exports.resolveProviders=s.resolveProviders,exports.softmax=p.softmax,exports.spatialInputSize=a.spatialInputSize,exports.toCHW=d.toCHW,exports.toCv2=d.toCv2,exports.toFloat32=d.toFloat32,exports.toFloat32Tensor=d.toFloat32Tensor,exports.toTensor=d.toTensor,exports.topK=p.topK,exports.writePlanarFloat32=f.writePlanarFloat32,exports.zeroTensorData=f.zeroTensorData;
1
+ const e=require("./core/exceptions.cjs"),t=require("./types.cjs"),n=require("./core/timing.cjs"),r=require("./results.cjs"),i=require("./labels.cjs"),a=require("./core/graph.cjs"),o=require("./core/metadata.cjs"),s=require("./core/providers.cjs"),c=require("./core/session.cjs"),l=require("./normalization.cjs"),u=require("./io/image.cjs"),d=require("./fusion.cjs"),f=require("./preprocess/image.cjs"),p=require("./preprocess/pipeline.cjs"),m=require("./postprocess/classification.cjs"),h=require("./postprocess/detection.cjs"),g=require("./postprocess/segmentation.cjs"),_=require("./tasks/base.cjs"),v=require("./tasks/classifier.cjs"),y=require("./tasks/detectClassify.cjs"),b=require("./tasks/detector.cjs"),x=require("./tasks/segmenter.cjs");var S=`0.8.1`;exports.BoundingBox=t.BoundingBox,exports.Boxes=r.Boxes,exports.COCO_CLASSES=i.COCO_CLASSES,exports.CUSTOM_NORMALIZATION=l.CUSTOM_NORMALIZATION,exports.ClassificationResults=r.ClassificationResults,exports.Classifier=v.Classifier,exports.DEFAULT_PROVIDERS=s.DEFAULT_PROVIDERS,exports.DetectClassify=y.DetectClassify,exports.DetectClassifyResults=r.DetectClassifyResults,exports.DetectionResults=r.DetectionResults,exports.Detector=b.Detector,exports.FUSION_KIND_DETECT_CLASSIFY=d.FUSION_KIND_DETECT_CLASSIFY,exports.FusionError=e.FusionError,exports.IDENTITY_MEAN=l.IDENTITY_MEAN,exports.IDENTITY_STD=l.IDENTITY_STD,exports.IMAGENET_MEAN=l.IMAGENET_MEAN,exports.IMAGENET_STD=l.IMAGENET_STD,exports.INPUT_IMAGE=d.INPUT_IMAGE,exports.INPUT_PAD=d.INPUT_PAD,exports.INPUT_SCALE=d.INPUT_SCALE,exports.INPUT_SOURCE=d.INPUT_SOURCE,exports.ImageLoadError=e.ImageLoadError,exports.InferenceError=e.InferenceError,exports.LabelMapError=e.LabelMapError,exports.LetterboxPipeline=p.LetterboxPipeline,exports.METADATA_PREFIX=d.METADATA_PREFIX,exports.Mask=t.Mask,exports.Masks=r.Masks,exports.ModelLoadError=e.ModelLoadError,exports.NoDetectionsError=e.NoDetectionsError,exports.OUTPUT_BOXES=d.OUTPUT_BOXES,exports.OUTPUT_CLASSES=d.OUTPUT_CLASSES,exports.OUTPUT_NUM_DETECTIONS=d.OUTPUT_NUM_DETECTIONS,exports.OUTPUT_PROBS=d.OUTPUT_PROBS,exports.OUTPUT_SCORES=d.OUTPUT_SCORES,exports.OrtSession=c.OrtSession,exports.OrtVisionError=e.OrtVisionError,exports.Probs=r.Probs,exports.ProviderNotAvailableError=e.ProviderNotAvailableError,exports.RGBImage=t.RGBImage,exports.ResizePipeline=p.ResizePipeline,exports.SegmentationResults=r.SegmentationResults,exports.Segmenter=x.Segmenter,exports.SpeedTimer=n.SpeedTimer,exports.VERSION=S,exports.VisionTask=_.VisionTask,exports.batchedNms=h.batchedNms,exports.classificationNumClasses=a.classificationNumClasses,exports.declaredShapesFrom=a.declaredShapesFrom,exports.decodeYolo=h.decodeYolo,exports.decodeYoloAnchors=h.decodeYoloAnchors,exports.decodeYoloSeg=g.decodeYoloSeg,exports.defaultLabels=i.defaultLabels,exports.detectProviders=s.detectProviders,exports.detectionNumClasses=a.detectionNumClasses,exports.fromCv2=f.fromCv2,exports.isUltralyticsClassifier=l.isUltralyticsClassifier,exports.letterbox=f.letterbox,exports.letterboxToTensorData=p.letterboxToTensorData,exports.loadImage=u.loadImage,exports.modelNames=o.modelNames,exports.nms=h.nms,exports.normalize=f.normalize,exports.parseNames=o.parseNames,exports.readFusionSpec=d.readFusionSpec,exports.readModelMetadata=o.readModelMetadata,exports.requireDetections=_.requireDetections,exports.resize=f.resize,exports.resizeToTensorData=p.resizeToTensorData,exports.resolveInputSize=a.resolveInputSize,exports.resolveLabels=i.resolveLabels,exports.resolveNormalization=l.resolveNormalization,exports.resolveProviders=s.resolveProviders,exports.softmax=m.softmax,exports.spatialInputSize=a.spatialInputSize,exports.toCHW=f.toCHW,exports.toCv2=f.toCv2,exports.toFloat32=f.toFloat32,exports.toFloat32Tensor=f.toFloat32Tensor,exports.toTensor=f.toTensor,exports.topK=m.topK,exports.writePlanarFloat32=p.writePlanarFloat32,exports.zeroTensorData=p.zeroTensorData;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/vision/index.ts"],"sourcesContent":["/**\n * `tempest-react-sdk/vision` — browser computer-vision inference with ONNX\n * Runtime Web (classification, detection, segmentation).\n *\n * Vendored from `@mauriciobenjamin700/ort-vision-sdk-web@0.7.1` (MIT, same\n * author) so it ships inside this SDK without an extra package install.\n * `onnxruntime-web` stays an optional peer dependency — install it (and ship\n * the matching `.wasm` files) only when you use this subpath.\n *\n * Do not hand-edit — regenerate with `npm run vendor:vision`.\n */\n\nexport {\n BoundingBox,\n Mask,\n RGBImage,\n type ClassProbability,\n type ClassificationResult,\n type DetectionResult,\n type SegmentationResult,\n} from \"./types\";\n\nexport {\n Boxes,\n ClassificationResults,\n DetectClassifyResults,\n DetectionResults,\n Masks,\n Probs,\n SegmentationResults,\n} from \"./results\";\n\nexport {\n COCO_CLASSES,\n type LabelSpec,\n type ResolveLabelsOptions,\n defaultLabels,\n resolveLabels,\n} from \"./labels\";\n\nexport {\n FusionError,\n ImageLoadError,\n InferenceError,\n LabelMapError,\n ModelLoadError,\n NoDetectionsError,\n OrtVisionError,\n ProviderNotAvailableError,\n} from \"./core/exceptions\";\n\nexport { type ModelSource, type OrtSessionOptions, OrtSession } from \"./core/session\";\nexport {\n type DeclaredDim,\n type DeclaredShape,\n type ResolveInputSizeOptions,\n classificationNumClasses,\n declaredShapesFrom,\n detectionNumClasses,\n resolveInputSize,\n spatialInputSize,\n} from \"./core/graph\";\nexport { modelNames, parseNames, readModelMetadata } from \"./core/metadata\";\nexport { DEFAULT_PROVIDERS, resolveProviders } from \"./core/providers\";\nexport { type Speed, SpeedTimer } from \"./core/timing\";\n\nexport { type ImageInput, loadImage } from \"./io/image\";\n\nexport {\n FUSION_KIND_DETECT_CLASSIFY,\n INPUT_IMAGE,\n INPUT_PAD,\n INPUT_SCALE,\n INPUT_SOURCE,\n METADATA_PREFIX,\n OUTPUT_BOXES,\n OUTPUT_CLASSES,\n OUTPUT_NUM_DETECTIONS,\n OUTPUT_PROBS,\n OUTPUT_SCORES,\n type CropSource,\n type FusionSpec,\n readFusionSpec,\n} from \"./fusion\";\n\nexport {\n type LetterboxResult,\n fromCv2,\n letterbox,\n normalize,\n resize,\n toCHW,\n toCv2,\n toFloat32,\n toFloat32Tensor,\n toTensor,\n} from \"./preprocess/image\";\n\nexport {\n type FusedLetterboxResult,\n type FusedResizeResult,\n LetterboxPipeline,\n ResizePipeline,\n letterboxToTensorData,\n resizeToTensorData,\n writePlanarFloat32,\n zeroTensorData,\n} from \"./preprocess/pipeline\";\n\nexport { type TopKResult, softmax, topK } from \"./postprocess/classification\";\n\nexport {\n type DecodeYoloAnchorsOptions,\n type DecodeYoloOptions,\n type DecodedAnchors,\n type DecodedDetection,\n batchedNms,\n decodeYolo,\n decodeYoloAnchors,\n nms,\n} from \"./postprocess/detection\";\n\nexport {\n type DecodeYoloSegOptions,\n type DecodedSegmentation,\n decodeYoloSeg,\n} from \"./postprocess/segmentation\";\n\nexport { VisionTask, requireDetections } from \"./tasks/base\";\nexport {\n type ClassifierOptions,\n type ClassifierPredictOptions,\n Classifier,\n} from \"./tasks/classifier\";\nexport {\n type DetectClassifyOptions,\n type DetectClassifyPredictOptions,\n DetectClassify,\n} from \"./tasks/detectClassify\";\nexport {\n type DetectorHead,\n type DetectorOptions,\n type DetectorPredictOptions,\n Detector,\n} from \"./tasks/detector\";\nexport {\n type SegmenterHead,\n type SegmenterOptions,\n type SegmenterPredictOptions,\n Segmenter,\n} from \"./tasks/segmenter\";\n\nexport const VERSION: string = \"0.7.1\";\n"],"mappings":"0sBAwJA,IAAa,EAAkB"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/vision/index.ts"],"sourcesContent":["/**\n * `tempest-react-sdk/vision` — browser computer-vision inference with ONNX\n * Runtime Web (classification, detection, segmentation).\n *\n * Vendored from `@mauriciobenjamin700/ort-vision-sdk-web@0.8.1` (MIT, same\n * author) so it ships inside this SDK without an extra package install.\n * `onnxruntime-web` stays an optional peer dependency — install it (and ship\n * the matching `.wasm` files) only when you use this subpath.\n *\n * Do not hand-edit — regenerate with `npm run vendor:vision`.\n */\n\nexport {\n BoundingBox,\n Mask,\n RGBImage,\n type ClassProbability,\n type ClassificationResult,\n type DetectionResult,\n type SegmentationResult,\n} from \"./types\";\n\nexport {\n Boxes,\n ClassificationResults,\n DetectClassifyResults,\n DetectionResults,\n Masks,\n Probs,\n SegmentationResults,\n} from \"./results\";\n\nexport {\n COCO_CLASSES,\n type LabelSpec,\n type ResolveLabelsOptions,\n defaultLabels,\n resolveLabels,\n} from \"./labels\";\n\nexport {\n FusionError,\n ImageLoadError,\n InferenceError,\n LabelMapError,\n ModelLoadError,\n NoDetectionsError,\n OrtVisionError,\n ProviderNotAvailableError,\n} from \"./core/exceptions\";\n\nexport { type ModelSource, type OrtSessionOptions, OrtSession } from \"./core/session\";\nexport {\n type DeclaredDim,\n type DeclaredShape,\n type ResolveInputSizeOptions,\n classificationNumClasses,\n declaredShapesFrom,\n detectionNumClasses,\n resolveInputSize,\n spatialInputSize,\n} from \"./core/graph\";\nexport { modelNames, parseNames, readModelMetadata } from \"./core/metadata\";\nexport { DEFAULT_PROVIDERS, detectProviders, resolveProviders } from \"./core/providers\";\nexport { type Speed, SpeedTimer } from \"./core/timing\";\nexport {\n CUSTOM_NORMALIZATION,\n IDENTITY_MEAN,\n IDENTITY_STD,\n IMAGENET_MEAN,\n IMAGENET_STD,\n type Normalization,\n type ResolvedNormalization,\n isUltralyticsClassifier,\n resolveNormalization,\n} from \"./normalization\";\n\nexport { type ImageInput, loadImage } from \"./io/image\";\n\nexport {\n FUSION_KIND_DETECT_CLASSIFY,\n INPUT_IMAGE,\n INPUT_PAD,\n INPUT_SCALE,\n INPUT_SOURCE,\n METADATA_PREFIX,\n OUTPUT_BOXES,\n OUTPUT_CLASSES,\n OUTPUT_NUM_DETECTIONS,\n OUTPUT_PROBS,\n OUTPUT_SCORES,\n type CropSource,\n type FusionSpec,\n readFusionSpec,\n} from \"./fusion\";\n\nexport {\n type LetterboxResult,\n fromCv2,\n letterbox,\n normalize,\n resize,\n toCHW,\n toCv2,\n toFloat32,\n toFloat32Tensor,\n toTensor,\n} from \"./preprocess/image\";\n\nexport {\n type FusedLetterboxResult,\n type FusedResizeResult,\n LetterboxPipeline,\n ResizePipeline,\n letterboxToTensorData,\n resizeToTensorData,\n writePlanarFloat32,\n zeroTensorData,\n} from \"./preprocess/pipeline\";\n\nexport { type TopKResult, softmax, topK } from \"./postprocess/classification\";\n\nexport {\n type DecodeYoloAnchorsOptions,\n type DecodeYoloOptions,\n type DecodedAnchors,\n type DecodedDetection,\n batchedNms,\n decodeYolo,\n decodeYoloAnchors,\n nms,\n} from \"./postprocess/detection\";\n\nexport {\n type DecodeYoloSegOptions,\n type DecodedSegmentation,\n decodeYoloSeg,\n} from \"./postprocess/segmentation\";\n\nexport { VisionTask, requireDetections } from \"./tasks/base\";\nexport {\n type ClassifierOptions,\n type ClassifierPredictOptions,\n Classifier,\n} from \"./tasks/classifier\";\nexport {\n type DetectClassifyOptions,\n type DetectClassifyPredictOptions,\n DetectClassify,\n} from \"./tasks/detectClassify\";\nexport {\n type DetectorHead,\n type DetectorOptions,\n type DetectorPredictOptions,\n Detector,\n} from \"./tasks/detector\";\nexport {\n type SegmenterHead,\n type SegmenterOptions,\n type SegmenterPredictOptions,\n Segmenter,\n} from \"./tasks/segmenter\";\n\nexport const VERSION: string = \"0.8.1\";\n"],"mappings":"2uBAmKA,IAAa,EAAkB"}
@@ -5,23 +5,24 @@ import { Boxes as f, ClassificationResults as p, DetectClassifyResults as m, Det
5
5
  import { COCO_CLASSES as y, defaultLabels as b, resolveLabels as x } from "./labels.js";
6
6
  import { classificationNumClasses as S, declaredShapesFrom as C, detectionNumClasses as w, resolveInputSize as T, spatialInputSize as E } from "./core/graph.js";
7
7
  import { modelNames as D, parseNames as O, readModelMetadata as k } from "./core/metadata.js";
8
- import { DEFAULT_PROVIDERS as A, resolveProviders as j } from "./core/providers.js";
9
- import { OrtSession as M } from "./core/session.js";
10
- import { loadImage as N } from "./io/image.js";
11
- import { FUSION_KIND_DETECT_CLASSIFY as P, INPUT_IMAGE as F, INPUT_PAD as I, INPUT_SCALE as L, INPUT_SOURCE as R, METADATA_PREFIX as z, OUTPUT_BOXES as B, OUTPUT_CLASSES as V, OUTPUT_NUM_DETECTIONS as H, OUTPUT_PROBS as U, OUTPUT_SCORES as W, readFusionSpec as G } from "./fusion.js";
12
- import { fromCv2 as K, letterbox as q, normalize as J, resize as Y, toCHW as X, toCv2 as Z, toFloat32 as Q, toFloat32Tensor as $, toTensor as ee } from "./preprocess/image.js";
13
- import { LetterboxPipeline as te, ResizePipeline as ne, letterboxToTensorData as re, resizeToTensorData as ie, writePlanarFloat32 as ae, zeroTensorData as oe } from "./preprocess/pipeline.js";
14
- import { softmax as se, topK as ce } from "./postprocess/classification.js";
15
- import { batchedNms as le, decodeYolo as ue, decodeYoloAnchors as de, nms as fe } from "./postprocess/detection.js";
16
- import { decodeYoloSeg as pe } from "./postprocess/segmentation.js";
17
- import { VisionTask as me, requireDetections as he } from "./tasks/base.js";
18
- import { Classifier as ge } from "./tasks/classifier.js";
19
- import { DetectClassify as _e } from "./tasks/detectClassify.js";
20
- import { Detector as ve } from "./tasks/detector.js";
21
- import { Segmenter as ye } from "./tasks/segmenter.js";
8
+ import { DEFAULT_PROVIDERS as A, detectProviders as j, resolveProviders as M } from "./core/providers.js";
9
+ import { OrtSession as N } from "./core/session.js";
10
+ import { CUSTOM_NORMALIZATION as P, IDENTITY_MEAN as F, IDENTITY_STD as I, IMAGENET_MEAN as L, IMAGENET_STD as R, isUltralyticsClassifier as z, resolveNormalization as B } from "./normalization.js";
11
+ import { loadImage as V } from "./io/image.js";
12
+ import { FUSION_KIND_DETECT_CLASSIFY as H, INPUT_IMAGE as U, INPUT_PAD as W, INPUT_SCALE as G, INPUT_SOURCE as K, METADATA_PREFIX as q, OUTPUT_BOXES as J, OUTPUT_CLASSES as Y, OUTPUT_NUM_DETECTIONS as X, OUTPUT_PROBS as Z, OUTPUT_SCORES as Q, readFusionSpec as $ } from "./fusion.js";
13
+ import { fromCv2 as ee, letterbox as te, normalize as ne, resize as re, toCHW as ie, toCv2 as ae, toFloat32 as oe, toFloat32Tensor as se, toTensor as ce } from "./preprocess/image.js";
14
+ import { LetterboxPipeline as le, ResizePipeline as ue, letterboxToTensorData as de, resizeToTensorData as fe, writePlanarFloat32 as pe, zeroTensorData as me } from "./preprocess/pipeline.js";
15
+ import { softmax as he, topK as ge } from "./postprocess/classification.js";
16
+ import { batchedNms as _e, decodeYolo as ve, decodeYoloAnchors as ye, nms as be } from "./postprocess/detection.js";
17
+ import { decodeYoloSeg as xe } from "./postprocess/segmentation.js";
18
+ import { VisionTask as Se, requireDetections as Ce } from "./tasks/base.js";
19
+ import { Classifier as we } from "./tasks/classifier.js";
20
+ import { DetectClassify as Te } from "./tasks/detectClassify.js";
21
+ import { Detector as Ee } from "./tasks/detector.js";
22
+ import { Segmenter as De } from "./tasks/segmenter.js";
22
23
  //#region src/vision/index.ts
23
- var be = "0.7.1";
24
+ var Oe = "0.8.1";
24
25
  //#endregion
25
- export { c as BoundingBox, f as Boxes, y as COCO_CLASSES, p as ClassificationResults, ge as Classifier, A as DEFAULT_PROVIDERS, _e as DetectClassify, m as DetectClassifyResults, h as DetectionResults, ve as Detector, P as FUSION_KIND_DETECT_CLASSIFY, e as FusionError, F as INPUT_IMAGE, I as INPUT_PAD, L as INPUT_SCALE, R as INPUT_SOURCE, t as ImageLoadError, n as InferenceError, r as LabelMapError, te as LetterboxPipeline, z as METADATA_PREFIX, l as Mask, g as Masks, i as ModelLoadError, a as NoDetectionsError, B as OUTPUT_BOXES, V as OUTPUT_CLASSES, H as OUTPUT_NUM_DETECTIONS, U as OUTPUT_PROBS, W as OUTPUT_SCORES, M as OrtSession, o as OrtVisionError, _ as Probs, s as ProviderNotAvailableError, u as RGBImage, ne as ResizePipeline, v as SegmentationResults, ye as Segmenter, d as SpeedTimer, be as VERSION, me as VisionTask, le as batchedNms, S as classificationNumClasses, C as declaredShapesFrom, ue as decodeYolo, de as decodeYoloAnchors, pe as decodeYoloSeg, b as defaultLabels, w as detectionNumClasses, K as fromCv2, q as letterbox, re as letterboxToTensorData, N as loadImage, D as modelNames, fe as nms, J as normalize, O as parseNames, G as readFusionSpec, k as readModelMetadata, he as requireDetections, Y as resize, ie as resizeToTensorData, T as resolveInputSize, x as resolveLabels, j as resolveProviders, se as softmax, E as spatialInputSize, X as toCHW, Z as toCv2, Q as toFloat32, $ as toFloat32Tensor, ee as toTensor, ce as topK, ae as writePlanarFloat32, oe as zeroTensorData };
26
+ export { c as BoundingBox, f as Boxes, y as COCO_CLASSES, P as CUSTOM_NORMALIZATION, p as ClassificationResults, we as Classifier, A as DEFAULT_PROVIDERS, Te as DetectClassify, m as DetectClassifyResults, h as DetectionResults, Ee as Detector, H as FUSION_KIND_DETECT_CLASSIFY, e as FusionError, F as IDENTITY_MEAN, I as IDENTITY_STD, L as IMAGENET_MEAN, R as IMAGENET_STD, U as INPUT_IMAGE, W as INPUT_PAD, G as INPUT_SCALE, K as INPUT_SOURCE, t as ImageLoadError, n as InferenceError, r as LabelMapError, le as LetterboxPipeline, q as METADATA_PREFIX, l as Mask, g as Masks, i as ModelLoadError, a as NoDetectionsError, J as OUTPUT_BOXES, Y as OUTPUT_CLASSES, X as OUTPUT_NUM_DETECTIONS, Z as OUTPUT_PROBS, Q as OUTPUT_SCORES, N as OrtSession, o as OrtVisionError, _ as Probs, s as ProviderNotAvailableError, u as RGBImage, ue as ResizePipeline, v as SegmentationResults, De as Segmenter, d as SpeedTimer, Oe as VERSION, Se as VisionTask, _e as batchedNms, S as classificationNumClasses, C as declaredShapesFrom, ve as decodeYolo, ye as decodeYoloAnchors, xe as decodeYoloSeg, b as defaultLabels, j as detectProviders, w as detectionNumClasses, ee as fromCv2, z as isUltralyticsClassifier, te as letterbox, de as letterboxToTensorData, V as loadImage, D as modelNames, be as nms, ne as normalize, O as parseNames, $ as readFusionSpec, k as readModelMetadata, Ce as requireDetections, re as resize, fe as resizeToTensorData, T as resolveInputSize, x as resolveLabels, B as resolveNormalization, M as resolveProviders, he as softmax, E as spatialInputSize, ie as toCHW, ae as toCv2, oe as toFloat32, se as toFloat32Tensor, ce as toTensor, ge as topK, pe as writePlanarFloat32, me as zeroTensorData };
26
27
 
27
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/vision/index.ts"],"sourcesContent":["/**\n * `tempest-react-sdk/vision` — browser computer-vision inference with ONNX\n * Runtime Web (classification, detection, segmentation).\n *\n * Vendored from `@mauriciobenjamin700/ort-vision-sdk-web@0.7.1` (MIT, same\n * author) so it ships inside this SDK without an extra package install.\n * `onnxruntime-web` stays an optional peer dependency — install it (and ship\n * the matching `.wasm` files) only when you use this subpath.\n *\n * Do not hand-edit — regenerate with `npm run vendor:vision`.\n */\n\nexport {\n BoundingBox,\n Mask,\n RGBImage,\n type ClassProbability,\n type ClassificationResult,\n type DetectionResult,\n type SegmentationResult,\n} from \"./types\";\n\nexport {\n Boxes,\n ClassificationResults,\n DetectClassifyResults,\n DetectionResults,\n Masks,\n Probs,\n SegmentationResults,\n} from \"./results\";\n\nexport {\n COCO_CLASSES,\n type LabelSpec,\n type ResolveLabelsOptions,\n defaultLabels,\n resolveLabels,\n} from \"./labels\";\n\nexport {\n FusionError,\n ImageLoadError,\n InferenceError,\n LabelMapError,\n ModelLoadError,\n NoDetectionsError,\n OrtVisionError,\n ProviderNotAvailableError,\n} from \"./core/exceptions\";\n\nexport { type ModelSource, type OrtSessionOptions, OrtSession } from \"./core/session\";\nexport {\n type DeclaredDim,\n type DeclaredShape,\n type ResolveInputSizeOptions,\n classificationNumClasses,\n declaredShapesFrom,\n detectionNumClasses,\n resolveInputSize,\n spatialInputSize,\n} from \"./core/graph\";\nexport { modelNames, parseNames, readModelMetadata } from \"./core/metadata\";\nexport { DEFAULT_PROVIDERS, resolveProviders } from \"./core/providers\";\nexport { type Speed, SpeedTimer } from \"./core/timing\";\n\nexport { type ImageInput, loadImage } from \"./io/image\";\n\nexport {\n FUSION_KIND_DETECT_CLASSIFY,\n INPUT_IMAGE,\n INPUT_PAD,\n INPUT_SCALE,\n INPUT_SOURCE,\n METADATA_PREFIX,\n OUTPUT_BOXES,\n OUTPUT_CLASSES,\n OUTPUT_NUM_DETECTIONS,\n OUTPUT_PROBS,\n OUTPUT_SCORES,\n type CropSource,\n type FusionSpec,\n readFusionSpec,\n} from \"./fusion\";\n\nexport {\n type LetterboxResult,\n fromCv2,\n letterbox,\n normalize,\n resize,\n toCHW,\n toCv2,\n toFloat32,\n toFloat32Tensor,\n toTensor,\n} from \"./preprocess/image\";\n\nexport {\n type FusedLetterboxResult,\n type FusedResizeResult,\n LetterboxPipeline,\n ResizePipeline,\n letterboxToTensorData,\n resizeToTensorData,\n writePlanarFloat32,\n zeroTensorData,\n} from \"./preprocess/pipeline\";\n\nexport { type TopKResult, softmax, topK } from \"./postprocess/classification\";\n\nexport {\n type DecodeYoloAnchorsOptions,\n type DecodeYoloOptions,\n type DecodedAnchors,\n type DecodedDetection,\n batchedNms,\n decodeYolo,\n decodeYoloAnchors,\n nms,\n} from \"./postprocess/detection\";\n\nexport {\n type DecodeYoloSegOptions,\n type DecodedSegmentation,\n decodeYoloSeg,\n} from \"./postprocess/segmentation\";\n\nexport { VisionTask, requireDetections } from \"./tasks/base\";\nexport {\n type ClassifierOptions,\n type ClassifierPredictOptions,\n Classifier,\n} from \"./tasks/classifier\";\nexport {\n type DetectClassifyOptions,\n type DetectClassifyPredictOptions,\n DetectClassify,\n} from \"./tasks/detectClassify\";\nexport {\n type DetectorHead,\n type DetectorOptions,\n type DetectorPredictOptions,\n Detector,\n} from \"./tasks/detector\";\nexport {\n type SegmenterHead,\n type SegmenterOptions,\n type SegmenterPredictOptions,\n Segmenter,\n} from \"./tasks/segmenter\";\n\nexport const VERSION: string = \"0.7.1\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwJA,IAAa,KAAkB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/vision/index.ts"],"sourcesContent":["/**\n * `tempest-react-sdk/vision` — browser computer-vision inference with ONNX\n * Runtime Web (classification, detection, segmentation).\n *\n * Vendored from `@mauriciobenjamin700/ort-vision-sdk-web@0.8.1` (MIT, same\n * author) so it ships inside this SDK without an extra package install.\n * `onnxruntime-web` stays an optional peer dependency — install it (and ship\n * the matching `.wasm` files) only when you use this subpath.\n *\n * Do not hand-edit — regenerate with `npm run vendor:vision`.\n */\n\nexport {\n BoundingBox,\n Mask,\n RGBImage,\n type ClassProbability,\n type ClassificationResult,\n type DetectionResult,\n type SegmentationResult,\n} from \"./types\";\n\nexport {\n Boxes,\n ClassificationResults,\n DetectClassifyResults,\n DetectionResults,\n Masks,\n Probs,\n SegmentationResults,\n} from \"./results\";\n\nexport {\n COCO_CLASSES,\n type LabelSpec,\n type ResolveLabelsOptions,\n defaultLabels,\n resolveLabels,\n} from \"./labels\";\n\nexport {\n FusionError,\n ImageLoadError,\n InferenceError,\n LabelMapError,\n ModelLoadError,\n NoDetectionsError,\n OrtVisionError,\n ProviderNotAvailableError,\n} from \"./core/exceptions\";\n\nexport { type ModelSource, type OrtSessionOptions, OrtSession } from \"./core/session\";\nexport {\n type DeclaredDim,\n type DeclaredShape,\n type ResolveInputSizeOptions,\n classificationNumClasses,\n declaredShapesFrom,\n detectionNumClasses,\n resolveInputSize,\n spatialInputSize,\n} from \"./core/graph\";\nexport { modelNames, parseNames, readModelMetadata } from \"./core/metadata\";\nexport { DEFAULT_PROVIDERS, detectProviders, resolveProviders } from \"./core/providers\";\nexport { type Speed, SpeedTimer } from \"./core/timing\";\nexport {\n CUSTOM_NORMALIZATION,\n IDENTITY_MEAN,\n IDENTITY_STD,\n IMAGENET_MEAN,\n IMAGENET_STD,\n type Normalization,\n type ResolvedNormalization,\n isUltralyticsClassifier,\n resolveNormalization,\n} from \"./normalization\";\n\nexport { type ImageInput, loadImage } from \"./io/image\";\n\nexport {\n FUSION_KIND_DETECT_CLASSIFY,\n INPUT_IMAGE,\n INPUT_PAD,\n INPUT_SCALE,\n INPUT_SOURCE,\n METADATA_PREFIX,\n OUTPUT_BOXES,\n OUTPUT_CLASSES,\n OUTPUT_NUM_DETECTIONS,\n OUTPUT_PROBS,\n OUTPUT_SCORES,\n type CropSource,\n type FusionSpec,\n readFusionSpec,\n} from \"./fusion\";\n\nexport {\n type LetterboxResult,\n fromCv2,\n letterbox,\n normalize,\n resize,\n toCHW,\n toCv2,\n toFloat32,\n toFloat32Tensor,\n toTensor,\n} from \"./preprocess/image\";\n\nexport {\n type FusedLetterboxResult,\n type FusedResizeResult,\n LetterboxPipeline,\n ResizePipeline,\n letterboxToTensorData,\n resizeToTensorData,\n writePlanarFloat32,\n zeroTensorData,\n} from \"./preprocess/pipeline\";\n\nexport { type TopKResult, softmax, topK } from \"./postprocess/classification\";\n\nexport {\n type DecodeYoloAnchorsOptions,\n type DecodeYoloOptions,\n type DecodedAnchors,\n type DecodedDetection,\n batchedNms,\n decodeYolo,\n decodeYoloAnchors,\n nms,\n} from \"./postprocess/detection\";\n\nexport {\n type DecodeYoloSegOptions,\n type DecodedSegmentation,\n decodeYoloSeg,\n} from \"./postprocess/segmentation\";\n\nexport { VisionTask, requireDetections } from \"./tasks/base\";\nexport {\n type ClassifierOptions,\n type ClassifierPredictOptions,\n Classifier,\n} from \"./tasks/classifier\";\nexport {\n type DetectClassifyOptions,\n type DetectClassifyPredictOptions,\n DetectClassify,\n} from \"./tasks/detectClassify\";\nexport {\n type DetectorHead,\n type DetectorOptions,\n type DetectorPredictOptions,\n Detector,\n} from \"./tasks/detector\";\nexport {\n type SegmenterHead,\n type SegmenterOptions,\n type SegmenterPredictOptions,\n Segmenter,\n} from \"./tasks/segmenter\";\n\nexport const VERSION: string = \"0.8.1\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmKA,IAAa,KAAkB"}
@@ -0,0 +1,2 @@
1
+ var e=[.485,.456,.406],t=[.229,.224,.225],n=[0,0,0],r=[1,1,1],i=`custom`,a={imagenet:[e,t],ultralytics:[n,r],none:[n,r]};function o(e){return(e.author??``).trim().toLowerCase()===`ultralytics`&&(e.task??``).trim().toLowerCase()===`classify`}function s(e,t={}){let s=t.normalization??`auto`,l=t.mean!==void 0||t.std!==void 0;if(s!==`auto`&&a[s]===void 0)throw RangeError(`normalization must be one of 'auto', 'imagenet', 'ultralytics', 'none'; got ${JSON.stringify(s)}.`);if(l&&s!==`auto`)throw RangeError(`Pass either normalization=${JSON.stringify(s)} or explicit mean/std, not both.`);let u=o(e),d=s===`auto`?u?`ultralytics`:`imagenet`:s,[f,p]=a[d];if(!l)return{name:d,mean:f,std:p};let m=t.mean??f,h=t.std??p;return u&&!(c(m,n)&&c(h,r))&&console.warn(`The classifier is an Ultralytics export, whose classification head is trained on raw [0, 1] images, but mean=${JSON.stringify(m)} / std=${JSON.stringify(h)} was requested. It will be fed images normalized in a way it never saw in training, which degrades accuracy without raising anything. Drop mean/std to let normalization='auto' pick the identity.`),{name:i,mean:m,std:h}}function c(e,t){return e.every((e,n)=>e===t[n])}exports.CUSTOM_NORMALIZATION=i,exports.IDENTITY_MEAN=n,exports.IDENTITY_STD=r,exports.IMAGENET_MEAN=e,exports.IMAGENET_STD=t,exports.isUltralyticsClassifier=o,exports.resolveNormalization=s;
2
+ //# sourceMappingURL=normalization.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.cjs","names":[],"sources":["../../src/vision/normalization.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Which preprocessing a classifier expects its input to have had.\n *\n * A classifier is trained on a specific tensor, and feeding it a differently\n * prepared one degrades it silently — no exception, no warning, just worse\n * predictions. The two families this SDK sees most disagree completely:\n * torchvision-style models want the ImageNet mean and deviation subtracted and\n * divided out, while an Ultralytics classification head consumes raw `[0, 1]`.\n *\n * Guessing wrong is not detectable from the outside, but it is not a guess: an\n * Ultralytics export stamps `author` and `task` into its own metadata, and every\n * task in this SDK already reads that map for the class names.\n *\n * Mirrors `ort_vision_sdk.normalization` in the Python SDK; the two must agree,\n * because the same model file is driven by both.\n */\n\n/**\n * Which preprocessing the classifier expects its input to have had.\n *\n * - `\"auto\"` (the default wherever it is accepted) reads the model's own export\n * metadata and picks. An Ultralytics classification head gets\n * `\"ultralytics\"`; anything else gets `\"imagenet\"`.\n * - `\"imagenet\"` subtracts the ImageNet mean and divides by the ImageNet\n * deviation — the torchvision convention.\n * - `\"ultralytics\"` leaves the image in `[0, 1]`. Ultralytics' own classifier\n * applies no mean/std at all, so anything else feeds it images it never saw\n * in training.\n * - `\"none\"` is the same arithmetic as `\"ultralytics\"` — identity — under a\n * name that says \"this model wants raw `[0, 1]`\" rather than naming a vendor.\n */\nexport type Normalization = \"auto\" | \"imagenet\" | \"ultralytics\" | \"none\";\n\n/** Per-channel RGB mean of ImageNet, the torchvision preprocessing convention. */\nexport const IMAGENET_MEAN: readonly [number, number, number] = [0.485, 0.456, 0.406];\n\n/** Per-channel RGB standard deviation of ImageNet. */\nexport const IMAGENET_STD: readonly [number, number, number] = [0.229, 0.224, 0.225];\n\n/** Mean that leaves an image untouched — what an Ultralytics classifier expects. */\nexport const IDENTITY_MEAN: readonly [number, number, number] = [0, 0, 0];\n\n/** Deviation that leaves an image untouched — what an Ultralytics classifier expects. */\nexport const IDENTITY_STD: readonly [number, number, number] = [1, 1, 1];\n\n/** Name reported when the caller supplied `mean`/`std` directly. */\nexport const CUSTOM_NORMALIZATION = \"custom\";\n\nconst PRESETS: Readonly<\n Record<string, readonly [readonly [number, number, number], readonly [number, number, number]]>\n> = {\n imagenet: [IMAGENET_MEAN, IMAGENET_STD],\n ultralytics: [IDENTITY_MEAN, IDENTITY_STD],\n none: [IDENTITY_MEAN, IDENTITY_STD],\n};\n\n/** What {@link resolveNormalization} settled on. */\nexport interface ResolvedNormalization {\n /** The preset name, or `\"custom\"` when the caller supplied the values. */\n readonly name: string;\n /** Per-channel mean to subtract. */\n readonly mean: readonly [number, number, number];\n /** Per-channel deviation to divide by. */\n readonly std: readonly [number, number, number];\n}\n\n/**\n * Whether a metadata map came out of `YOLO(...).export(format=\"onnx\")`.\n *\n * Every Ultralytics export stamps `author` and `task` into its metadata, and the\n * pair is unambiguous: `\"Ultralytics\"` plus `\"classify\"` is a classification head\n * from that codebase and nothing else.\n *\n * @param metadata The model's custom metadata map.\n */\nexport function isUltralyticsClassifier(metadata: Readonly<Record<string, string>>): boolean {\n return (\n (metadata.author ?? \"\").trim().toLowerCase() === \"ultralytics\" &&\n (metadata.task ?? \"\").trim().toLowerCase() === \"classify\"\n );\n}\n\n/**\n * Settle which `mean`/`std` to apply, and what to call the choice.\n *\n * Explicit `mean`/`std` always win — they are the escape hatch for a model whose\n * preprocessing neither preset describes. Anything they leave open falls back to\n * the preset, so passing only a `mean` does not silently reset the deviation\n * to 1.\n *\n * Warns (via `console.warn`) when the model is an Ultralytics export and the\n * supplied values are not the identity it was trained with. Nothing fails in\n * that case: the prediction has the right shape and is simply less accurate,\n * which is exactly why it is worth saying out loud.\n *\n * @param metadata The model's custom metadata map, read to detect the family.\n * @param options The preset asked for, plus any explicit `mean`/`std`.\n * @throws {RangeError} If `normalization` is not a known preset, or names one\n * while `mean`/`std` are also supplied — two answers to the same question.\n */\nexport function resolveNormalization(\n metadata: Readonly<Record<string, string>>,\n options: {\n readonly normalization?: Normalization;\n readonly mean?: readonly [number, number, number];\n readonly std?: readonly [number, number, number];\n } = {},\n): ResolvedNormalization {\n const normalization = options.normalization ?? \"auto\";\n const explicit = options.mean !== undefined || options.std !== undefined;\n\n if (normalization !== \"auto\" && PRESETS[normalization] === undefined) {\n throw new RangeError(\n `normalization must be one of 'auto', 'imagenet', 'ultralytics', 'none'; ` +\n `got ${JSON.stringify(normalization)}.`,\n );\n }\n if (explicit && normalization !== \"auto\") {\n throw new RangeError(\n `Pass either normalization=${JSON.stringify(normalization)} or explicit mean/std, not both.`,\n );\n }\n\n const ultralytics = isUltralyticsClassifier(metadata);\n const preset =\n normalization === \"auto\" ? (ultralytics ? \"ultralytics\" : \"imagenet\") : normalization;\n const [presetMean, presetStd] = PRESETS[preset] as readonly [\n readonly [number, number, number],\n readonly [number, number, number],\n ];\n\n if (!explicit) {\n return { name: preset, mean: presetMean, std: presetStd };\n }\n\n const mean = options.mean ?? presetMean;\n const std = options.std ?? presetStd;\n if (ultralytics && !(isIdentity(mean, IDENTITY_MEAN) && isIdentity(std, IDENTITY_STD))) {\n console.warn(\n \"The classifier is an Ultralytics export, whose classification head is trained on raw \" +\n `[0, 1] images, but mean=${JSON.stringify(mean)} / std=${JSON.stringify(std)} was ` +\n \"requested. It will be fed images normalized in a way it never saw in training, which \" +\n \"degrades accuracy without raising anything. Drop mean/std to let normalization='auto' \" +\n \"pick the identity.\",\n );\n }\n return { name: CUSTOM_NORMALIZATION, mean, std };\n}\n\n/**\n * Whether two channel triples are equal.\n *\n * @param value The triple to check.\n * @param reference The triple to compare against.\n */\nfunction isIdentity(\n value: readonly [number, number, number],\n reference: readonly [number, number, number],\n): boolean {\n return value.every((entry, index) => entry === reference[index]);\n}\n"],"mappings":"AAmCA,IAAa,EAAmD,CAAC,KAAO,KAAO,IAAK,EAGvE,EAAkD,CAAC,KAAO,KAAO,IAAK,EAGtE,EAAmD,CAAC,EAAG,EAAG,CAAC,EAG3D,EAAkD,CAAC,EAAG,EAAG,CAAC,EAG1D,EAAuB,SAE9B,EAEF,CACA,SAAU,CAAC,EAAe,CAAY,EACtC,YAAa,CAAC,EAAe,CAAY,EACzC,KAAM,CAAC,EAAe,CAAY,CACtC,EAqBA,SAAgB,EAAwB,EAAqD,CACzF,OACK,EAAS,QAAU,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,IAAM,gBAChD,EAAS,MAAQ,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,IAAM,UAEvD,CAoBA,SAAgB,EACZ,EACA,EAII,CAAC,EACgB,CACrB,IAAM,EAAgB,EAAQ,eAAiB,OACzC,EAAW,EAAQ,OAAS,IAAA,IAAa,EAAQ,MAAQ,IAAA,GAE/D,GAAI,IAAkB,QAAU,EAAQ,KAAmB,IAAA,GACvD,MAAU,WACN,+EACW,KAAK,UAAU,CAAa,EAAE,EAC7C,EAEJ,GAAI,GAAY,IAAkB,OAC9B,MAAU,WACN,6BAA6B,KAAK,UAAU,CAAa,EAAE,iCAC/D,EAGJ,IAAM,EAAc,EAAwB,CAAQ,EAC9C,EACF,IAAkB,OAAU,EAAc,cAAgB,WAAc,EACtE,CAAC,EAAY,GAAa,EAAQ,GAKxC,GAAI,CAAC,EACD,MAAO,CAAE,KAAM,EAAQ,KAAM,EAAY,IAAK,CAAU,EAG5D,IAAM,EAAO,EAAQ,MAAQ,EACvB,EAAM,EAAQ,KAAO,EAU3B,OATI,GAAe,EAAE,EAAW,EAAM,CAAa,GAAK,EAAW,EAAK,CAAY,IAChF,QAAQ,KACJ,gHAC+B,KAAK,UAAU,CAAI,EAAE,SAAS,KAAK,UAAU,CAAG,EAAE,mMAIrF,EAEG,CAAE,KAAM,EAAsB,OAAM,KAAI,CACnD,CAQA,SAAS,EACL,EACA,EACO,CACP,OAAO,EAAM,OAAO,EAAO,IAAU,IAAU,EAAU,EAAM,CACnE"}
@@ -0,0 +1,49 @@
1
+ //#region src/vision/normalization.ts
2
+ var e = [
3
+ .485,
4
+ .456,
5
+ .406
6
+ ], t = [
7
+ .229,
8
+ .224,
9
+ .225
10
+ ], n = [
11
+ 0,
12
+ 0,
13
+ 0
14
+ ], r = [
15
+ 1,
16
+ 1,
17
+ 1
18
+ ], i = "custom", a = {
19
+ imagenet: [e, t],
20
+ ultralytics: [n, r],
21
+ none: [n, r]
22
+ };
23
+ function o(e) {
24
+ return (e.author ?? "").trim().toLowerCase() === "ultralytics" && (e.task ?? "").trim().toLowerCase() === "classify";
25
+ }
26
+ function s(e, t = {}) {
27
+ let s = t.normalization ?? "auto", l = t.mean !== void 0 || t.std !== void 0;
28
+ if (s !== "auto" && a[s] === void 0) throw RangeError(`normalization must be one of 'auto', 'imagenet', 'ultralytics', 'none'; got ${JSON.stringify(s)}.`);
29
+ if (l && s !== "auto") throw RangeError(`Pass either normalization=${JSON.stringify(s)} or explicit mean/std, not both.`);
30
+ let u = o(e), d = s === "auto" ? u ? "ultralytics" : "imagenet" : s, [f, p] = a[d];
31
+ if (!l) return {
32
+ name: d,
33
+ mean: f,
34
+ std: p
35
+ };
36
+ let m = t.mean ?? f, h = t.std ?? p;
37
+ return u && !(c(m, n) && c(h, r)) && console.warn(`The classifier is an Ultralytics export, whose classification head is trained on raw [0, 1] images, but mean=${JSON.stringify(m)} / std=${JSON.stringify(h)} was requested. It will be fed images normalized in a way it never saw in training, which degrades accuracy without raising anything. Drop mean/std to let normalization='auto' pick the identity.`), {
38
+ name: i,
39
+ mean: m,
40
+ std: h
41
+ };
42
+ }
43
+ function c(e, t) {
44
+ return e.every((e, n) => e === t[n]);
45
+ }
46
+ //#endregion
47
+ export { i as CUSTOM_NORMALIZATION, n as IDENTITY_MEAN, r as IDENTITY_STD, e as IMAGENET_MEAN, t as IMAGENET_STD, o as isUltralyticsClassifier, s as resolveNormalization };
48
+
49
+ //# sourceMappingURL=normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.js","names":[],"sources":["../../src/vision/normalization.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * Which preprocessing a classifier expects its input to have had.\n *\n * A classifier is trained on a specific tensor, and feeding it a differently\n * prepared one degrades it silently — no exception, no warning, just worse\n * predictions. The two families this SDK sees most disagree completely:\n * torchvision-style models want the ImageNet mean and deviation subtracted and\n * divided out, while an Ultralytics classification head consumes raw `[0, 1]`.\n *\n * Guessing wrong is not detectable from the outside, but it is not a guess: an\n * Ultralytics export stamps `author` and `task` into its own metadata, and every\n * task in this SDK already reads that map for the class names.\n *\n * Mirrors `ort_vision_sdk.normalization` in the Python SDK; the two must agree,\n * because the same model file is driven by both.\n */\n\n/**\n * Which preprocessing the classifier expects its input to have had.\n *\n * - `\"auto\"` (the default wherever it is accepted) reads the model's own export\n * metadata and picks. An Ultralytics classification head gets\n * `\"ultralytics\"`; anything else gets `\"imagenet\"`.\n * - `\"imagenet\"` subtracts the ImageNet mean and divides by the ImageNet\n * deviation — the torchvision convention.\n * - `\"ultralytics\"` leaves the image in `[0, 1]`. Ultralytics' own classifier\n * applies no mean/std at all, so anything else feeds it images it never saw\n * in training.\n * - `\"none\"` is the same arithmetic as `\"ultralytics\"` — identity — under a\n * name that says \"this model wants raw `[0, 1]`\" rather than naming a vendor.\n */\nexport type Normalization = \"auto\" | \"imagenet\" | \"ultralytics\" | \"none\";\n\n/** Per-channel RGB mean of ImageNet, the torchvision preprocessing convention. */\nexport const IMAGENET_MEAN: readonly [number, number, number] = [0.485, 0.456, 0.406];\n\n/** Per-channel RGB standard deviation of ImageNet. */\nexport const IMAGENET_STD: readonly [number, number, number] = [0.229, 0.224, 0.225];\n\n/** Mean that leaves an image untouched — what an Ultralytics classifier expects. */\nexport const IDENTITY_MEAN: readonly [number, number, number] = [0, 0, 0];\n\n/** Deviation that leaves an image untouched — what an Ultralytics classifier expects. */\nexport const IDENTITY_STD: readonly [number, number, number] = [1, 1, 1];\n\n/** Name reported when the caller supplied `mean`/`std` directly. */\nexport const CUSTOM_NORMALIZATION = \"custom\";\n\nconst PRESETS: Readonly<\n Record<string, readonly [readonly [number, number, number], readonly [number, number, number]]>\n> = {\n imagenet: [IMAGENET_MEAN, IMAGENET_STD],\n ultralytics: [IDENTITY_MEAN, IDENTITY_STD],\n none: [IDENTITY_MEAN, IDENTITY_STD],\n};\n\n/** What {@link resolveNormalization} settled on. */\nexport interface ResolvedNormalization {\n /** The preset name, or `\"custom\"` when the caller supplied the values. */\n readonly name: string;\n /** Per-channel mean to subtract. */\n readonly mean: readonly [number, number, number];\n /** Per-channel deviation to divide by. */\n readonly std: readonly [number, number, number];\n}\n\n/**\n * Whether a metadata map came out of `YOLO(...).export(format=\"onnx\")`.\n *\n * Every Ultralytics export stamps `author` and `task` into its metadata, and the\n * pair is unambiguous: `\"Ultralytics\"` plus `\"classify\"` is a classification head\n * from that codebase and nothing else.\n *\n * @param metadata The model's custom metadata map.\n */\nexport function isUltralyticsClassifier(metadata: Readonly<Record<string, string>>): boolean {\n return (\n (metadata.author ?? \"\").trim().toLowerCase() === \"ultralytics\" &&\n (metadata.task ?? \"\").trim().toLowerCase() === \"classify\"\n );\n}\n\n/**\n * Settle which `mean`/`std` to apply, and what to call the choice.\n *\n * Explicit `mean`/`std` always win — they are the escape hatch for a model whose\n * preprocessing neither preset describes. Anything they leave open falls back to\n * the preset, so passing only a `mean` does not silently reset the deviation\n * to 1.\n *\n * Warns (via `console.warn`) when the model is an Ultralytics export and the\n * supplied values are not the identity it was trained with. Nothing fails in\n * that case: the prediction has the right shape and is simply less accurate,\n * which is exactly why it is worth saying out loud.\n *\n * @param metadata The model's custom metadata map, read to detect the family.\n * @param options The preset asked for, plus any explicit `mean`/`std`.\n * @throws {RangeError} If `normalization` is not a known preset, or names one\n * while `mean`/`std` are also supplied — two answers to the same question.\n */\nexport function resolveNormalization(\n metadata: Readonly<Record<string, string>>,\n options: {\n readonly normalization?: Normalization;\n readonly mean?: readonly [number, number, number];\n readonly std?: readonly [number, number, number];\n } = {},\n): ResolvedNormalization {\n const normalization = options.normalization ?? \"auto\";\n const explicit = options.mean !== undefined || options.std !== undefined;\n\n if (normalization !== \"auto\" && PRESETS[normalization] === undefined) {\n throw new RangeError(\n `normalization must be one of 'auto', 'imagenet', 'ultralytics', 'none'; ` +\n `got ${JSON.stringify(normalization)}.`,\n );\n }\n if (explicit && normalization !== \"auto\") {\n throw new RangeError(\n `Pass either normalization=${JSON.stringify(normalization)} or explicit mean/std, not both.`,\n );\n }\n\n const ultralytics = isUltralyticsClassifier(metadata);\n const preset =\n normalization === \"auto\" ? (ultralytics ? \"ultralytics\" : \"imagenet\") : normalization;\n const [presetMean, presetStd] = PRESETS[preset] as readonly [\n readonly [number, number, number],\n readonly [number, number, number],\n ];\n\n if (!explicit) {\n return { name: preset, mean: presetMean, std: presetStd };\n }\n\n const mean = options.mean ?? presetMean;\n const std = options.std ?? presetStd;\n if (ultralytics && !(isIdentity(mean, IDENTITY_MEAN) && isIdentity(std, IDENTITY_STD))) {\n console.warn(\n \"The classifier is an Ultralytics export, whose classification head is trained on raw \" +\n `[0, 1] images, but mean=${JSON.stringify(mean)} / std=${JSON.stringify(std)} was ` +\n \"requested. It will be fed images normalized in a way it never saw in training, which \" +\n \"degrades accuracy without raising anything. Drop mean/std to let normalization='auto' \" +\n \"pick the identity.\",\n );\n }\n return { name: CUSTOM_NORMALIZATION, mean, std };\n}\n\n/**\n * Whether two channel triples are equal.\n *\n * @param value The triple to check.\n * @param reference The triple to compare against.\n */\nfunction isIdentity(\n value: readonly [number, number, number],\n reference: readonly [number, number, number],\n): boolean {\n return value.every((entry, index) => entry === reference[index]);\n}\n"],"mappings":";AAmCA,IAAa,IAAmD;CAAC;CAAO;CAAO;AAAK,GAGvE,IAAkD;CAAC;CAAO;CAAO;AAAK,GAGtE,IAAmD;CAAC;CAAG;CAAG;AAAC,GAG3D,IAAkD;CAAC;CAAG;CAAG;AAAC,GAG1D,IAAuB,UAE9B,IAEF;CACA,UAAU,CAAC,GAAe,CAAY;CACtC,aAAa,CAAC,GAAe,CAAY;CACzC,MAAM,CAAC,GAAe,CAAY;AACtC;AAqBA,SAAgB,EAAwB,GAAqD;CACzF,QACK,EAAS,UAAU,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,MAAM,kBAChD,EAAS,QAAQ,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,MAAM;AAEvD;AAoBA,SAAgB,EACZ,GACA,IAII,CAAC,GACgB;CACrB,IAAM,IAAgB,EAAQ,iBAAiB,QACzC,IAAW,EAAQ,SAAS,KAAA,KAAa,EAAQ,QAAQ,KAAA;CAE/D,IAAI,MAAkB,UAAU,EAAQ,OAAmB,KAAA,GACvD,MAAU,WACN,+EACW,KAAK,UAAU,CAAa,EAAE,EAC7C;CAEJ,IAAI,KAAY,MAAkB,QAC9B,MAAU,WACN,6BAA6B,KAAK,UAAU,CAAa,EAAE,iCAC/D;CAGJ,IAAM,IAAc,EAAwB,CAAQ,GAC9C,IACF,MAAkB,SAAU,IAAc,gBAAgB,aAAc,GACtE,CAAC,GAAY,KAAa,EAAQ;CAKxC,IAAI,CAAC,GACD,OAAO;EAAE,MAAM;EAAQ,MAAM;EAAY,KAAK;CAAU;CAG5D,IAAM,IAAO,EAAQ,QAAQ,GACvB,IAAM,EAAQ,OAAO;CAU3B,OATI,KAAe,EAAE,EAAW,GAAM,CAAa,KAAK,EAAW,GAAK,CAAY,MAChF,QAAQ,KACJ,gHAC+B,KAAK,UAAU,CAAI,EAAE,SAAS,KAAK,UAAU,CAAG,EAAE,mMAIrF,GAEG;EAAE,MAAM;EAAsB;EAAM;CAAI;AACnD;AAQA,SAAS,EACL,GACA,GACO;CACP,OAAO,EAAM,OAAO,GAAO,MAAU,MAAU,EAAU,EAAM;AACnE"}
@@ -1,2 +1,2 @@
1
- var e={load:0,preprocess:0,inference:0,postprocess:0},t=class{xyxy;cls;conf;origShape;constructor(e,t,n,r){this.xyxy=e,this.cls=t,this.conf=n,this.origShape=r}get length(){return this.cls.length}get shape(){return[this.length,4]}get xywh(){let e=new Float32Array(this.xyxy.length);for(let t=0;t<this.length;t++){let n=this.xyxy[t*4],r=this.xyxy[t*4+1],i=this.xyxy[t*4+2],a=this.xyxy[t*4+3];e[t*4]=(n+i)/2,e[t*4+1]=(r+a)/2,e[t*4+2]=i-n,e[t*4+3]=a-r}return e}get xyxyn(){let[e,t]=this.origShape,n=new Float32Array(this.xyxy.length);if(this.length===0||t<=0||e<=0)return n;for(let r=0;r<this.length;r++)n[r*4]=this.xyxy[r*4]/t,n[r*4+1]=this.xyxy[r*4+1]/e,n[r*4+2]=this.xyxy[r*4+2]/t,n[r*4+3]=this.xyxy[r*4+3]/e;return n}get xywhn(){let e=this.xywh,[t,n]=this.origShape;if(this.length===0||n<=0||t<=0)return e;for(let r=0;r<this.length;r++)e[r*4]=e[r*4]/n,e[r*4+1]=e[r*4+1]/t,e[r*4+2]=e[r*4+2]/n,e[r*4+3]=e[r*4+3]/t;return e}get data(){let e=new Float32Array(this.length*6);for(let t=0;t<this.length;t++)e[t*6]=this.xyxy[t*4],e[t*6+1]=this.xyxy[t*4+1],e[t*6+2]=this.xyxy[t*4+2],e[t*6+3]=this.xyxy[t*4+3],e[t*6+4]=this.conf[t],e[t*6+5]=this.cls[t];return e}},n=class{data;constructor(e){this.data=e}get length(){return this.data.length}get shape(){return[this.length]}get top1(){return this._top(1).indices[0]??0}get top1conf(){return this._top(1).values[0]??0}get top5(){return this._top(5).indices}get top5conf(){return this._top(5).values}_cache=new Map;_top(e){let t=this._cache.get(e);if(t)return t;let n=this._topK(e);return this._cache.set(e,n),n}_topK(e){let t=Math.min(e,this.data.length),n=new Int32Array(t),r=new Float32Array(t);if(t===0)return{indices:n,values:r};r.fill(-1/0);for(let e=0;e<this.data.length;e++){let i=this.data[e];if(i<=r[t-1])continue;let a=t-1;for(;a>0&&r[a-1]<i;)r[a]=r[a-1],n[a]=n[a-1],--a;r[a]=i,n[a]=e}return{indices:n,values:r}}},r=class{data;xyxy;origShape;constructor(e,t,n){this.data=e,this.xyxy=t,this.origShape=n}get length(){return this.data.length}get shape(){return[this.length]}[Symbol.iterator](){return this.data[Symbol.iterator]()}},i=class{boxes;detections;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o=null,s=e){this.boxes=t,this.detections=n,this.names=r,this.origImg=i,this.origShape=a,this.path=o,this.speed=s}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}},a=class{boxes;detections;names;classifierNames;origImg;origShape;path;speed;constructor(t,n,r,i,a,o,s=null,c=e){this.boxes=t,this.detections=n,this.names=r,this.classifierNames=i,this.origImg=a,this.origShape=o,this.path=s,this.speed=c}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}},o=class{probs;result;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o=null,s=e){this.probs=t,this.result=n,this.names=r,this.origImg=i,this.origShape=a,this.path=o,this.speed=s}get cls(){return this.probs.top1}get conf(){return this.probs.top1conf}get name(){return this.names[this.cls]??`class_${this.cls}`}get probabilities(){return this.result.probabilities}},s=class{boxes;masks;detections;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o,s=null,c=e){this.boxes=t,this.masks=n,this.detections=r,this.names=i,this.origImg=a,this.origShape=o,this.path=s,this.speed=c}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}};exports.Boxes=t,exports.ClassificationResults=o,exports.DetectClassifyResults=a,exports.DetectionResults=i,exports.Masks=r,exports.Probs=n,exports.SegmentationResults=s;
1
+ var e={load:0,preprocess:0,inference:0,postprocess:0},t=class{xyxy;cls;conf;origShape;constructor(e,t,n,r){this.xyxy=e,this.cls=t,this.conf=n,this.origShape=r}get length(){return this.cls.length}get shape(){return[this.length,4]}get xywh(){let e=new Float32Array(this.xyxy.length);for(let t=0;t<this.length;t++){let n=this.xyxy[t*4],r=this.xyxy[t*4+1],i=this.xyxy[t*4+2],a=this.xyxy[t*4+3];e[t*4]=(n+i)/2,e[t*4+1]=(r+a)/2,e[t*4+2]=i-n,e[t*4+3]=a-r}return e}get xyxyn(){let[e,t]=this.origShape,n=new Float32Array(this.xyxy.length);if(this.length===0||t<=0||e<=0)return n;for(let r=0;r<this.length;r++)n[r*4]=this.xyxy[r*4]/t,n[r*4+1]=this.xyxy[r*4+1]/e,n[r*4+2]=this.xyxy[r*4+2]/t,n[r*4+3]=this.xyxy[r*4+3]/e;return n}get xywhn(){let e=this.xywh,[t,n]=this.origShape;if(this.length===0||n<=0||t<=0)return e;for(let r=0;r<this.length;r++)e[r*4]=e[r*4]/n,e[r*4+1]=e[r*4+1]/t,e[r*4+2]=e[r*4+2]/n,e[r*4+3]=e[r*4+3]/t;return e}get data(){let e=new Float32Array(this.length*6);for(let t=0;t<this.length;t++)e[t*6]=this.xyxy[t*4],e[t*6+1]=this.xyxy[t*4+1],e[t*6+2]=this.xyxy[t*4+2],e[t*6+3]=this.xyxy[t*4+3],e[t*6+4]=this.conf[t],e[t*6+5]=this.cls[t];return e}},n=class{data;constructor(e){this.data=e}get length(){return this.data.length}get shape(){return[this.length]}get top1(){if(this.data.length===0)return 0;let e=0,t=this.data[0];for(let n=1;n<this.data.length;n++){let r=this.data[n];r>t&&(e=n,t=r)}return e}get top1conf(){return this.data.length===0?0:this.data[this.top1]}get top5(){return this._top(5).indices}get top5conf(){return this._top(5).values}_cache=new Map;_top(e){let t=this._cache.get(e);if(t)return t;let n=this._topK(e);return this._cache.set(e,n),n}_topK(e){let t=Math.min(e,this.data.length),n=new Int32Array(t),r=new Float32Array(t);if(t===0)return{indices:n,values:r};r.fill(-1/0);for(let e=0;e<this.data.length;e++){let i=this.data[e];if(i<=r[t-1])continue;let a=t-1;for(;a>0&&r[a-1]<i;)r[a]=r[a-1],n[a]=n[a-1],--a;r[a]=i,n[a]=e}return{indices:n,values:r}}},r=class{data;xyxy;origShape;constructor(e,t,n){this.data=e,this.xyxy=t,this.origShape=n}get length(){return this.data.length}get shape(){return[this.length]}[Symbol.iterator](){return this.data[Symbol.iterator]()}},i=class{boxes;detections;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o=null,s=e){this.boxes=t,this.detections=n,this.names=r,this.origImg=i,this.origShape=a,this.path=o,this.speed=s}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}},a=class{boxes;detections;names;classifierNames;origImg;origShape;path;speed;constructor(t,n,r,i,a,o,s=null,c=e){this.boxes=t,this.detections=n,this.names=r,this.classifierNames=i,this.origImg=a,this.origShape=o,this.path=s,this.speed=c}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}},o=class{probs;result;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o=null,s=e){this.probs=t,this.result=n,this.names=r,this.origImg=i,this.origShape=a,this.path=o,this.speed=s}get cls(){return this.probs.top1}get conf(){return this.probs.top1conf}get name(){return this.names[this.cls]??`class_${this.cls}`}get probabilities(){return this.result.probabilities}},s=class{boxes;masks;detections;names;origImg;origShape;path;speed;constructor(t,n,r,i,a,o,s=null,c=e){this.boxes=t,this.masks=n,this.detections=r,this.names=i,this.origImg=a,this.origShape=o,this.path=s,this.speed=c}get length(){return this.detections.length}get(e){return this.detections[e]}[Symbol.iterator](){return this.detections[Symbol.iterator]()}};exports.Boxes=t,exports.ClassificationResults=o,exports.DetectClassifyResults=a,exports.DetectionResults=i,exports.Masks=r,exports.Probs=n,exports.SegmentationResults=s;
2
2
  //# sourceMappingURL=results.cjs.map