Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all architectures using 'org.tensorflow:tensorflow-android' dependency #1

Merged
merged 3 commits into from
Sep 2, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use TraceCompat instead of Trace
This will work on API levels less than 18
  • Loading branch information
daj committed Aug 13, 2017
commit 0128fef74a6d33de0f7f3f6953f5c7c364c8b6ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.content.res.AssetManager;
import android.os.Trace;
import android.support.v4.os.TraceCompat;
import android.util.Log;

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

// Copy the input data into TensorFlow.
Trace.beginSection("fillNodeFloat");
TraceCompat.beginSection("fillNodeFloat");
inferenceInterface.fillNodeFloat(
inputName, new int[]{inputSize * inputSize}, pixels);
Trace.endSection();
TraceCompat.endSection();

// Run the inference call.
Trace.beginSection("runInference");
TraceCompat.beginSection("runInference");
inferenceInterface.runInference(outputNames);
Trace.endSection();
TraceCompat.endSection();

// Copy the output Tensor back into the output array.
Trace.beginSection("readNodeFloat");
TraceCompat.beginSection("readNodeFloat");
inferenceInterface.readNodeFloat(outputName, outputs);
Trace.endSection();
TraceCompat.endSection();

// Find the best classifications.
PriorityQueue<Recognition> pq =
Expand All @@ -161,7 +162,7 @@ public int compare(Recognition lhs, Recognition rhs) {
for (int i = 0; i < recognitionsSize; ++i) {
recognitions.add(pq.poll());
}
Trace.endSection(); // "recognizeImage"
TraceCompat.endSection(); // "recognizeImage"
return recognitions;
}

Expand Down