react-native-executorch 0.3.3 → 0.4.2
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.
- package/README.md +30 -13
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +1 -2
- package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +58 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +13 -49
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +51 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +86 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +3 -4
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +48 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +1 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +26 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +142 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +3 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/{StyleTransferModel.kt → styleTransfer/StyleTransferModel.kt} +2 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -8
- package/android/src/main/java/com/swmansion/rnexecutorch/{models/classification/Utils.kt → utils/Numerical.kt} +1 -1
- package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/RnExecutorch/Classification.mm +15 -18
- package/ios/RnExecutorch/ETModule.mm +6 -5
- package/ios/RnExecutorch/ImageSegmentation.h +5 -0
- package/ios/RnExecutorch/ImageSegmentation.mm +60 -0
- package/ios/RnExecutorch/LLM.mm +12 -53
- package/ios/RnExecutorch/OCR.mm +39 -43
- package/ios/RnExecutorch/ObjectDetection.mm +20 -20
- package/ios/RnExecutorch/SpeechToText.mm +6 -7
- package/ios/RnExecutorch/StyleTransfer.mm +16 -19
- package/ios/RnExecutorch/TextEmbeddings.h +5 -0
- package/ios/RnExecutorch/TextEmbeddings.mm +62 -0
- package/ios/RnExecutorch/Tokenizer.h +5 -0
- package/ios/RnExecutorch/Tokenizer.mm +83 -0
- package/ios/RnExecutorch/VerticalOCR.mm +36 -36
- package/ios/RnExecutorch/models/BaseModel.h +2 -5
- package/ios/RnExecutorch/models/BaseModel.mm +5 -15
- package/ios/RnExecutorch/models/classification/ClassificationModel.mm +2 -3
- package/ios/RnExecutorch/models/classification/Constants.mm +0 -1
- package/ios/RnExecutorch/models/image_segmentation/Constants.h +4 -0
- package/ios/RnExecutorch/models/image_segmentation/Constants.mm +8 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +10 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +146 -0
- package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +1 -2
- package/ios/RnExecutorch/models/ocr/Detector.h +0 -2
- package/ios/RnExecutorch/models/ocr/Detector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +5 -4
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +9 -26
- package/ios/RnExecutorch/models/ocr/Recognizer.mm +1 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -1
- package/ios/RnExecutorch/models/stt/Moonshine.mm +1 -6
- package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +7 -11
- package/ios/RnExecutorch/models/stt/Whisper.mm +0 -5
- package/ios/RnExecutorch/models/{StyleTransferModel.h → style_transfer/StyleTransferModel.h} +1 -1
- package/ios/RnExecutorch/models/{StyleTransferModel.mm → style_transfer/StyleTransferModel.mm} +2 -3
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +15 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +45 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +8 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +49 -0
- package/ios/RnExecutorch/utils/Conversions.h +15 -0
- package/ios/RnExecutorch/utils/ImageProcessor.h +0 -1
- package/ios/RnExecutorch/{models/classification/Utils.h → utils/Numerical.h} +0 -2
- package/ios/RnExecutorch/{models/classification/Utils.mm → utils/Numerical.mm} +0 -2
- package/ios/RnExecutorch/utils/ObjectDetectionUtils.mm +0 -2
- package/ios/RnExecutorch/utils/SFFT.mm +1 -1
- package/ios/RnExecutorch/utils/ScalarType.h +0 -2
- package/lib/module/Error.js +16 -2
- package/lib/module/Error.js.map +1 -1
- package/lib/module/constants/{llamaDefaults.js → llmDefaults.js} +7 -3
- package/lib/module/constants/llmDefaults.js.map +1 -0
- package/lib/module/constants/modelUrls.js +88 -27
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/constants/ocr/models.js +290 -0
- package/lib/module/constants/ocr/models.js.map +1 -0
- package/lib/module/constants/ocr/symbols.js +137 -2
- package/lib/module/constants/ocr/symbols.js.map +1 -1
- package/lib/module/constants/sttDefaults.js +50 -25
- package/lib/module/constants/sttDefaults.js.map +1 -1
- package/lib/module/controllers/LLMController.js +205 -0
- package/lib/module/controllers/LLMController.js.map +1 -0
- package/lib/module/controllers/OCRController.js +5 -10
- package/lib/module/controllers/OCRController.js.map +1 -1
- package/lib/module/controllers/SpeechToTextController.js +225 -122
- package/lib/module/controllers/SpeechToTextController.js.map +1 -1
- package/lib/module/controllers/VerticalOCRController.js +6 -10
- package/lib/module/controllers/VerticalOCRController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +8 -23
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +13 -0
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -0
- package/lib/module/hooks/computer_vision/useOCR.js +11 -6
- package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +8 -23
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +8 -23
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/computer_vision/useVerticalOCR.js +10 -7
- package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +8 -36
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +54 -63
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js +15 -11
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +14 -0
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js +54 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -0
- package/lib/module/hooks/useModule.js +18 -62
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +16 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +9 -10
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +8 -5
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +28 -0
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -0
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +8 -5
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +8 -5
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +8 -5
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +46 -27
- package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +8 -5
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +14 -0
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js +26 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -0
- package/lib/module/native/NativeClassification.js.map +1 -1
- package/lib/module/native/NativeImageSegmentation.js +5 -0
- package/lib/module/native/NativeImageSegmentation.js.map +1 -0
- package/lib/module/native/NativeLLM.js.map +1 -1
- package/lib/module/native/NativeTextEmbeddings.js +5 -0
- package/lib/module/native/NativeTextEmbeddings.js.map +1 -0
- package/lib/module/native/NativeTokenizer.js +5 -0
- package/lib/module/native/NativeTokenizer.js.map +1 -0
- package/lib/module/native/RnExecutorchModules.js +18 -113
- package/lib/module/native/RnExecutorchModules.js.map +1 -1
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/imageSegmentation.js +29 -0
- package/lib/module/types/imageSegmentation.js.map +1 -0
- package/lib/module/types/llm.js +7 -0
- package/lib/module/types/llm.js.map +1 -0
- package/lib/module/types/{object_detection.js → objectDetection.js} +1 -1
- package/lib/module/types/objectDetection.js.map +1 -0
- package/lib/module/types/ocr.js +2 -0
- package/lib/module/types/stt.js +82 -0
- package/lib/module/types/stt.js.map +1 -0
- package/lib/module/utils/ResourceFetcher.js +156 -0
- package/lib/module/utils/ResourceFetcher.js.map +1 -0
- package/lib/module/utils/llm.js +25 -0
- package/lib/module/utils/llm.js.map +1 -0
- package/lib/module/utils/stt.js +22 -0
- package/lib/module/utils/stt.js.map +1 -0
- package/lib/typescript/Error.d.ts +4 -1
- package/lib/typescript/Error.d.ts.map +1 -1
- package/lib/typescript/constants/{llamaDefaults.d.ts → llmDefaults.d.ts} +5 -5
- package/lib/typescript/constants/llmDefaults.d.ts.map +1 -0
- package/lib/typescript/constants/modelUrls.d.ts +74 -28
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/models.d.ts +285 -0
- package/lib/typescript/constants/ocr/models.d.ts.map +1 -0
- package/lib/typescript/constants/ocr/symbols.d.ts +73 -1
- package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
- package/lib/typescript/constants/sttDefaults.d.ts +8 -13
- package/lib/typescript/constants/sttDefaults.d.ts.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts +46 -0
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -0
- package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
- package/lib/typescript/controllers/SpeechToTextController.d.ts +30 -16
- package/lib/typescript/controllers/SpeechToTextController.d.ts.map +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts +5 -5
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +37 -0
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -4
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +4 -2
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts +5 -6
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -6
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +7 -3
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +13 -0
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +16 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -0
- package/lib/typescript/hooks/useModule.d.ts +11 -10
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +15 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +4 -5
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +7 -7
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +32 -0
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -0
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +4 -3
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +19 -5
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +7 -4
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +8 -0
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -0
- package/lib/typescript/native/NativeClassification.d.ts.map +1 -1
- package/lib/typescript/native/NativeImageSegmentation.d.ts +10 -0
- package/lib/typescript/native/NativeImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/native/NativeLLM.d.ts +3 -4
- package/lib/typescript/native/NativeLLM.d.ts.map +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts.map +1 -1
- package/lib/typescript/native/NativeSpeechToText.d.ts +2 -2
- package/lib/typescript/native/NativeSpeechToText.d.ts.map +1 -1
- package/lib/typescript/native/NativeTextEmbeddings.d.ts +8 -0
- package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/native/NativeTokenizer.d.ts +12 -0
- package/lib/typescript/native/NativeTokenizer.d.ts.map +1 -0
- package/lib/typescript/native/RnExecutorchModules.d.ts +18 -41
- package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
- package/lib/typescript/types/common.d.ts +1 -26
- package/lib/typescript/types/common.d.ts.map +1 -1
- package/lib/typescript/types/imageSegmentation.d.ts +25 -0
- package/lib/typescript/types/imageSegmentation.d.ts.map +1 -0
- package/lib/typescript/types/llm.d.ts +38 -0
- package/lib/typescript/types/llm.d.ts.map +1 -0
- package/lib/typescript/types/{object_detection.d.ts → objectDetection.d.ts} +1 -1
- package/lib/typescript/types/objectDetection.d.ts.map +1 -0
- package/lib/typescript/types/ocr.d.ts +2 -1
- package/lib/typescript/types/ocr.d.ts.map +1 -1
- package/lib/typescript/types/stt.d.ts +91 -0
- package/lib/typescript/types/stt.d.ts.map +1 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts +17 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -0
- package/lib/typescript/utils/llm.d.ts +3 -0
- package/lib/typescript/utils/llm.d.ts.map +1 -0
- package/lib/typescript/utils/stt.d.ts +2 -0
- package/lib/typescript/utils/stt.d.ts.map +1 -0
- package/package.json +13 -49
- package/react-native-executorch.podspec +1 -1
- package/src/Error.ts +16 -3
- package/src/constants/llmDefaults.ts +14 -0
- package/src/constants/modelUrls.ts +146 -39
- package/src/constants/ocr/models.ts +453 -0
- package/src/constants/ocr/symbols.ts +147 -3
- package/src/constants/sttDefaults.ts +55 -37
- package/src/controllers/LLMController.ts +286 -0
- package/src/controllers/OCRController.ts +14 -28
- package/src/controllers/SpeechToTextController.ts +318 -180
- package/src/controllers/VerticalOCRController.ts +17 -32
- package/src/hooks/computer_vision/useClassification.ts +11 -26
- package/src/hooks/computer_vision/useImageSegmentation.ts +18 -0
- package/src/hooks/computer_vision/useOCR.ts +17 -5
- package/src/hooks/computer_vision/useObjectDetection.ts +10 -24
- package/src/hooks/computer_vision/useStyleTransfer.ts +9 -25
- package/src/hooks/computer_vision/useVerticalOCR.ts +11 -4
- package/src/hooks/general/useExecutorchModule.ts +10 -50
- package/src/hooks/natural_language_processing/useLLM.ts +80 -97
- package/src/hooks/natural_language_processing/useSpeechToText.ts +39 -12
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +18 -0
- package/src/hooks/natural_language_processing/useTokenizer.ts +61 -0
- package/src/hooks/useModule.ts +32 -92
- package/src/index.tsx +16 -2
- package/src/modules/BaseModule.ts +16 -26
- package/src/modules/computer_vision/ClassificationModule.ts +13 -8
- package/src/modules/computer_vision/ImageSegmentationModule.ts +39 -0
- package/src/modules/computer_vision/ObjectDetectionModule.ts +13 -8
- package/src/modules/computer_vision/StyleTransferModule.ts +13 -8
- package/src/modules/general/ExecutorchModule.ts +11 -6
- package/src/modules/natural_language_processing/LLMModule.ts +64 -51
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +25 -10
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +18 -0
- package/src/modules/natural_language_processing/TokenizerModule.ts +34 -0
- package/src/native/NativeClassification.ts +0 -1
- package/src/native/NativeImageSegmentation.ts +14 -0
- package/src/native/NativeLLM.ts +3 -10
- package/src/native/NativeObjectDetection.ts +1 -1
- package/src/native/NativeSpeechToText.ts +2 -2
- package/src/native/NativeTextEmbeddings.ts +9 -0
- package/src/native/NativeTokenizer.ts +13 -0
- package/src/native/RnExecutorchModules.ts +54 -234
- package/src/types/common.ts +1 -44
- package/src/types/imageSegmentation.ts +25 -0
- package/src/types/llm.ts +57 -0
- package/src/types/ocr.ts +3 -1
- package/src/types/stt.ts +93 -0
- package/src/utils/ResourceFetcher.ts +196 -0
- package/src/utils/llm.ts +34 -0
- package/src/utils/stt.ts +28 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/llms/ConversationManager.kt +0 -68
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/_CodeSignature/CodeResources +0 -124
- package/ios/RnExecutorch/utils/llms/Constants.h +0 -6
- package/ios/RnExecutorch/utils/llms/Constants.mm +0 -23
- package/ios/RnExecutorch/utils/llms/ConversationManager.h +0 -26
- package/ios/RnExecutorch/utils/llms/ConversationManager.mm +0 -71
- package/lib/module/constants/llamaDefaults.js.map +0 -1
- package/lib/module/modules/computer_vision/BaseCVModule.js +0 -14
- package/lib/module/modules/computer_vision/BaseCVModule.js.map +0 -1
- package/lib/module/types/object_detection.js.map +0 -1
- package/lib/module/utils/fetchResource.js +0 -93
- package/lib/module/utils/fetchResource.js.map +0 -1
- package/lib/module/utils/listDownloadedResources.js +0 -13
- package/lib/module/utils/listDownloadedResources.js.map +0 -1
- package/lib/typescript/constants/llamaDefaults.d.ts.map +0 -1
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts +0 -9
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts.map +0 -1
- package/lib/typescript/types/object_detection.d.ts.map +0 -1
- package/lib/typescript/utils/fetchResource.d.ts +0 -3
- package/lib/typescript/utils/fetchResource.d.ts.map +0 -1
- package/lib/typescript/utils/listDownloadedResources.d.ts +0 -3
- package/lib/typescript/utils/listDownloadedResources.d.ts.map +0 -1
- package/src/constants/llamaDefaults.ts +0 -9
- package/src/modules/computer_vision/BaseCVModule.ts +0 -22
- package/src/utils/fetchResource.ts +0 -106
- package/src/utils/listDownloadedResources.ts +0 -12
- /package/src/types/{object_detection.ts → objectDetection.ts} +0 -0
|
@@ -1,62 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fetchResource } from '../../utils/fetchResource';
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_CONTEXT_WINDOW_LENGTH,
|
|
5
|
-
DEFAULT_MESSAGE_HISTORY,
|
|
6
|
-
DEFAULT_SYSTEM_PROMPT,
|
|
7
|
-
} from '../../constants/llamaDefaults';
|
|
1
|
+
import { LLMController } from '../../controllers/LLMController';
|
|
8
2
|
import { ResourceSource } from '../../types/common';
|
|
3
|
+
import { ChatConfig, LLMTool, Message, ToolsConfig } from '../../types/llm';
|
|
9
4
|
|
|
10
5
|
export class LLMModule {
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
static async load(
|
|
14
|
-
modelSource
|
|
15
|
-
tokenizerSource
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
6
|
+
static controller: LLMController;
|
|
7
|
+
|
|
8
|
+
static async load({
|
|
9
|
+
modelSource,
|
|
10
|
+
tokenizerSource,
|
|
11
|
+
tokenizerConfigSource,
|
|
12
|
+
onDownloadProgressCallback,
|
|
13
|
+
responseCallback,
|
|
14
|
+
messageHistoryCallback,
|
|
15
|
+
}: {
|
|
16
|
+
modelSource: ResourceSource;
|
|
17
|
+
tokenizerSource: ResourceSource;
|
|
18
|
+
tokenizerConfigSource: ResourceSource;
|
|
19
|
+
onDownloadProgressCallback?: (_downloadProgress: number) => void;
|
|
20
|
+
responseCallback?: (response: string) => void;
|
|
21
|
+
messageHistoryCallback?: (messageHistory: Message[]) => void;
|
|
22
|
+
}) {
|
|
23
|
+
this.controller = new LLMController({
|
|
24
|
+
responseCallback: responseCallback,
|
|
25
|
+
messageHistoryCallback: messageHistoryCallback,
|
|
26
|
+
onDownloadProgressCallback: onDownloadProgressCallback,
|
|
27
|
+
});
|
|
28
|
+
await this.controller.load({
|
|
29
|
+
modelSource,
|
|
30
|
+
tokenizerSource,
|
|
31
|
+
tokenizerConfigSource,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static configure({
|
|
36
|
+
chatConfig,
|
|
37
|
+
toolsConfig,
|
|
38
|
+
}: {
|
|
39
|
+
chatConfig?: Partial<ChatConfig>;
|
|
40
|
+
toolsConfig?: ToolsConfig;
|
|
41
|
+
}) {
|
|
42
|
+
this.controller.configure({ chatConfig, toolsConfig });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static async forward(input: string): Promise<string> {
|
|
46
|
+
await this.controller.forward(input);
|
|
47
|
+
return this.controller.response;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static async generate(
|
|
51
|
+
messages: Message[],
|
|
52
|
+
tools?: LLMTool[]
|
|
53
|
+
): Promise<string> {
|
|
54
|
+
await this.controller.generate(messages, tools);
|
|
55
|
+
return this.controller.response;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static async sendMessage(message: string): Promise<Message[]> {
|
|
59
|
+
await this.controller.sendMessage(message);
|
|
60
|
+
return this.controller.messageHistory;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static async deleteMessage(index: number): Promise<Message[]> {
|
|
64
|
+
await this.controller.deleteMessage(index);
|
|
65
|
+
return this.controller.messageHistory;
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
static interrupt() {
|
|
56
|
-
|
|
69
|
+
this.controller.interrupt();
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
static delete() {
|
|
60
|
-
|
|
73
|
+
this.controller.delete();
|
|
61
74
|
}
|
|
62
75
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ResourceSource } from '../../types/common';
|
|
2
2
|
import { SpeechToTextController } from '../../controllers/SpeechToTextController';
|
|
3
|
+
import { AvailableModels, SpeechToTextLanguage } from '../../types/stt';
|
|
4
|
+
import { STREAMING_ACTION } from '../../constants/sttDefaults';
|
|
3
5
|
|
|
4
6
|
export class SpeechToText {
|
|
5
7
|
static module: SpeechToTextController;
|
|
@@ -7,9 +9,9 @@ export class SpeechToText {
|
|
|
7
9
|
static onDownloadProgressCallback = (_downloadProgress: number) => {};
|
|
8
10
|
|
|
9
11
|
static async load(
|
|
10
|
-
modelName:
|
|
12
|
+
modelName: AvailableModels,
|
|
11
13
|
transcribeCallback: (sequence: string) => void,
|
|
12
|
-
|
|
14
|
+
modelDownloadProgressCallback?: (downloadProgress: number) => void,
|
|
13
15
|
encoderSource?: ResourceSource,
|
|
14
16
|
decoderSource?: ResourceSource,
|
|
15
17
|
tokenizerSource?: ResourceSource,
|
|
@@ -25,7 +27,7 @@ export class SpeechToText {
|
|
|
25
27
|
) {
|
|
26
28
|
this.module = new SpeechToTextController({
|
|
27
29
|
transcribeCallback: transcribeCallback,
|
|
28
|
-
|
|
30
|
+
modelDownloadProgressCallback: modelDownloadProgressCallback,
|
|
29
31
|
overlapSeconds: overlapSeconds,
|
|
30
32
|
windowSize: windowSize,
|
|
31
33
|
streamingConfig: streamingConfig,
|
|
@@ -50,17 +52,30 @@ export class SpeechToText {
|
|
|
50
52
|
);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
static async transcribe(
|
|
54
|
-
waveform: number[]
|
|
55
|
-
): ReturnType<SpeechToTextController['transcribe']> {
|
|
56
|
-
return await this.module.transcribe(waveform);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
static async encode(waveform: number[]) {
|
|
60
56
|
return await this.module.encode(waveform);
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
static async decode(seq: number[], encodings
|
|
59
|
+
static async decode(seq: number[], encodings: number[]) {
|
|
64
60
|
return await this.module.decode(seq, encodings);
|
|
65
61
|
}
|
|
62
|
+
|
|
63
|
+
static async transcribe(
|
|
64
|
+
waveform: number[],
|
|
65
|
+
audioLanguage?: SpeechToTextLanguage
|
|
66
|
+
): ReturnType<SpeechToTextController['transcribe']> {
|
|
67
|
+
return await this.module.transcribe(waveform, audioLanguage);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async streamingTranscribe(
|
|
71
|
+
streamAction: STREAMING_ACTION,
|
|
72
|
+
waveform?: number[],
|
|
73
|
+
audioLanguage?: SpeechToTextLanguage
|
|
74
|
+
): ReturnType<SpeechToTextController['streamingTranscribe']> {
|
|
75
|
+
return await this.module.streamingTranscribe(
|
|
76
|
+
streamAction,
|
|
77
|
+
waveform,
|
|
78
|
+
audioLanguage
|
|
79
|
+
);
|
|
80
|
+
}
|
|
66
81
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TextEmbeddingsNativeModule } from '../../native/RnExecutorchModules';
|
|
2
|
+
import { ResourceSource } from '../../types/common';
|
|
3
|
+
import { BaseModule } from '../BaseModule';
|
|
4
|
+
|
|
5
|
+
export class TextEmbeddingsModule extends BaseModule {
|
|
6
|
+
protected static override nativeModule = TextEmbeddingsNativeModule;
|
|
7
|
+
|
|
8
|
+
static override async load(
|
|
9
|
+
modelSource: ResourceSource,
|
|
10
|
+
tokenizerSource: ResourceSource
|
|
11
|
+
) {
|
|
12
|
+
await super.load(modelSource, tokenizerSource);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static override async forward(input: string): Promise<number[]> {
|
|
16
|
+
return this.nativeModule.forward(input);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TokenizerNativeModule } from '../../native/RnExecutorchModules';
|
|
2
|
+
import { ResourceSource } from '../../types/common';
|
|
3
|
+
import { BaseModule } from '../BaseModule';
|
|
4
|
+
|
|
5
|
+
export class TokenizerModule extends BaseModule {
|
|
6
|
+
protected static override nativeModule = TokenizerNativeModule;
|
|
7
|
+
|
|
8
|
+
static override async load(tokenizerSource: ResourceSource) {
|
|
9
|
+
await super.load(tokenizerSource);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static async decode(
|
|
13
|
+
input: number[],
|
|
14
|
+
skipSpecialTokens = false
|
|
15
|
+
): Promise<string> {
|
|
16
|
+
return await this.nativeModule.decode(input, skipSpecialTokens);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static async encode(input: string): Promise<number[]> {
|
|
20
|
+
return await this.nativeModule.encode(input);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static async getVocabSize(): Promise<number> {
|
|
24
|
+
return await this.nativeModule.getVocabSize();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static async idToToken(tokenId: number): Promise<string> {
|
|
28
|
+
return await this.nativeModule.idToToken(tokenId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static async tokenToId(token: string): Promise<number> {
|
|
32
|
+
return await this.nativeModule.tokenToId(token);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
loadModule(modelSource: string): Promise<number>;
|
|
6
|
+
|
|
7
|
+
forward(
|
|
8
|
+
input: string,
|
|
9
|
+
classesOfInterest: string[],
|
|
10
|
+
resize: boolean
|
|
11
|
+
): Promise<{ [category: string]: number[] }>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default TurboModuleRegistry.get<Spec>('ImageSegmentation');
|
package/src/native/NativeLLM.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
3
|
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
-
import { MessageType } from '../types/common';
|
|
5
4
|
|
|
6
5
|
export interface Spec extends TurboModule {
|
|
7
|
-
loadLLM(
|
|
8
|
-
|
|
9
|
-
tokenizerSource: string,
|
|
10
|
-
systemPrompt: string,
|
|
11
|
-
messageHistory: MessageType[],
|
|
12
|
-
contextWindowLength: number
|
|
13
|
-
): Promise<string>;
|
|
14
|
-
runInference(input: string): Promise<string>;
|
|
6
|
+
loadLLM(modelSource: string, tokenizerSource: string): Promise<string>;
|
|
7
|
+
forward(input: string): Promise<string>;
|
|
15
8
|
interrupt(): void;
|
|
16
|
-
|
|
9
|
+
releaseResources(): void;
|
|
17
10
|
|
|
18
11
|
readonly onToken: EventEmitter<string>;
|
|
19
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
import { Detection } from '../types/
|
|
3
|
+
import { Detection } from '../types/objectDetection';
|
|
4
4
|
|
|
5
5
|
export interface Spec extends TurboModule {
|
|
6
6
|
loadModule(modelSource: string): Promise<number>;
|
|
@@ -8,8 +8,8 @@ export interface Spec extends TurboModule {
|
|
|
8
8
|
modelSources: (string | number)[]
|
|
9
9
|
): Promise<number>;
|
|
10
10
|
generate(waveform: number[]): Promise<number[]>;
|
|
11
|
-
encode(input: number[]
|
|
12
|
-
decode(prevTokens: number[], encoderOutput: number[]): Promise<number
|
|
11
|
+
encode(input: number[]): Promise<number[]>;
|
|
12
|
+
decode(prevTokens: number[], encoderOutput: number[]): Promise<number>;
|
|
13
13
|
|
|
14
14
|
readonly onToken: EventEmitter<number>;
|
|
15
15
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
loadModule(modelSource: string, tokenizerSource: string): Promise<number>;
|
|
6
|
+
forward(input: string): Promise<number[]>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default TurboModuleRegistry.get<Spec>('TextEmbeddings');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
loadModule(tokenizerSource: string): Promise<number>;
|
|
6
|
+
decode(input: number[], skipSpecialTokens: boolean): Promise<string>;
|
|
7
|
+
encode(input: string): Promise<number[]>;
|
|
8
|
+
getVocabSize(): Promise<number>;
|
|
9
|
+
idToToken(tokenId: number): Promise<string>;
|
|
10
|
+
tokenToId(token: string): Promise<number>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get<Spec>('Tokenizer');
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import { Spec as ClassificationInterface } from './NativeClassification';
|
|
3
2
|
import { Spec as ObjectDetectionInterface } from './NativeObjectDetection';
|
|
4
3
|
import { Spec as StyleTransferInterface } from './NativeStyleTransfer';
|
|
4
|
+
import { Spec as ImageSegmentationInterface } from './NativeImageSegmentation';
|
|
5
5
|
import { Spec as ETModuleInterface } from './NativeETModule';
|
|
6
6
|
import { Spec as OCRInterface } from './NativeOCR';
|
|
7
7
|
import { Spec as VerticalOCRInterface } from './NativeVerticalOCR';
|
|
8
|
+
import { Spec as SpeechToTextInterface } from './NativeSpeechToText';
|
|
9
|
+
import { Spec as TextEmbeddingsInterface } from './NativeTextEmbeddings';
|
|
10
|
+
import { Spec as LLMInterface } from './NativeLLM';
|
|
11
|
+
import { Spec as ClassificationInterface } from './NativeClassification';
|
|
12
|
+
import { Spec as TokenizerInterface } from './NativeTokenizer';
|
|
8
13
|
|
|
9
14
|
const LINKING_ERROR =
|
|
10
15
|
`The package 'react-native-executorch' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -12,241 +17,56 @@ const LINKING_ERROR =
|
|
|
12
17
|
'- You rebuilt the app after installing the package\n' +
|
|
13
18
|
'- You are not using Expo Go\n';
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const ETModuleSpec = require('./NativeETModule').default;
|
|
29
|
-
|
|
30
|
-
const ETModule = ETModuleSpec
|
|
31
|
-
? ETModuleSpec
|
|
32
|
-
: new Proxy(
|
|
33
|
-
{},
|
|
34
|
-
{
|
|
35
|
-
get() {
|
|
36
|
-
throw new Error(LINKING_ERROR);
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const ClassificationSpec = require('./NativeClassification').default;
|
|
42
|
-
|
|
43
|
-
const Classification = ClassificationSpec
|
|
44
|
-
? ClassificationSpec
|
|
45
|
-
: new Proxy(
|
|
46
|
-
{},
|
|
47
|
-
{
|
|
48
|
-
get() {
|
|
49
|
-
throw new Error(LINKING_ERROR);
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const ObjectDetectionSpec = require('./NativeObjectDetection').default;
|
|
55
|
-
|
|
56
|
-
const ObjectDetection = ObjectDetectionSpec
|
|
57
|
-
? ObjectDetectionSpec
|
|
58
|
-
: new Proxy(
|
|
59
|
-
{},
|
|
60
|
-
{
|
|
61
|
-
get() {
|
|
62
|
-
throw new Error(LINKING_ERROR);
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const StyleTransferSpec = require('./NativeStyleTransfer').default;
|
|
68
|
-
|
|
69
|
-
const StyleTransfer = StyleTransferSpec
|
|
70
|
-
? StyleTransferSpec
|
|
71
|
-
: new Proxy(
|
|
72
|
-
{},
|
|
73
|
-
{
|
|
74
|
-
get() {
|
|
75
|
-
throw new Error(LINKING_ERROR);
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const SpeechToTextSpec = require('./NativeSpeechToText').default;
|
|
81
|
-
|
|
82
|
-
const SpeechToText = SpeechToTextSpec
|
|
83
|
-
? SpeechToTextSpec
|
|
84
|
-
: new Proxy(
|
|
85
|
-
{},
|
|
86
|
-
{
|
|
87
|
-
get() {
|
|
88
|
-
throw new Error(LINKING_ERROR);
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const OCRSpec = require('./NativeOCR').default;
|
|
94
|
-
|
|
95
|
-
const OCR = OCRSpec
|
|
96
|
-
? OCRSpec
|
|
97
|
-
: new Proxy(
|
|
98
|
-
{},
|
|
99
|
-
{
|
|
100
|
-
get() {
|
|
101
|
-
throw new Error(LINKING_ERROR);
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const VerticalOCRSpec = require('./NativeVerticalOCR').default;
|
|
107
|
-
|
|
108
|
-
const VerticalOCR = VerticalOCRSpec
|
|
109
|
-
? VerticalOCRSpec
|
|
110
|
-
: new Proxy(
|
|
111
|
-
{},
|
|
112
|
-
{
|
|
113
|
-
get() {
|
|
114
|
-
throw new Error(LINKING_ERROR);
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
class _ObjectDetectionModule {
|
|
120
|
-
async forward(
|
|
121
|
-
input: string
|
|
122
|
-
): ReturnType<ObjectDetectionInterface['forward']> {
|
|
123
|
-
return await ObjectDetection.forward(input);
|
|
124
|
-
}
|
|
125
|
-
async loadModule(
|
|
126
|
-
modelSource: string | number
|
|
127
|
-
): ReturnType<ObjectDetectionInterface['loadModule']> {
|
|
128
|
-
return await ObjectDetection.loadModule(modelSource);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
class _StyleTransferModule {
|
|
133
|
-
async forward(input: string): ReturnType<StyleTransferInterface['forward']> {
|
|
134
|
-
return await StyleTransfer.forward(input);
|
|
135
|
-
}
|
|
136
|
-
async loadModule(
|
|
137
|
-
modelSource: string | number
|
|
138
|
-
): ReturnType<StyleTransferInterface['loadModule']> {
|
|
139
|
-
return await StyleTransfer.loadModule(modelSource);
|
|
140
|
-
}
|
|
20
|
+
function returnSpecOrThrowLinkingError(spec: any) {
|
|
21
|
+
return spec
|
|
22
|
+
? spec
|
|
23
|
+
: new Proxy(
|
|
24
|
+
{},
|
|
25
|
+
{
|
|
26
|
+
get() {
|
|
27
|
+
throw new Error(LINKING_ERROR);
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
);
|
|
141
31
|
}
|
|
142
32
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
class _OCRModule {
|
|
173
|
-
async forward(input: string): ReturnType<OCRInterface['forward']> {
|
|
174
|
-
return await OCR.forward(input);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async loadModule(
|
|
178
|
-
detectorSource: string,
|
|
179
|
-
recognizerSourceLarge: string,
|
|
180
|
-
recognizerSourceMedium: string,
|
|
181
|
-
recognizerSourceSmall: string,
|
|
182
|
-
symbols: string
|
|
183
|
-
) {
|
|
184
|
-
return await OCR.loadModule(
|
|
185
|
-
detectorSource,
|
|
186
|
-
recognizerSourceLarge,
|
|
187
|
-
recognizerSourceMedium,
|
|
188
|
-
recognizerSourceSmall,
|
|
189
|
-
symbols
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
class _VerticalOCRModule {
|
|
195
|
-
async forward(input: string): ReturnType<VerticalOCRInterface['forward']> {
|
|
196
|
-
return await VerticalOCR.forward(input);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async loadModule(
|
|
200
|
-
detectorLargeSource: string,
|
|
201
|
-
detectorMediumSource: string,
|
|
202
|
-
recognizerSource: string,
|
|
203
|
-
symbols: string,
|
|
204
|
-
independentCharacters: boolean
|
|
205
|
-
): ReturnType<VerticalOCRInterface['loadModule']> {
|
|
206
|
-
return await VerticalOCR.loadModule(
|
|
207
|
-
detectorLargeSource,
|
|
208
|
-
detectorMediumSource,
|
|
209
|
-
recognizerSource,
|
|
210
|
-
symbols,
|
|
211
|
-
independentCharacters
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
class _ETModule {
|
|
217
|
-
async forward(
|
|
218
|
-
inputs: number[][],
|
|
219
|
-
shapes: number[][],
|
|
220
|
-
inputTypes: number[]
|
|
221
|
-
): ReturnType<ETModuleInterface['forward']> {
|
|
222
|
-
return await ETModule.forward(inputs, shapes, inputTypes);
|
|
223
|
-
}
|
|
224
|
-
async loadModule(
|
|
225
|
-
modelSource: string
|
|
226
|
-
): ReturnType<ETModuleInterface['loadModule']> {
|
|
227
|
-
return await ETModule.loadModule(modelSource);
|
|
228
|
-
}
|
|
229
|
-
async loadMethod(
|
|
230
|
-
methodName: string
|
|
231
|
-
): ReturnType<ETModuleInterface['loadMethod']> {
|
|
232
|
-
return await ETModule.loadMethod(methodName);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
33
|
+
const LLMNativeModule: LLMInterface = returnSpecOrThrowLinkingError(
|
|
34
|
+
require('./NativeLLM').default
|
|
35
|
+
);
|
|
36
|
+
const ETModuleNativeModule: ETModuleInterface = returnSpecOrThrowLinkingError(
|
|
37
|
+
require('./NativeETModule').default
|
|
38
|
+
);
|
|
39
|
+
const ClassificationNativeModule: ClassificationInterface =
|
|
40
|
+
returnSpecOrThrowLinkingError(require('./NativeClassification').default);
|
|
41
|
+
const ImageSegmentationNativeModule: ImageSegmentationInterface =
|
|
42
|
+
returnSpecOrThrowLinkingError(require('./NativeImageSegmentation').default);
|
|
43
|
+
const ObjectDetectionNativeModule: ObjectDetectionInterface =
|
|
44
|
+
returnSpecOrThrowLinkingError(require('./NativeObjectDetection').default);
|
|
45
|
+
const StyleTransferNativeModule: StyleTransferInterface =
|
|
46
|
+
returnSpecOrThrowLinkingError(require('./NativeStyleTransfer').default);
|
|
47
|
+
const SpeechToTextNativeModule: SpeechToTextInterface =
|
|
48
|
+
returnSpecOrThrowLinkingError(require('./NativeSpeechToText').default);
|
|
49
|
+
const OCRNativeModule: OCRInterface = returnSpecOrThrowLinkingError(
|
|
50
|
+
require('./NativeOCR').default
|
|
51
|
+
);
|
|
52
|
+
const VerticalOCRNativeModule: VerticalOCRInterface =
|
|
53
|
+
returnSpecOrThrowLinkingError(require('./NativeVerticalOCR').default);
|
|
54
|
+
const TokenizerNativeModule: TokenizerInterface = returnSpecOrThrowLinkingError(
|
|
55
|
+
require('./NativeTokenizer').default
|
|
56
|
+
);
|
|
57
|
+
const TextEmbeddingsNativeModule: TextEmbeddingsInterface =
|
|
58
|
+
returnSpecOrThrowLinkingError(require('./NativeTextEmbeddings').default);
|
|
235
59
|
|
|
236
60
|
export {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
_ObjectDetectionModule,
|
|
249
|
-
_SpeechToTextModule,
|
|
250
|
-
_OCRModule,
|
|
251
|
-
_VerticalOCRModule,
|
|
61
|
+
LLMNativeModule,
|
|
62
|
+
ETModuleNativeModule,
|
|
63
|
+
ClassificationNativeModule,
|
|
64
|
+
ObjectDetectionNativeModule,
|
|
65
|
+
StyleTransferNativeModule,
|
|
66
|
+
ImageSegmentationNativeModule,
|
|
67
|
+
SpeechToTextNativeModule,
|
|
68
|
+
OCRNativeModule,
|
|
69
|
+
VerticalOCRNativeModule,
|
|
70
|
+
TextEmbeddingsNativeModule,
|
|
71
|
+
TokenizerNativeModule,
|
|
252
72
|
};
|