Skip to content

Commit 62ca792

Browse files
author
Persie
committed
upgraded dependencies
1 parent 2c0b843 commit 62ca792

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

android/build.gradle

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ android {
5454
}
5555
dependencies{
5656
implementation 'com.github.vladiH:opencv-android:v1.0.0'
57-
implementation 'org.tensorflow:tensorflow-lite:2.10.0'
58-
implementation 'org.tensorflow:tensorflow-lite-api:2.10.0'
59-
implementation 'org.tensorflow:tensorflow-lite-gpu:2.10.0'
60-
implementation 'org.tensorflow:tensorflow-lite-gpu-api:2.10.0'
61-
implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.3'
62-
implementation 'org.tensorflow:tensorflow-lite-support:0.4.3'
63-
implementation 'org.tensorflow:tensorflow-lite-metadata:0.4.3'
64-
implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:2.11.0'
57+
implementation 'com.google.ai.edge.litert:litert:1.1.2'
58+
implementation 'com.google.ai.edge.litert:litert-api:1.1.2'
59+
implementation 'com.google.ai.edge.litert:litert-gpu:1.1.2'
60+
implementation 'com.google.ai.edge.litert:litert-gpu-api:1.1.2'
61+
implementation 'com.google.ai.edge.litert:litert-support:1.1.2'
62+
implementation 'com.google.ai.edge.litert:litert-metadata:1.1.2'
6563
}

android/src/main/java/com/vladih/computer_vision/flutter_vision/models/Yolo.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import android.util.Log;
99

1010
import org.tensorflow.lite.Interpreter;
11-
import org.tensorflow.lite.Tensor;
1211
import org.tensorflow.lite.gpu.CompatibilityList;
1312
import org.tensorflow.lite.gpu.GpuDelegate;
14-
import org.tensorflow.lite.gpu.GpuDelegateFactory;
1513

1614
import java.io.BufferedReader;
1715
import java.io.FileInputStream;
@@ -59,12 +57,6 @@ public Yolo(Context context,
5957
this.rotation = rotation;
6058
}
6159

62-
public Tensor getInputTensor() {
63-
if (interpreter == null) return null;
64-
return this.interpreter.getInputTensor(0);
65-
}
66-
67-
6860
public void initialize_model() throws Exception {
6961
AssetManager asset_manager = null;
7062
MappedByteBuffer buffer;
@@ -89,17 +81,17 @@ public void initialize_model() throws Exception {
8981
buffer = file_channel.map(FileChannel.MapMode.READ_ONLY, 0, file_channel.size());
9082
}
9183

84+
// Initialize interpreter with GPU delegate
9285
Interpreter.Options interpreterOptions = new Interpreter.Options();
93-
CompatibilityList compatibilityList = new CompatibilityList();
86+
CompatibilityList compatList = new CompatibilityList();
9487

95-
if (use_gpu && compatibilityList.isDelegateSupportedOnThisDevice()) {
88+
if (use_gpu && compatList.isDelegateSupportedOnThisDevice()) {
9689
try {
97-
GpuDelegateFactory.Options delegateOptions = compatibilityList.getBestOptionsForThisDevice();
98-
GpuDelegate gpuDelegate = new GpuDelegate(delegateOptions.setQuantizedModelsAllowed(this.quantization));
90+
GpuDelegate.Options delegateOptions = compatList.getBestOptionsForThisDevice();
91+
GpuDelegate gpuDelegate = new GpuDelegate(delegateOptions);
9992
interpreterOptions.addDelegate(gpuDelegate);
10093
} catch (Exception e) {
10194
Log.e("Yolo", "GPU delegate failed, falling back to CPU", e);
102-
interpreterOptions = new Interpreter.Options();
10395
interpreterOptions.setNumThreads(num_threads);
10496
}
10597
} else {
@@ -266,9 +258,6 @@ protected static List<float[]> nms(List<float[]> boxes, float iou_threshold) {
266258
}
267259
}
268260

269-
public boolean isInitialized() {
270-
return interpreter != null;
271-
}
272261

273262

274263
protected List<float[]> restore_size(List<float[]> nms,

0 commit comments

Comments
 (0)