mrousavy / react-native-fast-tflite Goto Github PK
View Code? Open in Web Editor NEW๐ฅ High-performance TensorFlow Lite library for React Native with GPU acceleration
Home Page: https://mrousavy.com
License: MIT License
๐ฅ High-performance TensorFlow Lite library for React Native with GPU acceleration
Home Page: https://mrousavy.com
License: MIT License
example/android/app/build.gradle
enableProguardInReleaseBuilds
to true
2024-03-19 17:19:48.426 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollContainerViewManager
2024-03-19 17:19:48.427 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.progressbar.ReactProgressBarViewManager
2024-03-19 17:19:48.427 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.progressbar.b
2024-03-19 17:19:48.427 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.scroll.ReactScrollViewManager
2024-03-19 17:19:48.428 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager
2024-03-19 17:19:48.428 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager$b
2024-03-19 17:19:48.428 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager
2024-03-19 17:19:48.429 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager
2024-03-19 17:19:48.429 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class x3.a
2024-03-19 17:19:48.429 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.image.ReactImageManager
2024-03-19 17:19:48.429 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.modal.ReactModalHostManager
2024-03-19 17:19:48.429 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.modal.b
2024-03-19 17:19:48.430 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.ReactRawTextManager
2024-03-19 17:19:48.430 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.k
2024-03-19 17:19:48.430 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputManager
2024-03-19 17:19:48.431 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.textinput.d0
2024-03-19 17:19:48.431 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
2024-03-19 17:19:48.431 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.r
2024-03-19 17:19:48.432 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
2024-03-19 17:19:48.432 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextViewManager
2024-03-19 17:19:48.432 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.text.a0
2024-03-19 17:19:48.432 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.facebook.react.views.unimplementedview.ReactUnimplementedViewManager
2024-03-19 17:19:48.432 23925-23950 unknown:Vi...rtyUpdater com.tfliteexample W Could not find generated setter for class com.mrousavy.camera.CameraViewManager
2024-03-19 17:19:48.443 23925-23945 OpenGLRenderer com.tfliteexample W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2024-03-19 17:19:48.443 23925-23945 OpenGLRenderer com.tfliteexample W Failed to initialize 101010-2 format, error = EGL_SUCCESS
2024-03-19 17:19:48.449 23925-23945 Gralloc4 com.tfliteexample I mapper 4.x is not supported
2024-03-19 17:19:48.451 23925-23950 ReactNativeJS com.tfliteexample I Running "TfliteExample
2024-03-19 17:19:48.454 23925-23950 ReactNativeJS com.tfliteexample I Loading react-native-worklets-core...
2024-03-19 17:19:48.454 23925-23945 OpenGLRenderer com.tfliteexample E Unable to match the desired swap behavior.
2024-03-19 17:19:48.458 23925-23950 ReactNativeJS com.tfliteexample I Worklets loaded successfully
2024-03-19 17:19:48.465 23925-23950 VisionCameraProxy com.tfliteexample I Initializing VisionCameraProxy...
2024-03-19 17:19:48.465 23925-23950 VisionCameraProxy com.tfliteexample I Creating Worklet Context...
2024-03-19 17:19:48.468 23925-23950 VisionCameraProxy com.tfliteexample I Worklet Context created!
2024-03-19 17:19:48.469 23925-23950 Compatibil...geReporter com.tfliteexample D Compat change id reported: 250678880; UID 10185; state: ENABLED
2024-03-19 17:19:48.535 23925-23950 Compatibil...geReporter com.tfliteexample D Compat change id reported: 206033068; UID 10185; state: ENABLED
2024-03-19 17:19:48.548 23925-23950 ReactNativeJS com.tfliteexample I Installing bindings...
2024-03-19 17:19:48.549 23925-23950 Tflite com.tfliteexample I Loading C++ library...
2024-03-19 17:19:48.549 23925-23950 Tflite com.tfliteexample I Installing JSI Bindings for VisionCamera Tflite plugin...
2024-03-19 17:19:48.550 23925-23950 Tflite com.tfliteexample I Successfully installed JSI Bindings!
2024-03-19 17:19:48.550 23925-23950 ReactNativeJS com.tfliteexample I Successfully installed!
2024-03-19 17:19:48.550 23925-23950 FrameProce...inRegistry com.tfliteexample I Looking up Frame Processor Plugin "resize"...
2024-03-19 17:19:48.550 23925-23950 FrameProce...inRegistry com.tfliteexample I Frame Processor Plugin "resize" found! Initializing...
2024-03-19 17:19:48.550 23925-23950 ReactNativeJS com.tfliteexample I Model: loading (false)
2024-03-19 17:19:48.553 23925-23950 ReactNativeJS com.tfliteexample I Loading Tensorflow Lite Model 1
2024-03-19 17:19:48.554 23925-23950 ReactNativeJS com.tfliteexample I Resolved Model path: assets_efficientdet
2024-03-19 17:19:48.554 23925-23968 Tflite com.tfliteexample I Loading byte data from URL: assets_efficientdet...
2024-03-19 17:19:48.554 23925-23968 Tflite com.tfliteexample I Parsing resourceId...
2024-03-19 17:19:48.554 23925-23968 Tflite com.tfliteexample I Parsed resourceId: 2131558400
2024-03-19 17:19:48.560 23925-23925 PreviewView com.tfliteexample I Creating PreviewView...
2024-03-19 17:19:48.561 23925-23925 PreviewView com.tfliteexample I PreviewView is 0x0, rendering 1080x1920 content. Resizing to: 0x0 (COVER)
2024-03-19 17:19:48.562 23925-23925 CameraView com.tfliteexample I Updating CameraSession...
2024-03-19 17:19:48.563 23925-23963 CameraSession com.tfliteexample I configure { ... }: Waiting for lock...
2024-03-19 17:19:48.563 23925-23963 CameraSession com.tfliteexample I configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-03-19 17:19:48.564 23925-23963 CameraSession com.tfliteexample I Need to rebuild CameraDevice and CameraCaptureSession...
2024-03-19 17:19:48.564 23925-23963 CameraSession com.tfliteexample I CameraDevice and CameraCaptureSession is torn down but Camera is not active, skipping update...
2024-03-19 17:19:48.564 23925-23963 CameraSession com.tfliteexample I Successfully updated CameraSession Configuration! isActive: false
2024-03-19 17:19:48.564 23925-23963 CameraView com.tfliteexample I invokeOnInitialized()
2024-03-19 17:19:48.567 23925-23925 CameraView com.tfliteexample I Updating CameraSession...
2024-03-19 17:19:48.567 23925-23963 CameraSession com.tfliteexample I configure { ... }: Waiting for lock...
2024-03-19 17:19:48.567 23925-23963 CameraSession com.tfliteexample I configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-03-19 17:19:48.567 23925-23963 CameraSession com.tfliteexample I Need to rebuild CameraDevice and CameraCaptureSession...
2024-03-19 17:19:48.567 23925-23963 CameraSession com.tfliteexample I Need to rebuild CameraDevice and CameraCaptureSession...
2024-03-19 17:19:48.567 23925-23963 CameraSession com.tfliteexample I Configuring Camera #10...
2024-03-19 17:19:48.568 23925-23963 CameraManager com.tfliteexample I Camera #10: Opening...
2024-03-19 17:19:48.568 23925-23925 PreviewView com.tfliteexample I PreviewView is 1440x2891, rendering 1080x1920 content. Resizing to: 1626x2891 (COVER)
2024-03-19 17:19:48.570 23925-23925 CameraSession com.tfliteexample I PreviewView Surface created! Surface(name=null)/@0x29c2de0
2024-03-19 17:19:48.570 23925-23925 CameraSession com.tfliteexample I Setting Preview Output...
2024-03-19 17:19:48.570 23925-23925 CameraSession com.tfliteexample I PreviewView Surface updated! Surface(name=null)/@0x29c2de0 1626 x 2891
2024-03-19 17:19:48.577 23925-23951 CameraDevices com.tfliteexample I Camera #10 is now unavailable.
2024-03-19 17:19:48.578 23925-23963 CameraSession com.tfliteexample I configure { ... }: Waiting for lock...
2024-03-19 17:19:48.578 23925-23963 CameraManager com.tfliteexample I Camera #10: Opened!
2024-03-19 17:19:48.579 23925-23963 CameraSession com.tfliteexample I Successfully configured Camera #10!
2024-03-19 17:19:48.579 23925-23963 CameraSession com.tfliteexample I Destroying previous outputs...
2024-03-19 17:19:48.580 23925-23963 CameraSession com.tfliteexample I Creating outputs for Camera #10...
2024-03-19 17:19:48.580 23925-23963 CameraSession com.tfliteexample I Adding 1280x960 Video Output in YUV_420_888...
2024-03-19 17:19:48.580 23925-23963 VideoPipeline com.tfliteexample I Initializing 1280 x 960 Video Pipeline (format: YUV)
2024-03-19 17:19:48.580 23925-23963 VideoPipeline com.tfliteexample I Using ImageReader round-trip (format: #35)
2024-03-19 17:19:48.581 23925-23963 VideoPipeline com.tfliteexample I Using API 29 for GPU ImageReader...
2024-03-19 17:19:48.581 23925-23968 tflite com.tfliteexample I Initialized TensorFlow Lite runtime.
2024-03-19 17:19:48.581 23925-23963 Compatibil...geReporter com.tfliteexample D Compat change id reported: 236825255; UID 10185; state: ENABLED
2024-03-19 17:19:48.582 23925-23963 CreateCaptureSession com.tfliteexample I Camera #10: Creating Capture Session #1... (Hardware Level: 0 | Outputs: [VIDEO (1280x960 in YUV)])
2024-03-19 17:19:48.582 23925-23963 CreateCaptureSession com.tfliteexample I Using new API (>=28)
2024-03-19 17:19:48.582 23925-23950 ReactNativeJS com.tfliteexample I Model: loading (false)
2024-03-19 17:19:48.803 23925-23950 ReactNativeJS com.tfliteexample E Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;.<init>(Lcom/facebook/jni/HybridData;)V", js engine: hermes
2024-03-19 17:19:48.804 23925-23950 ReactNativeJS com.tfliteexample I Model: loaded (true)
2024-03-19 17:19:48.812 23925-23950 ReactNativeJS com.tfliteexample I Model loaded! Shape:
TFLite Model (default):
- Inputs:
- uint8 serving_default_images:0[1,320,320,3]
- Outputs:
- float32 StatefulPartitionedCall:3[1,25,4]
- float32 StatefulPartitionedCall:2[1,25]
- float32 StatefulPartitionedCall:1[1,25]
- float32 StatefulPartitionedCall:0[1]]
2024-03-19 17:19:48.812 23925-23950 ReactNativeJS com.tfliteexample E Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;.<init>(Lcom/facebook/jni/HybridData;)V"
This error is located at:
in Camera
in RCTView
in Unknown
in App
in RCTView
in Unknown
in RCTView
in Unknown
in AppContainer, js engine: hermes
2024-03-19 17:19:48.813 23925-23950 ReactNativeJS com.tfliteexample E 'Failed to load Tensorflow Model 1!', { [Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;.<init>(Lcom/facebook/jni/HybridData;)V"]
componentStack: '\n in Camera\n in RCTView\n in Unknown\n in App\n in RCTView\n in Unknown\n in RCTView\n in Unknown\n in AppContainer',
isComponentError: true }
2024-03-19 17:19:48.840 23925-23951 AndroidRuntime com.tfliteexample E FATAL EXCEPTION: mqt_native_modules
Process: com.tfliteexample, PID: 23925
com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;.<init>(Lcom/facebook/jni/HybridData;)V", js engine: hermes, stack:
setFrameProcessor@1:602717
onViewReady@1:602821
invokeGuardedCallbackImpl@1:284974
invokeGuardedCallback@1:285031
invokeGuardedCallbackAndCatchFirstError@1:285063
executeDispatch@1:285192
executeDispatchesAndReleaseTopLevel@1:289361
forEachAccumulated@1:286650
anonymous@1:289724
batchedUpdatesImpl@1:348771
batchedUpdates@1:289279
_receiveRootNodeIDEvent@1:289562
receiveEvent@1:343266
__callFunction@1:41328
anonymous@1:39633
__guard@1:40589
callFunctionReturnFlushedQueue@1:39591
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(Unknown Source:75)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:142)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:21)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:1012)
2024-03-19 17:19:48.845 23925-23963 CreateCaptureSession com.tfliteexample I Camera #10: Successfully created CameraCaptureSession #1!
2024-03-19 17:19:48.845 23925-23963 CameraSession com.tfliteexample I Successfully configured Session with 1 outputs for Camera #10!
2024-03-19 17:19:48.845 23925-23963 CameraSession com.tfliteexample I Updating Video Outputs...
2024-03-19 17:19:48.845 23925-23963 VideoPipeline com.tfliteexample I Removing FrameProcessor Output...
2024-03-19 17:19:48.845 23925-23963 VideoPipeline com.tfliteexample I Removing RecordingSession Output...
2024-03-19 17:19:48.847 23925-23963 CameraView com.tfliteexample I invokeOnStarted()
2024-03-19 17:19:48.847 23925-23963 CameraSession com.tfliteexample I Successfully updated CameraSession Configuration! isActive: true
2024-03-19 17:19:48.847 23925-23963 CameraView com.tfliteexample I invokeOnInitialized()
2024-03-19 17:19:48.848 23925-23963 CameraSession com.tfliteexample I configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=false, outputsChanged=true, sidePropsChanged=true, isActiveChanged=false)
2024-03-19 17:19:48.848 23925-23963 CameraSession com.tfliteexample I Destroying previous outputs...
2024-03-19 17:19:48.848 23925-23963 SurfaceOutput com.tfliteexample I Closing 1280x960 Video Pipeline..
2024-03-19 17:19:48.849 23925-23963 CameraView com.tfliteexample I invokeOnStopped()
2024-03-19 17:19:48.849 23925-23974 BufferQueueProducer com.tfliteexample E [ImageReader-1280x960f23m3-23925-0](id:5d7500000003,api:4,p:449,c:23925) dequeueBuffer: BufferQueue has been abandoned
2024-03-19 17:19:48.851 23925-23963 CameraSession com.tfliteexample I Creating outputs for Camera #10...
2024-03-19 17:19:48.852 23925-23963 CameraSession com.tfliteexample I Adding 1280x960 Video Output in YUV_420_888...
2024-03-19 17:19:48.852 23925-23963 VideoPipeline com.tfliteexample I Initializing 1280 x 960 Video Pipeline (format: YUV)
2024-03-19 17:19:48.852 23925-23963 VideoPipeline com.tfliteexample I Using ImageReader round-trip (format: #35)
2024-03-19 17:19:48.852 23925-23963 VideoPipeline com.tfliteexample I Using API 29 for GPU ImageReader...
2024-03-19 17:19:48.853 23925-23963 CameraSession com.tfliteexample I Adding 1280x960 Preview Output...
2024-03-19 17:19:48.854 23925-23925 PreviewView com.tfliteexample I Setting PreviewView Surface Size to 1626 x 2891...
2024-03-19 17:19:48.855 23925-23963 CreateCaptureSession com.tfliteexample I Camera #10: Creating Capture Session #2... (Hardware Level: 0 | Outputs: [VIDEO (1280x960 in YUV), PREVIEW (1280 x 960)])
2024-03-19 17:19:48.855 23925-23963 CreateCaptureSession com.tfliteexample I Using new API (>=28)
2024-03-19 17:19:48.860 23925-23925 CameraSession com.tfliteexample I PreviewView Surface updated! Surface(name=null)/@0x29c2de0 1280 x 960
2024-03-19 17:19:48.869 23925-23951 Process com.tfliteexample I Sending signal. PID: 23925 SIG: 9
2024-03-19 17:19:52.308 24103-24128 AndroidRuntime pid-24103 E FATAL EXCEPTION: mqt_native_modules
Process: com.tfliteexample, PID: 24103
com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;.<init>(Lcom/facebook/jni/HybridData;)V", js engine: hermes, stack:
setFrameProcessor@1:602717
onViewReady@1:602821
invokeGuardedCallbackImpl@1:284974
invokeGuardedCallback@1:285031
invokeGuardedCallbackAndCatchFirstError@1:285063
executeDispatch@1:285192
executeDispatchesAndReleaseTopLevel@1:289361
forEachAccumulated@1:286650
anonymous@1:289724
batchedUpdatesImpl@1:348771
batchedUpdates@1:289279
_receiveRootNodeIDEvent@1:289562
receiveEvent@1:343266
__callFunction@1:41328
anonymous@1:39633
__guard@1:40589
callFunctionReturnFlushedQueue@1:39591
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(Unknown Source:75)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:142)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:21)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:1012)
2024-03-19 17:19:52.437 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.467 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.500 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.534 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.566 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.601 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.632 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.666 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.700 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.734 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.766 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.800 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.834 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.867 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.899 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.932 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.965 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:52.999 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.033 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.066 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.081 24103-24122 EGL_emulation com.tfliteexample D app_time_stats: avg=10.84ms min=0.81ms max=71.05ms count=51
2024-03-19 17:19:53.101 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.134 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.168 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.201 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.234 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.266 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.300 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.335 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.367 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.401 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.433 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.467 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.500 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.534 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.567 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.602 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.635 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.670 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.703 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.736 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.767 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.801 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.834 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.868 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.900 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.933 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:53.967 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.000 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.032 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.068 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.102 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.103 24103-24122 EGL_emulation com.tfliteexample D app_time_stats: avg=2.39ms min=1.08ms max=6.75ms count=49
2024-03-19 17:19:54.135 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.168 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.200 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.234 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.269 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.300 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.334 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.366 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.402 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.433 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.467 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.502 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.537 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.569 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.602 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.634 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.668 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.702 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.735 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.769 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.802 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.834 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.869 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.924 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.938 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:54.972 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.006 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.039 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.075 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.107 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.108 24103-24122 EGL_emulation com.tfliteexample D app_time_stats: avg=2.68ms min=0.82ms max=7.11ms count=46
2024-03-19 17:19:55.141 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.173 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.207 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.240 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.273 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.307 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.340 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.373 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.408 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.441 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.474 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.507 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.541 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.574 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.606 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.638 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.672 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.705 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.738 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.773 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.805 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.837 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.870 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.904 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.939 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:55.974 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.008 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.040 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.076 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.106 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.114 24103-24122 EGL_emulation com.tfliteexample D app_time_stats: avg=3.53ms min=0.94ms max=14.37ms count=39
2024-03-19 17:19:56.143 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
2024-03-19 17:19:56.204 24103-24138 VideoPipeline com.tfliteexample I ImageReader::onImageAvailable!
Hi, I know react-native-fast-tflite can process any tflite model, but it looks like MediaPipe's pose estimation allows you to download models that is ".task" file (the underlying model are apparently tflite models) https://developers.google.com/mediapipe/solutions/vision/pose_landmarker
To work around this, I was looking into integrating the example Mediapipe android code into creating a frame processor plugin (followed steps from the react-native-camera-vision docs , but this doesn't seems as straightforward. (for one, I am not sure how to convert Frame into ImageProxy object, 2. I am mostly familiar with RN side of things)
Any help is appreciated.
Hi, there is an issues with the library on Android in the release version.
First:
Function loadTensorflowModel in TensorflowLite.ts use
const asset = Image.resolveAssetSource(source)
uri = asset.uri
In Dev mode, assets are served from the server, so the URI will be: "http://localhost:8081/assets/src/assets/mymodel.flite?platform=android&hash=...." so it works,
but in release mode on Android, asset.uri will be: src_assets_mymodel
Second:
The function fetchByteDataFromUrl in lib/android in TfliteModule.java uses the HTTP request method, which throws an error because it expects the URL scheme to be "http" or "https."
public static byte[] fetchByteDataFromUrl(String url) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful() && response.body() != null) {
return response.body().bytes();
} else {
throw new RuntimeException("Response was not successful!");
}
} catch (Exception e) {
Log.e(NAME, "Failed to fetch URL " + url + "!", e);
return null;
}
}
On iOS, everything works fine
I have a deployment very soon and I found out my frame processing isn't working in my release versions but it does work in my debug versions.
I checked the catlog of my app and I saw Failed to load Tensorflow Model IllegalArgumentException: Expected URL scheme 'http' or 'https' but no colon was found
, I need to fix this ASAP, can you suggest a solution or even just a patch I could work with? Would very appreciate any help with this
2024-02-13 19:53:22.365 31683-31762 FrameProce...inRegistry com.x I Looking up Frame Processor Plugin "scanOCR"...
2024-02-13 19:53:22.365 31683-31762 FrameProce...inRegistry com.x I Frame Processor Plugin "scanOCR" found! Initializing...
2024-02-13 19:53:22.370 31683-31762 ReactNativeJS com.x I Loading Tensorflow Lite Model 19
2024-02-13 19:53:22.370 31683-31762 ReactNativeJS com.x I Resolved Model path: app_assets_documentdetection
2024-02-13 19:53:22.374 31683-31762 ReactNativeJS com.x E 'Failed to load Tensorflow Model 19!', [Error: java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no colon was found]
2024-02-13 19:53:22.381 31683-31683 PreviewView com.x I Creating PreviewView...
2024-02-13 19:53:22.382 31683-31683 PreviewView com.x I PreviewView is 0x0, rendering 1920x1080 content. Resizing to: 0x0 (COVER)
2024-02-13 19:53:22.383 31683-31683 CameraView com.x I Updating CameraSession...
2024-02-13 19:53:22.384 31683-31759 CameraSession com.x I configure { ... }: Waiting for lock...
2024-02-13 19:53:22.385 31683-31759 CameraSession com.x I configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-02-13 19:53:22.385 31683-31759 CameraSession com.x I Configuring inputs for CameraSession...
2024-02-13 19:53:22.385 31683-31759 Persistent...ureSession com.x D --> setInput(0)
2024-02-13 19:53:22.385 31683-31759 CameraSession com.x I Destroying previous outputs...
2024-02-13 19:53:22.386 31683-31683 PreviewView com.x I Setting PreviewView ResizeMode to COVER...
2024-02-13 19:53:22.389 31683-31759 CameraSession com.x I Creating outputs for Camera #0...
2024-02-13 19:53:22.392 31683-31763 unknown:ReactNative com.x E console.error: Failed to load Tensorflow Model 19! Error: java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no colon was found, js engine: hermes, stack:
_construct@1:189687
Wrapper@1:189333
_callSuper@1:187344
SyntheticError@1:188814
reactConsoleErrorHandler@1:188479
?anon_0_@1:2159260
asyncGeneratorStep@1:543122
_throw@1:543424
tryCallOne@53:15
anonymous@139:26
anonymous@1:206378
_callTimer@1:205329
_callReactNativeMicrotasksPass@1:205473
callReactNativeMicrotasks@1:207457
__callReactNativeMicrotasks@1:93414
anonymous@1:92498
__guard@1:93252
flushedQueue@1:92409
Hy, i use plugin but i'm error in app
error =>
'Failed to load Tensorflow Model 1!', [TypeError: right operand of 'in' is not an object]
=> Platform
real device IOS 17 iphone 14 pro
v. "react-native-fast-tflite": "^0.3.0",
"react-native-vision-camera": "^3.3.1",
First of all, many thanks for this library. It looks really promising to me, but I struggle to get it working correctly. In a first step, I wanted to test the library without a camera, using just a local image. I managed to get an output, but my problem is that it doesn't seem to be accurate. I use the object detection example from the Tensorfow website as my model. Based on netron.app I can tell that the input tensor of the model is shaped as follows: uint8[1,300,300,3].
My first hurdle was to get my local image into the desired ArrayBuffers format, taking into account the expected input format of the model. I endet up using the Image object from react-native-skia. I draw my testimage onto a 300x300 pixel canvas to extract the pixels and convert them to the desired data-shape using the following code:
...
const imageBytes = image.readPixels()
const rgbData = new Uint8Array(300 * 300 * 3)
// Input shape: 1 uint8[1,300,300,3]
// Meaning: 300 x 300 Pixels + 3 bit for RGB
// Copy pixel but leave out alpha channel
for (let i = 0, j = 0; i < imageBytes.length; i += 4, j += 3) {
rgbData[j] = imageBytes[i] // Red
rgbData[j + 1] = imageBytes[i + 1] // Green
rgbData[j + 2] = imageBytes[i + 2] // Blue
}
const dataArray = await model.model.run([rgbData])
const locations = dataArray[0]
const classes = dataArray[1]
const scores = dataArray[2]
const topDetections = []
for (let i = 0; i < Math.min(classes.length, 3); i++) {
topDetections.push({
location: locations[i],
score: scores[i],
class: labelmap[classes[i]]
})
}
const output = 'Guesses:\n' + topDetections.map((detection) => `${detection.class} (${detection.score})\n`)
setGuess(output)
First I was a bit confused, as I am passing an Uint8Array instead of an array buffer, but I was happy the model finally returned something. However, as you can see from my screenshot, the result is not as expected (there is a "cat" class in the model..).
Does anyone have any idea where my error could lie? I'm not sure what the first 1 in the input format [1,300,300,3] means. Somewhere I read it's called batch dimension, but I have no clue if or how to add it to my input tensor.
Hi @mrousavy , I am using expo-49 on android and getting this error
In IOS when I use this package and run code I get this error
Error: Unable to resolve module ./LogBoxImages/close.png from /node_modules/react-native/Libraries/LogBox/UI/LogBoxNotification.js
107 | style={dismissStyles.press}>
108 | <Image
> 109 | source={require('./LogBoxImages/close.png')}
| ^
110 | style={dismissStyles.image}
111 | />
112 | </LogBoxButton>
React Native: v0.73.10
react-native-fast-tflite: 1.1.3
The guide mentioned setting up GPU delegation for IOS, but how can I do it in Android?
I encountered two errors while attempting to build for iOS with both new and old architectures, each resulting in different issues. When using the new architecture, I encountered the following error:
node_modules/react-native-fast-tflite/ios/Tflite.h:3:9 'RNTfliteSpec.h' file not found
Switching back to the old architecture triggered an another error, which appears to be the same as this issue. While a workaround involves adding arm64
to excluded architectures and using Xcode in Rosetta mode, it's not an ideal solution in my opinion.
Building for iOS Simulator, but linking in object file built for iOS, file 'node_modules/react-native-fast-tflite/ios/TensorFlowLiteC.framework/TensorFlowLiteC' for architecture arm64
yarn react-native run-ios
(you can toggle the RCT_NEW_ARCH_ENABLED
flag in Podfile to switch architectures and observe both errors).https://github.com/ahmetbicer/fast-tflite-repro
0.73.1
I am currently using TFLite to load my model.tflite and I am trying to get the name of the classes that detected by the Camera. But, the problem is it only shows the number of arrays. Any suggestions for me to solve my problem?
model.tflite - I don't have labels.txt cause this is from the kaggle and it didn't provide any..
When building the app in release mode the app crashes on start but works on debug build.
I am able to build the app in release mode when I disable dex guard. I have tried to remove the package from pro guard but nothing is working
// proguard_rules.pro
-keepclasseswithmembers class com.tflite.** {*;}
-keepclasseswithmembers class com.mrousavy.camera.** { *; }
-keepclasseswithmembers class com.worklets.** { *; }
//dexguard version and config
dexguard {
version = '9.3.7'
license = './lib/Dexguard/dexguard-license.txt'
configurations {
release {
defaultConfiguration 'dexguard-release.pro'
configuration 'dexguard-project.pro'
}
}
}
Hey @mrousavy ,
I have been working with a model which expects input in the following format.
I have used the frame processor from react-native-vision-camera
const frameProcessor = useFrameProcessor(
frame => {
'worklet';
runAtTargetFps(1, () => {
'worklet';
if (actualModel == null) {
// model is still loading...
return;
}
const resized = resize(frame, {
size: {
width: 768,
height: 768,
},
pixelFormat: 'rgb-uint8',
});
const result = actualModel.runSync([new Uint8Array(resized)]);
console.log('result--->', result);
});
},
[actualModel],
);
My model is running and giving the same output for every frame. Can you help with that ?
ERROR Error: The package 'react-native-fast-tflite' doesn't seem to be linked. Make sure:
Can you please add support for Expo react native?
my question is where the label map ? and can we make app that request to camera for object detection ?
Showing Recent Errors Only
Building for 'iOS-simulator', but linking in object file (/Users/vemarav/Developer/example/node_modules/react-native-fast-tflite/ios/TensorFlowLiteC.framework/TensorFlowLiteC) built for 'iOS'
After running npx pod-install && yarn ios
on a brand new react native project, I got following error:
** BUILD FAILED **
The following build commands failed:
CompileC /Users/movila/Library/Developer/Xcode/DerivedData/Zproc-brjekwuaqyjzkngtrxtlfqaagxvs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-fast-tflite.build/Objects-normal/arm64/Tflite.o /Users/shbai/Dev/test/rctnative/NewEnv/Zproc/node_modules/react-native-fast-tflite/ios/Tflite.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-fast-tflite' from project 'Pods')
(1 failure)
info Fetching system and libraries information...
System:
OS: macOS 13.6
CPU: (8) arm64 Apple M1 Pro
Memory: 91.20 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.2.0
path: ~/.nvm/versions/node/v20.2.0/bin/node
Yarn:
version: 1.22.19
path: ~/.nvm/versions/node/v20.2.0/bin/yarn
npm:
version: 9.6.6
path: ~/.nvm/versions/node/v20.2.0/bin/npm
Watchman:
version: 2023.09.04.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 3.2.2
path: /Users/movila/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.6
wanted: 0.72.6
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: true
I also tried #26118 (comment), still not working.
I am working with img labling project and need guidance on processing local images from the file system. How can I convert these local image files into tensors to pass them as inputs to the functions? and im using expo and it seems like @tensorflow/tfjs-react-native doesnt work with the currunt version of expo
Today, we build TensorFlowLiteC from source to use it in iOS:
react-native-fast-tflite/scripts/build-tensorflow-ios.sh
Lines 13 to 27 in 5b8d612
The source code is added to this repo as a git submodule (tensorflow/
), and when shipping the library to npm I prebuild a TensorFlowLiteC binary (including the TensorFlowLiteCCoreML delegate), add the headers, then ship it.
On Android however, we use the org.tensorflow:tensorflow-lite
library from Gradle:
react-native-fast-tflite/android/build.gradle
Lines 125 to 128 in 5b8d612
Instead, we should aim to also use TensorFlowLiteC (any potentially also an Android GPU delegate?) from source by also building it in the tensorflow/
submodule, just like how we do it on iOS, then add the headers and link the library in the android/CMakeLists.txt
config.
This would align the versions perfectly and we don't need to fetch a prebuild version from Maven.
This PR was an attempt at doing so: #33 ...but I couldn't manage to get Bazel to build the Android version.
We need to make sure this ships the correct binaries (x86, x86_64, arm, and arm64 - or just x86_fat and arm_fat).
Added Bonus: Maybe we can even do the whole building in the CI with dependabot, so everytime the submodule changes (a commit lands on main in tensorflow/
) it opens a PR, prebuilds the libraries, moves them into ios
and android
, and I only need to merge that to get the changes. No need to build it on my mac. Makes it even more safe
I tried:
import my_tflite_model from "../../../assets/MyDetection.tflite";
import my_tflite_model = require("../../../assets/MyDetection.tflite");
const my_tflite_model = require("../../../assets/MyDetection.tflite");
const my_tflite_model = useTensorflowModel(require("../../../assets/MyDetection.tflite"));
const my_tflite_model = loadTensorflowModel(require("../../../assets/MyDetection.tflite"));
Before that, I did:
yarn add react-native-fast-tflite
tflite
to module.exports. resolver. assetExts
in metro.config.js
.MyDetection.tflite
to the ../../../assets
folder.Em,
How can I use this library? (I just want to create a function that can run my model.)
Problem Description:
When attempting to load a TensorFlow 1 model, an error occurs with the message "Failed to load Tensorflow Model 1! [TypeError: right operand of 'in' is not an object]".
Expected Behavior:
Expected the TensorFlow 1 model to load successfully without any errors.
Reproduction Steps:
Run the application/script where an attempt to load the TensorFlow 1 model is made.
Observe the error message "Failed to load Tensorflow Model 1! [TypeError: right operand of 'in' is not an object]".
Actual Behavior:
Instead of successfully loading the model, an error occurs with the message "Failed to load Tensorflow Model 1! [TypeError: right operand of 'in' is not an object]".
Additional Information:
Device: iPhone 14 Pro Max
CoreML: disabled
Model: from your demo (model_movenet_singlepose_lightning_tflite_int8_4)
"dependencies": {
"@shopify/react-native-skia": "^0.1.202",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-fast-tflite": "^0.3.0",
"react-native-vision-camera": "^3.0.0-rc.8",
"react-native-worklets-core": "^0.2.0"
},
On iOS, we currently build TensorFlowLiteC from source. This builds a fat iOS binary:
react-native-fast-tflite/scripts/build-tensorflow-ios.sh
Lines 16 to 17 in 5b8d612
..for some reason users have reported that this does not work when running the app on an iOS Simulator on a Intel x86 Mac.
I don't have such Mac anymore, but I am not sure what's going wrong - maybe there is a way to also build for x86?
I setup everything, also I use face detection, its work perfectly.
But this package not worked. I get this error TypeError: Cannot read property 'runSync' of undefined . I try to implement this code:
const model = useTensorflowModel(require('object_detection.tflite'))
const frameProcessor = useFrameProcessor((frame) => {
'worklet'
if (model.state !== "loaded") return
const data = frame.toArrayBuffer()
// do RGB conversion if the Frame is not already in RGB Format
const outputs = model.model.runSync([data])
const detection_boxes = outputs[0]
const detection_classes = outputs[1]
const detection_scores = outputs[2]
const num_detections = outputs[3]
console.log(`Detected ${num_detections[0]} objects!`)
for (let i = 0; i < detection_boxes.length; i += 4) {
const confidence = detection_scores[i / 4]
if (confidence > 0.7) {
// Draw a red box around the object!
const left = detection_boxes[i]
const top = detection_boxes[i + 1]
const right = detection_boxes[i + 2]
const bottom = detection_boxes[i + 3]
const rect = SkRect.Make(left, top, right, bottom)
frame.drawRect(rect, SkColors.Red)
}
}
}, [model])
return (
<Camera frameProcessor={frameProcessor} {...otherProps} />
)
can you help me?
Hello,
I 've modify this example https://github.com/tensorflow/tfjs-examples/tree/master/react-native/image-classification/expo
in order to use a .tflite model following your instructions.
When I run de project i get the following error:
Error: The package 'react-native-fast-tflite' doesn't seem to be linked. Make sure:
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules@react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\metro-runtime\src\polyfills\require.js:203:6 in guardedLoadModule
at http://192.168.1.17:19000/index.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:297699:3 in global code
Invariant Violation: "main" has not been registered. This can happen if:
AppRegistry.registerComponent
wasn't called.โบ Opening on Android...
โบ Opening exp://192.168.1.17:19000 on 22041216G
โบ Press ? โ show all commands
โบ Opening on Android...
โบ Opening exp://192.168.1.17:19000 on 22041216G
โบ Press ? โ show all commands
Android Bundling complete 74ms
Android Running app on 22041216G
Invariant Violation: "main" has not been registered. This can happen if:
AppRegistry.registerComponent
wasn't called.Error: The package 'react-native-fast-tflite' doesn't seem to be linked. Make sure:
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules@react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\metro-runtime\src\polyfills\require.js:203:6 in guardedLoadModule
at http://192.168.1.17:19000/index.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:297699:3 in global code
Can you please help on this issue?
Regards.
Hi bro,
I have a model that supports dynamic shape, but tflite does not support it when converting, but it does support it from the code.
Doc from TFL
https://www.tensorflow.org/lite/guide/inference#run_inference_with_dynamic_shape_model
If you want to run a model with dynamic input shape, resize the input shape before running inference. Otherwise, the None shape in Tensorflow models will be replaced by a placeholder of 1 in TFLite models.
The following examples show how to resize the input shape before running inference in different languages. All the examples assume that the input shape is defined as [1/None, 10], and need to be resized to [3, 10].
// Resize input tensors before allocate tensors
interpreter->ResizeInputTensor(/*tensor_index=*/0, std::vector<int>{3,10});
interpreter->AllocateTensors();
How to operate with react-native-fast-tflite
I enabled the GPU Delegates in app.json, and I have $EnableCoreMLDelegate=true in my Podfile, yet when I try to load the example model in the README (using the exact same code), I get the following error:
ERROR Failed to load Tensorflow Model 14! [Error: Failed to create TFLite interpreter from model "http://192.168.1.79:8081/assets/assets/models/efficientdet.tflite?platform=ios&hash=8c27d0eef1a3447e68f5704859bdc418"!]
Note that I do not get this error when I don't use 'core-ml' in loadTensorflowModel
.
I'm using iPhone 7 Plus with iOS 14.4.2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.