Skip to content

Commit 0128fef

Browse files
committed
Use TraceCompat instead of Trace
This will work on API levels less than 18
1 parent 7bb4758 commit 0128fef

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/src/main/java/com/mindorks/tensorflowexample/TensorFlowImageClassifier.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.content.res.AssetManager;
2020
import android.os.Trace;
21+
import android.support.v4.os.TraceCompat;
2122
import android.util.Log;
2223

2324
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
@@ -120,23 +121,23 @@ public static Classifier create(
120121
@Override
121122
public List<Recognition> recognizeImage(final float[] pixels) {
122123
// Log this method so that it can be analyzed with systrace.
123-
Trace.beginSection("recognizeImage");
124+
TraceCompat.beginSection("recognizeImage");
124125

125126
// Copy the input data into TensorFlow.
126-
Trace.beginSection("fillNodeFloat");
127+
TraceCompat.beginSection("fillNodeFloat");
127128
inferenceInterface.fillNodeFloat(
128129
inputName, new int[]{inputSize * inputSize}, pixels);
129-
Trace.endSection();
130+
TraceCompat.endSection();
130131

131132
// Run the inference call.
132-
Trace.beginSection("runInference");
133+
TraceCompat.beginSection("runInference");
133134
inferenceInterface.runInference(outputNames);
134-
Trace.endSection();
135+
TraceCompat.endSection();
135136

136137
// Copy the output Tensor back into the output array.
137-
Trace.beginSection("readNodeFloat");
138+
TraceCompat.beginSection("readNodeFloat");
138139
inferenceInterface.readNodeFloat(outputName, outputs);
139-
Trace.endSection();
140+
TraceCompat.endSection();
140141

141142
// Find the best classifications.
142143
PriorityQueue<Recognition> pq =
@@ -161,7 +162,7 @@ public int compare(Recognition lhs, Recognition rhs) {
161162
for (int i = 0; i < recognitionsSize; ++i) {
162163
recognitions.add(pq.poll());
163164
}
164-
Trace.endSection(); // "recognizeImage"
165+
TraceCompat.endSection(); // "recognizeImage"
165166
return recognitions;
166167
}
167168

0 commit comments

Comments
 (0)