18
18
19
19
import android .content .res .AssetManager ;
20
20
import android .os .Trace ;
21
+ import android .support .v4 .os .TraceCompat ;
21
22
import android .util .Log ;
22
23
23
24
import org .tensorflow .contrib .android .TensorFlowInferenceInterface ;
@@ -120,23 +121,23 @@ public static Classifier create(
120
121
@ Override
121
122
public List <Recognition > recognizeImage (final float [] pixels ) {
122
123
// Log this method so that it can be analyzed with systrace.
123
- Trace .beginSection ("recognizeImage" );
124
+ TraceCompat .beginSection ("recognizeImage" );
124
125
125
126
// Copy the input data into TensorFlow.
126
- Trace .beginSection ("fillNodeFloat" );
127
+ TraceCompat .beginSection ("fillNodeFloat" );
127
128
inferenceInterface .fillNodeFloat (
128
129
inputName , new int []{inputSize * inputSize }, pixels );
129
- Trace .endSection ();
130
+ TraceCompat .endSection ();
130
131
131
132
// Run the inference call.
132
- Trace .beginSection ("runInference" );
133
+ TraceCompat .beginSection ("runInference" );
133
134
inferenceInterface .runInference (outputNames );
134
- Trace .endSection ();
135
+ TraceCompat .endSection ();
135
136
136
137
// Copy the output Tensor back into the output array.
137
- Trace .beginSection ("readNodeFloat" );
138
+ TraceCompat .beginSection ("readNodeFloat" );
138
139
inferenceInterface .readNodeFloat (outputName , outputs );
139
- Trace .endSection ();
140
+ TraceCompat .endSection ();
140
141
141
142
// Find the best classifications.
142
143
PriorityQueue <Recognition > pq =
@@ -161,7 +162,7 @@ public int compare(Recognition lhs, Recognition rhs) {
161
162
for (int i = 0 ; i < recognitionsSize ; ++i ) {
162
163
recognitions .add (pq .poll ());
163
164
}
164
- Trace .endSection (); // "recognizeImage"
165
+ TraceCompat .endSection (); // "recognizeImage"
165
166
return recognitions ;
166
167
}
167
168
0 commit comments