Skip to content

Commit

Permalink
feat: Upgraded and pre-compiled TFLite binaries for both iOS and Andr…
Browse files Browse the repository at this point in the history
…oid (#85)

* Updated example app dependencies to work with latest Xcode.

* Use ios binaries from TensorFlowLiteC pod instead of having the TFLite binaries in the repo.

* Use android binaries from the maven repository and headers from the tensorflow repo.

* Generated new Podfile.lock

* Build for iPhone 15 Pro

---------

Co-authored-by: Per Stråkendal <[email protected]>
  • Loading branch information
PStrakendal and Per Stråkendal authored Sep 9, 2024
1 parent 1d73f8a commit 35d7cbd
Show file tree
Hide file tree
Showing 28 changed files with 54 additions and 4,588 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ jobs:
-scheme TfliteExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11 Pro' \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
build \
CODE_SIGNING_ALLOWED=NO | xcpretty"
2 changes: 1 addition & 1 deletion android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ target_include_directories(
PRIVATE
"../cpp"
"src/main/cpp"
"src/main/cpp/lib/tensorflow/headers/"
"../tensorflow/"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper
Expand Down
25 changes: 4 additions & 21 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,12 @@ dependencies {
implementation "com.facebook.react:react-native:+"

// Tensorflow Lite .aar (includes C API via prefabs)
implementation "org.tensorflow:tensorflow-lite:2.12.0"
extractHeaders("org.tensorflow:tensorflow-lite:2.12.0")
extractSO("org.tensorflow:tensorflow-lite:2.12.0")
implementation "org.tensorflow:tensorflow-lite:2.16.1"
extractSO("org.tensorflow:tensorflow-lite:2.16.1")

// Tensorflow Lite GPU delegate
implementation "org.tensorflow:tensorflow-lite-gpu:2.12.0"
extractHeaders("org.tensorflow:tensorflow-lite-gpu:2.12.0")
extractSO("org.tensorflow:tensorflow-lite-gpu:2.12.0")
}

task extractAARHeaders {
doLast {
configurations.extractHeaders.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "src/main/cpp/lib/$packageName/"
include "**/*.h"
}
}
}
implementation "org.tensorflow:tensorflow-lite-gpu:2.16.1"
extractSO("org.tensorflow:tensorflow-lite-gpu:2.16.1")
}

task extractSOFiles {
Expand Down Expand Up @@ -182,6 +166,5 @@ def nativeBuildDependsOn(dependsOnTask) {
}

afterEvaluate {
nativeBuildDependsOn(extractAARHeaders)
nativeBuildDependsOn(extractSOFiles)
}
38 changes: 27 additions & 11 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,13 @@ PODS:
- React-Mapbuffer (0.73.3):
- glog
- React-debug
- react-native-fast-tflite (1.2.0):
- react-native-fast-tflite (1.3.0):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- react-native-worklets-core (0.3.0):
- TensorFlowLiteC (= 2.17.0)
- TensorFlowLiteC/CoreML (= 2.17.0)
- react-native-worklets-core (1.2.0):
- React
- React-callinvoker
- React-Core
Expand Down Expand Up @@ -1062,16 +1064,28 @@ PODS:
- React-logger (= 0.73.3)
- React-perflogger (= 0.73.3)
- SocketRocket (0.6.1)
- vision-camera-resize-plugin (2.0.1):
- TensorFlowLiteC (2.17.0):
- TensorFlowLiteC/Core (= 2.17.0)
- TensorFlowLiteC/Core (2.17.0)
- TensorFlowLiteC/CoreML (2.17.0):
- TensorFlowLiteC/Core
- vision-camera-resize-plugin (3.1.0):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- VisionCamera
- VisionCamera (3.8.2):
- VisionCamera (4.0.3):
- VisionCamera/Core (= 4.0.3)
- VisionCamera/FrameProcessors (= 4.0.3)
- VisionCamera/React (= 4.0.3)
- VisionCamera/Core (4.0.3)
- VisionCamera/FrameProcessors (4.0.3):
- React
- React-callinvoker
- React-Core
- react-native-worklets-core
- VisionCamera/React (4.0.3):
- React-Core
- VisionCamera/FrameProcessors
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1136,6 +1150,7 @@ SPEC REPOS:
- fmt
- libevent
- SocketRocket
- TensorFlowLiteC

EXTERNAL SOURCES:
boost:
Expand Down Expand Up @@ -1274,8 +1289,8 @@ SPEC CHECKSUMS:
React-jsinspector: 6fad0fe14882fb6b1c32e5cc8a4bd3d33a8b6790
React-logger: cb0dd15ac67b00e7b771ef15203edcb29d4a3f8e
React-Mapbuffer: d59258be3b0d2280c6ba8964ab6e36ec69211871
react-native-fast-tflite: a9574c72f0d3e9efb916953926d089f65326c66b
react-native-worklets-core: a894d572639fcf37c6d284cc799882d25d00c93d
react-native-fast-tflite: b39b2ff96fea7891006ba5cedda261c39fd748b2
react-native-worklets-core: a316975bba20b73d47aa4d41bffb0ca984ba592e
React-nativeconfig: 4d3076dc3dc498ec49819e4e4225b55d3507f902
React-NativeModulesApple: 46f14baf36010b22ffd84fd89d5586e4148edfb3
React-perflogger: 27ccacf853ba725524ef2b4e444f14e34d0837b0
Expand All @@ -1297,10 +1312,11 @@ SPEC CHECKSUMS:
React-utils: b22b4a51aa578b3aac1e7c19501c0b9ba358ed79
ReactCommon: e708b8be8cb317b83e31c6ccfeda8bf6c0d1a2b3
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
vision-camera-resize-plugin: 536345c29f42e04438d34d0cada7b4992a8fc104
VisionCamera: edbcd00e27a438b2228f67823e2b8d15a189065f
Yoga: 08cd7601462818c4985bda7b205b9e6a92a7e66a
TensorFlowLiteC: eac6d689a8d391d1b202dc59e3d9165ba64aaf73
vision-camera-resize-plugin: 525763ad8f20ff9e58984ee4d5aceb50ec22ce4c
VisionCamera: b633f90960feab2669b7a1c51f8a201dd0a5bfc3
Yoga: ff0382b894475dba0b4d2a5fda860bfee5a9afad

PODFILE CHECKSUM: 33c2f84b68c18fe6787cbe3e723675d15fcc7e66

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.3",
"react-native-vision-camera": "^3.8.2",
"react-native-worklets-core": "^0.3.0",
"vision-camera-resize-plugin": "^2.0.1"
"react-native-vision-camera": "4.0.3",
"react-native-worklets-core": "1.2.0",
"vision-camera-resize-plugin": "3.1.0"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand Down
24 changes: 12 additions & 12 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5830,15 +5830,15 @@ react-is@^17.0.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-native-vision-camera@^3.8.2:
version "3.8.2"
resolved "https://registry.yarnpkg.com/react-native-vision-camera/-/react-native-vision-camera-3.8.2.tgz#f4f75f84c6a19e1c3474ddc0f7f785b5a526739b"
integrity sha512-MY39l2e3hNRPUefn2JPShOFExcw0PblbAcUGvJrIfS9pMzdIyceo0umRAx8lOGXzDUAdb+xy/tFWb8zGxKimCQ==
react-native-vision-camera@4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/react-native-vision-camera/-/react-native-vision-camera-4.0.3.tgz#185e278bf3654f11a2878a3e4deb3369935627f8"
integrity sha512-scDSSVtd5OVMJrwhio/TcBw+h33XssJM+ANv3sdw7pH8dNQPRsHO1J32f0F/AAhudfdwffv7kAHB0Efe4nUl7g==

react-native-worklets-core@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/react-native-worklets-core/-/react-native-worklets-core-0.3.0.tgz#4d6c4c4999d3bf2f8c67fa46fdd70d8b5bc7ba0e"
integrity sha512-bOoo6xbl+f+mz0Q65bLkUP3FxgYt7f/Bzi0c5Yj8Ix4vQCKMtgHwafrqCNRhW32N7TpTv3+zOoyQMJwQVr/frQ==
react-native-worklets-core@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/react-native-worklets-core/-/react-native-worklets-core-1.2.0.tgz#155040a48d1e3f66107544867ec579c2f5044271"
integrity sha512-Uuf1Hg4V1w4I8eYNinwnnf+h+2YdQgwkUDQszY2yEEXWPWcZBWec0xjYn079RFRcKmGWuJ/zOtokjwy/IjJ9Fw==
dependencies:
string-hash-64 "^1.0.3"

Expand Down Expand Up @@ -6646,10 +6646,10 @@ vary@~1.1.2:
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==

vision-camera-resize-plugin@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vision-camera-resize-plugin/-/vision-camera-resize-plugin-2.0.1.tgz#3f96b66993f015ec8fecc94be5444c6bacd7198e"
integrity sha512-l1HB0BVuhPhc4jfTysP0bmUqVwYqrXR5as3T2OcOU0fUFhKo8Li/gfGyuCxJ3oEacOgQzDJJvFb1IRWES1XELA==
vision-camera-resize-plugin@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/vision-camera-resize-plugin/-/vision-camera-resize-plugin-3.1.0.tgz#6e5b773396bab2c92ecec896c3ee7812540a6d24"
integrity sha512-KKW5c5GCP+SCr4r8O3cg14lqDe4OSWAmRoY1YICYuv01wRVlDTavEmkWfuqjtcSAgU8EAXL76gM9GVCyWme6KQ==

vlq@^1.0.0:
version "1.0.1"
Expand Down
11 changes: 0 additions & 11 deletions ios/TensorFlowLiteC.framework/Headers/TensorFlowLiteC.h

This file was deleted.

Loading

0 comments on commit 35d7cbd

Please sign in to comment.