react-native-executorch 0.9.1 → 0.9.3

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 (47) hide show
  1. package/android/build.gradle +1 -0
  2. package/android/consumer-proguard-rules.pro +51 -0
  3. package/android/src/main/cpp/ETInstallerModule.cpp +4 -3
  4. package/android/src/main/cpp/ETInstallerModule.h +1 -1
  5. package/android/src/main/java/com/swmansion/rnexecutorch/ETInstaller.kt +2 -2
  6. package/common/rnexecutorch/RnExecutorchInstaller.cpp +6 -1
  7. package/common/rnexecutorch/RnExecutorchInstaller.h +2 -1
  8. package/common/runner/encoders/vision_encoder.cpp +13 -4
  9. package/common/runner/encoders/vision_encoder.h +15 -2
  10. package/common/runner/sampler.cpp +52 -41
  11. package/ios/PrivacyInfo.xcprivacy +36 -0
  12. package/ios/RnExecutorch/ETInstaller.mm +3 -1
  13. package/lib/module/constants/modelRegistry.js +29 -1
  14. package/lib/module/constants/modelRegistry.js.map +1 -1
  15. package/lib/module/constants/modelUrls.js +19 -0
  16. package/lib/module/constants/modelUrls.js.map +1 -1
  17. package/lib/module/index.js +1 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/modules/computer_vision/PoseEstimationModule.js +13 -1
  20. package/lib/module/modules/computer_vision/PoseEstimationModule.js.map +1 -1
  21. package/lib/module/types/poseEstimation.js.map +1 -1
  22. package/lib/module/utils/ResourceFetcher.js +3 -1
  23. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  24. package/lib/module/utils/ResourceFetcherUtils.js +20 -15
  25. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
  26. package/lib/typescript/constants/modelRegistry.d.ts +10 -0
  27. package/lib/typescript/constants/modelRegistry.d.ts.map +1 -1
  28. package/lib/typescript/constants/modelUrls.d.ts +12 -0
  29. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  30. package/lib/typescript/index.d.ts +1 -0
  31. package/lib/typescript/index.d.ts.map +1 -1
  32. package/lib/typescript/modules/computer_vision/PoseEstimationModule.d.ts +6 -0
  33. package/lib/typescript/modules/computer_vision/PoseEstimationModule.d.ts.map +1 -1
  34. package/lib/typescript/types/poseEstimation.d.ts +3 -0
  35. package/lib/typescript/types/poseEstimation.d.ts.map +1 -1
  36. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  37. package/lib/typescript/utils/ResourceFetcherUtils.d.ts +1 -0
  38. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/react-native-executorch.podspec +4 -0
  41. package/src/constants/modelRegistry.ts +28 -0
  42. package/src/constants/modelUrls.ts +22 -0
  43. package/src/index.ts +4 -1
  44. package/src/modules/computer_vision/PoseEstimationModule.ts +12 -0
  45. package/src/types/poseEstimation.ts +10 -4
  46. package/src/utils/ResourceFetcher.ts +3 -1
  47. package/src/utils/ResourceFetcherUtils.ts +18 -16
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceFetcherUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/ResourceFetcherUtils.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,oBAAY,SAAS;IACnB;;OAEG;IACH,EAAE,MAAM;IAER;;OAEG;IACH,eAAe,MAAM;CACtB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB;;OAEG;IACH,OAAO,IAAA;IAEP;;OAEG;IACH,MAAM,IAAA;CACP;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB;;OAEG;IACH,MAAM,IAAA;IAEN;;OAEG;IACH,UAAU,IAAA;IAEV;;OAEG;IACH,iBAAiB,IAAA;IAEjB;;OAEG;IACH,aAAa,IAAA;IAEb;;OAEG;IACH,WAAW,IAAA;CACZ;AAED;;;GAGG;AACH,yBAAiB,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,UAE3C;IAED;;;;OAIG;IACH,SAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,UAU5C;IAED;;;;;;;;OAQG;IACH,SAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,wBAAwB,EAAE,MAAM,EAChC,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,IAEvC,UAAU,MAAM,UAoBzB;IAED;;;;OAIG;IACH,SAAsB,iCAAiC,CAAC,GAAG,EAAE,MAAM,iBAMlE;IAED;;;;OAIG;IACH,SAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAK7C;IAaD,SAAgB,UAAU,IAAI,OAAO,CAEpC;IAYD;;;OAGG;IACH,SAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,QAa/C;IAED;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAI7C;CACF"}
1
+ {"version":3,"file":"ResourceFetcherUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/ResourceFetcherUtils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,oBAAY,SAAS;IACnB;;OAEG;IACH,EAAE,MAAM;IAER;;OAEG;IACH,eAAe,MAAM;CACtB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB;;OAEG;IACH,OAAO,IAAA;IAEP;;OAEG;IACH,MAAM,IAAA;CACP;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB;;OAEG;IACH,MAAM,IAAA;IAEN;;OAEG;IACH,UAAU,IAAA;IAEV;;OAEG;IACH,iBAAiB,IAAA;IAEjB;;OAEG;IACH,aAAa,IAAA;IAEb;;OAEG;IACH,WAAW,IAAA;CACZ;AAED;;;GAGG;AACH,yBAAiB,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,UAE3C;IAED;;;;OAIG;IACH,SAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,UAU5C;IAED;;;;;;;;OAQG;IACH,SAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,wBAAwB,EAAE,MAAM,EAChC,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,IAEvC,UAAU,MAAM,UAoBzB;IAED;;;;OAIG;IACH,SAAsB,iCAAiC,CAAC,GAAG,EAAE,MAAM,iBAMlE;IAED;;;;OAIG;IACH,SAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAK7C;IAaD,SAAgB,UAAU,IAAI,OAAO,CAEpC;IAED,SAAgB,WAAW,IAAI,MAAM,CAEpC;IAYD;;;OAGG;IACH,SAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,QAa/C;IAED;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAI7C;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-executorch",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "An easy way to run AI models in React Native with ExecuTorch",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -60,6 +60,10 @@ Pod::Spec.new do |s|
60
60
  "third-party/common/phonemis/src/**/*.{cpp,hpp,h}",
61
61
  ]
62
62
 
63
+ s.resource_bundles = {
64
+ 'RnExecutorchPrivacyInfo' => ['ios/PrivacyInfo.xcprivacy'],
65
+ }
66
+
63
67
  s.libraries = "z"
64
68
  s.ios.vendored_frameworks = "third-party/ios/ExecutorchLib.xcframework"
65
69
 
@@ -276,6 +276,31 @@ const RF_DETR_NANO_SEG_VARIANTS = {
276
276
  },
277
277
  };
278
278
 
279
+ // RF-DETR Keypoint (pose estimation) — BETA preview. Configs mirror the
280
+ // All three backends ship fp32
281
+ // (non-quantized); this entry may be re-exported under a different constant
282
+ // once more RF-DETR keypoint weights are released.
283
+ const RF_DETR_KEYPOINT_PREVIEW_VARIANTS = {
284
+ xnnpack: {
285
+ base: {
286
+ modelName: 'rfdetr-keypoint-preview' as const,
287
+ modelSource: M.RF_DETR_KEYPOINT_PREVIEW_XNNPACK_FP32_MODEL,
288
+ },
289
+ },
290
+ coreml: {
291
+ base: {
292
+ modelName: 'rfdetr-keypoint-preview' as const,
293
+ modelSource: M.RF_DETR_KEYPOINT_PREVIEW_COREML_FP32_MODEL,
294
+ },
295
+ },
296
+ mlx: {
297
+ base: {
298
+ modelName: 'rfdetr-keypoint-preview' as const,
299
+ modelSource: M.RF_DETR_KEYPOINT_PREVIEW_MLX_FP32_MODEL,
300
+ },
301
+ },
302
+ };
303
+
279
304
  const FASTSAM_S_VARIANTS = {
280
305
  xnnpack: {
281
306
  base: {
@@ -553,6 +578,9 @@ export const models = {
553
578
  },
554
579
  pose_estimation: {
555
580
  yolo26n: base(M.YOLO26N_POSE),
581
+ // BETA preview — may be re-exported under a different constant once a
582
+ // stable RF-DETR keypoint model ships.
583
+ rfdetr_keypoint_preview: variant(RF_DETR_KEYPOINT_PREVIEW_VARIANTS),
556
584
  },
557
585
  semantic_segmentation: {
558
586
  deeplab_v3_resnet50: pair(
@@ -731,6 +731,28 @@ export const YOLO26N_POSE = {
731
731
  modelSource: YOLO26N_POSE_MODEL,
732
732
  } as const;
733
733
 
734
+ // RF-DETR Keypoint (pose estimation) — BETA preview.
735
+ // NOTE: served from the `preview/` path under PREVIOUS_VERSION_TAG (shipping as
736
+ // part of a patch release). This export is a preview and may be re-exported
737
+ // under a different constant once a stable version ships.
738
+ export const RF_DETR_KEYPOINT_PREVIEW_XNNPACK_FP32_MODEL = `${URL_PREFIX}-rfdetr-keypoint/${VERSION_TAG}/preview/xnnpack/rfdetr_keypoint_preview_xnnpack_fp32.pte`;
739
+ export const RF_DETR_KEYPOINT_PREVIEW_COREML_FP32_MODEL = `${URL_PREFIX}-rfdetr-keypoint/${VERSION_TAG}/preview/coreml/rfdetr_keypoint_preview_coreml_fp32.pte`;
740
+ export const RF_DETR_KEYPOINT_PREVIEW_MLX_FP32_MODEL = `${URL_PREFIX}-rfdetr-keypoint/${VERSION_TAG}/preview/mlx/rfdetr_keypoint_preview_mlx_fp32.pte`;
741
+ const RF_DETR_KEYPOINT_PREVIEW_MODEL =
742
+ Platform.OS === 'ios'
743
+ ? RF_DETR_KEYPOINT_PREVIEW_COREML_FP32_MODEL
744
+ : RF_DETR_KEYPOINT_PREVIEW_XNNPACK_FP32_MODEL;
745
+
746
+ /**
747
+ * @category Models - Pose Estimation
748
+ * @beta Preview export — may be re-exported under a different constant once a
749
+ * stable RF-DETR keypoint model ships.
750
+ */
751
+ export const RF_DETR_KEYPOINT_PREVIEW = {
752
+ modelName: 'rfdetr-keypoint-preview',
753
+ modelSource: RF_DETR_KEYPOINT_PREVIEW_MODEL,
754
+ } as const;
755
+
734
756
  // Style transfer
735
757
  /**
736
758
  * Builds the four `(backend, precision)` URLs for a single style-transfer style.
package/src/index.ts CHANGED
@@ -120,6 +120,8 @@ declare global {
120
120
  ) => Promise<any>;
121
121
  // eslint-disable-next-line camelcase
122
122
  var __rne_isEmulator: boolean;
123
+ // eslint-disable-next-line camelcase
124
+ var __rne_bundleId: string;
123
125
  }
124
126
  // eslint-disable no-var
125
127
 
@@ -142,7 +144,8 @@ if (
142
144
  global.loadTextToSpeechKokoro == null ||
143
145
  global.loadOCR == null ||
144
146
  global.loadVerticalOCR == null ||
145
- global.__rne_isEmulator == null
147
+ global.__rne_isEmulator == null ||
148
+ global.__rne_bundleId == null
146
149
  ) {
147
150
  if (!ETInstallerNativeModule) {
148
151
  throw new Error(
@@ -29,8 +29,20 @@ const YOLO_POSE_CONFIG = {
29
29
  defaultKeypointThreshold: 0.5,
30
30
  } satisfies PoseEstimationConfig<typeof CocoKeypoint>;
31
31
 
32
+ // RF-DETR keypoint preview (BETA). Unlike yolo26n-pose's multi-method
33
+ // `forward_<size>` export, this ships a single `forward` method — omitting
34
+ // availableInputSizes/defaultInputSize makes forward() dispatch to plain
35
+ // `forward`. May be renamed once a stable model ships.
36
+ const RFDETR_KEYPOINT_CONFIG = {
37
+ keypointMap: CocoKeypoint,
38
+ preprocessorConfig: undefined,
39
+ defaultDetectionThreshold: 0.5,
40
+ defaultKeypointThreshold: 0.5,
41
+ } satisfies PoseEstimationConfig<typeof CocoKeypoint>;
42
+
32
43
  const ModelConfigs = {
33
44
  'yolo26n-pose': YOLO_POSE_CONFIG,
45
+ 'rfdetr-keypoint-preview': RFDETR_KEYPOINT_CONFIG,
34
46
  } as const satisfies Record<
35
47
  PoseEstimationModelName,
36
48
  PoseEstimationConfig<LabelEnum>
@@ -62,10 +62,16 @@ export type PoseEstimationConfig<K extends LabelEnum> = {
62
62
  * Each model name maps to its required fields.
63
63
  * @category Types
64
64
  */
65
- export type PoseEstimationModelSources = {
66
- modelName: 'yolo26n-pose';
67
- modelSource: ResourceSource;
68
- };
65
+ export type PoseEstimationModelSources =
66
+ | {
67
+ modelName: 'yolo26n-pose';
68
+ modelSource: ResourceSource;
69
+ }
70
+ // RF-DETR keypoint preview (BETA) — may be renamed once a stable model ships.
71
+ | {
72
+ modelName: 'rfdetr-keypoint-preview';
73
+ modelSource: ResourceSource;
74
+ };
69
75
 
70
76
  /**
71
77
  * Union of all built-in pose estimation model names.
@@ -138,8 +138,10 @@ export class ResourceFetcher {
138
138
  * @remarks
139
139
  * **REQUIRED**: Used internally for reading configuration files (e.g., tokenizer configs).
140
140
  */
141
+ // Reference the class by name: `this` inside a static-field arrow gets
142
+ // rebound to module scope by Babel under RN's hermes transform profiles.
141
143
  readAsString: async (path: string) => {
142
- return this.getAdapter().readAsString(path);
144
+ return ResourceFetcher.getAdapter().readAsString(path);
143
145
  },
144
146
  };
145
147
  }
@@ -1,8 +1,6 @@
1
1
  import { getModelNameForUrl } from '../constants/modelUrls';
2
- import {
3
- DOWNLOAD_EVENT_ENDPOINT,
4
- LIB_VERSION,
5
- } from '../constants/resourceFetcher';
2
+ import { DOWNLOAD_EVENT_ENDPOINT } from '../constants/resourceFetcher';
3
+ import { Platform } from 'react-native';
6
4
  /**
7
5
  * Http status codes
8
6
  * @category Types
@@ -174,6 +172,10 @@ export namespace ResourceFetcherUtils {
174
172
  return global.__rne_isEmulator;
175
173
  }
176
174
 
175
+ export function getBundleId(): string {
176
+ return global.__rne_bundleId;
177
+ }
178
+
177
179
  function getModelNameFromUri(uri: string): string {
178
180
  const knownName = getModelNameForUrl(uri);
179
181
  if (knownName) {
@@ -189,18 +191,18 @@ export namespace ResourceFetcherUtils {
189
191
  * @param uri - The URI of the downloaded resource.
190
192
  */
191
193
  export function triggerDownloadEvent(uri: string) {
192
- try {
193
- fetch(DOWNLOAD_EVENT_ENDPOINT, {
194
- method: 'POST',
195
- headers: { 'Content-Type': 'application/json' },
196
- body: JSON.stringify({
197
- modelName: getModelNameFromUri(uri),
198
- countryCode: getCountryCode(),
199
- isEmulator: isEmulator(),
200
- libVersion: LIB_VERSION,
201
- }),
202
- });
203
- } catch (e) {}
194
+ fetch(DOWNLOAD_EVENT_ENDPOINT, {
195
+ method: 'POST',
196
+ headers: { 'Content-Type': 'application/json' },
197
+ body: JSON.stringify({
198
+ bundleId: getBundleId(),
199
+ countryCode: getCountryCode(),
200
+ isEmulator: isEmulator(),
201
+ libVersion: require('../../package.json').version,
202
+ modelName: getModelNameFromUri(uri),
203
+ system: Platform.OS,
204
+ }),
205
+ }).catch((_) => {});
204
206
  }
205
207
 
206
208
  /**