Skip to content

Commit 35d7cbd

Browse files
PStrakendalPer Stråkendal
andauthored
feat: Upgraded and pre-compiled TFLite binaries for both iOS and Android (#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]>
1 parent 1d73f8a commit 35d7cbd

28 files changed

+54
-4588
lines changed

.github/workflows/build-ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ jobs:
7575
-scheme TfliteExample \
7676
-sdk iphonesimulator \
7777
-configuration Debug \
78-
-destination 'platform=iOS Simulator,name=iPhone 11 Pro' \
78+
-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
7979
build \
8080
CODE_SIGNING_ALLOWED=NO | xcpretty"

android/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target_include_directories(
4242
PRIVATE
4343
"../cpp"
4444
"src/main/cpp"
45-
"src/main/cpp/lib/tensorflow/headers/"
45+
"../tensorflow/"
4646
"${NODE_MODULES_DIR}/react-native/ReactCommon"
4747
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
4848
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper

android/build.gradle

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,12 @@ dependencies {
123123
implementation "com.facebook.react:react-native:+"
124124

125125
// Tensorflow Lite .aar (includes C API via prefabs)
126-
implementation "org.tensorflow:tensorflow-lite:2.12.0"
127-
extractHeaders("org.tensorflow:tensorflow-lite:2.12.0")
128-
extractSO("org.tensorflow:tensorflow-lite:2.12.0")
126+
implementation "org.tensorflow:tensorflow-lite:2.16.1"
127+
extractSO("org.tensorflow:tensorflow-lite:2.16.1")
129128

130129
// Tensorflow Lite GPU delegate
131-
implementation "org.tensorflow:tensorflow-lite-gpu:2.12.0"
132-
extractHeaders("org.tensorflow:tensorflow-lite-gpu:2.12.0")
133-
extractSO("org.tensorflow:tensorflow-lite-gpu:2.12.0")
134-
}
135-
136-
task extractAARHeaders {
137-
doLast {
138-
configurations.extractHeaders.files.each {
139-
def file = it.absoluteFile
140-
def packageName = file.name.tokenize('-')[0]
141-
copy {
142-
from zipTree(file)
143-
into "src/main/cpp/lib/$packageName/"
144-
include "**/*.h"
145-
}
146-
}
147-
}
130+
implementation "org.tensorflow:tensorflow-lite-gpu:2.16.1"
131+
extractSO("org.tensorflow:tensorflow-lite-gpu:2.16.1")
148132
}
149133

150134
task extractSOFiles {
@@ -182,6 +166,5 @@ def nativeBuildDependsOn(dependsOnTask) {
182166
}
183167

184168
afterEvaluate {
185-
nativeBuildDependsOn(extractAARHeaders)
186169
nativeBuildDependsOn(extractSOFiles)
187170
}

example/ios/Podfile.lock

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,13 @@ PODS:
886886
- React-Mapbuffer (0.73.3):
887887
- glog
888888
- React-debug
889-
- react-native-fast-tflite (1.2.0):
889+
- react-native-fast-tflite (1.3.0):
890890
- glog
891891
- RCT-Folly (= 2022.05.16.00)
892892
- React-Core
893-
- react-native-worklets-core (0.3.0):
893+
- TensorFlowLiteC (= 2.17.0)
894+
- TensorFlowLiteC/CoreML (= 2.17.0)
895+
- react-native-worklets-core (1.2.0):
894896
- React
895897
- React-callinvoker
896898
- React-Core
@@ -1062,16 +1064,28 @@ PODS:
10621064
- React-logger (= 0.73.3)
10631065
- React-perflogger (= 0.73.3)
10641066
- SocketRocket (0.6.1)
1065-
- vision-camera-resize-plugin (2.0.1):
1067+
- TensorFlowLiteC (2.17.0):
1068+
- TensorFlowLiteC/Core (= 2.17.0)
1069+
- TensorFlowLiteC/Core (2.17.0)
1070+
- TensorFlowLiteC/CoreML (2.17.0):
1071+
- TensorFlowLiteC/Core
1072+
- vision-camera-resize-plugin (3.1.0):
10661073
- glog
10671074
- RCT-Folly (= 2022.05.16.00)
10681075
- React-Core
10691076
- VisionCamera
1070-
- VisionCamera (3.8.2):
1077+
- VisionCamera (4.0.3):
1078+
- VisionCamera/Core (= 4.0.3)
1079+
- VisionCamera/FrameProcessors (= 4.0.3)
1080+
- VisionCamera/React (= 4.0.3)
1081+
- VisionCamera/Core (4.0.3)
1082+
- VisionCamera/FrameProcessors (4.0.3):
10711083
- React
10721084
- React-callinvoker
1073-
- React-Core
10741085
- react-native-worklets-core
1086+
- VisionCamera/React (4.0.3):
1087+
- React-Core
1088+
- VisionCamera/FrameProcessors
10751089
- Yoga (1.14.0)
10761090

10771091
DEPENDENCIES:
@@ -1136,6 +1150,7 @@ SPEC REPOS:
11361150
- fmt
11371151
- libevent
11381152
- SocketRocket
1153+
- TensorFlowLiteC
11391154

11401155
EXTERNAL SOURCES:
11411156
boost:
@@ -1274,8 +1289,8 @@ SPEC CHECKSUMS:
12741289
React-jsinspector: 6fad0fe14882fb6b1c32e5cc8a4bd3d33a8b6790
12751290
React-logger: cb0dd15ac67b00e7b771ef15203edcb29d4a3f8e
12761291
React-Mapbuffer: d59258be3b0d2280c6ba8964ab6e36ec69211871
1277-
react-native-fast-tflite: a9574c72f0d3e9efb916953926d089f65326c66b
1278-
react-native-worklets-core: a894d572639fcf37c6d284cc799882d25d00c93d
1292+
react-native-fast-tflite: b39b2ff96fea7891006ba5cedda261c39fd748b2
1293+
react-native-worklets-core: a316975bba20b73d47aa4d41bffb0ca984ba592e
12791294
React-nativeconfig: 4d3076dc3dc498ec49819e4e4225b55d3507f902
12801295
React-NativeModulesApple: 46f14baf36010b22ffd84fd89d5586e4148edfb3
12811296
React-perflogger: 27ccacf853ba725524ef2b4e444f14e34d0837b0
@@ -1297,10 +1312,11 @@ SPEC CHECKSUMS:
12971312
React-utils: b22b4a51aa578b3aac1e7c19501c0b9ba358ed79
12981313
ReactCommon: e708b8be8cb317b83e31c6ccfeda8bf6c0d1a2b3
12991314
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
1300-
vision-camera-resize-plugin: 536345c29f42e04438d34d0cada7b4992a8fc104
1301-
VisionCamera: edbcd00e27a438b2228f67823e2b8d15a189065f
1302-
Yoga: 08cd7601462818c4985bda7b205b9e6a92a7e66a
1315+
TensorFlowLiteC: eac6d689a8d391d1b202dc59e3d9165ba64aaf73
1316+
vision-camera-resize-plugin: 525763ad8f20ff9e58984ee4d5aceb50ec22ce4c
1317+
VisionCamera: b633f90960feab2669b7a1c51f8a201dd0a5bfc3
1318+
Yoga: ff0382b894475dba0b4d2a5fda860bfee5a9afad
13031319

13041320
PODFILE CHECKSUM: 33c2f84b68c18fe6787cbe3e723675d15fcc7e66
13051321

1306-
COCOAPODS: 1.14.3
1322+
COCOAPODS: 1.15.2

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"dependencies": {
1313
"react": "18.2.0",
1414
"react-native": "0.73.3",
15-
"react-native-vision-camera": "^3.8.2",
16-
"react-native-worklets-core": "^0.3.0",
17-
"vision-camera-resize-plugin": "^2.0.1"
15+
"react-native-vision-camera": "4.0.3",
16+
"react-native-worklets-core": "1.2.0",
17+
"vision-camera-resize-plugin": "3.1.0"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "^7.23.9",

example/yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5830,15 +5830,15 @@ react-is@^17.0.1:
58305830
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
58315831
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
58325832

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

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

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

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

66546654
vlq@^1.0.0:
66556655
version "1.0.1"

ios/TensorFlowLiteC.framework/Headers/TensorFlowLiteC.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)