This is an old revision of the document!
android tensor flow projects 01
prereq
bazel
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - sudo apt-get update && sudo apt-get install bazel
- android sdk (in /opt/android-sdk)
- android ndk 14b from here as newer versions (or android-studio bundle) are not compatible with bazel (in /opt/android-ndk)
tensorflow
clone github tensorflow and build
cd /lab git clone --depth 1 https://github.com/tensorflow/tensorflow.git tensorflow.git cd tensorflow.git
update WORKSPACE file
android_sdk_repository( name = "androidsdk", api_level = 25, # Ensure that you have the build_tools_version below installed in the # SDK manager as it updates periodically. build_tools_version = "26.0.1", # Replace with path to Android SDK on your system path = "/opt/android-sdk", ) # android_ndk_repository( name="androidndk", path="/opt/android-ndk-r14b", # This needs to be 14 or higher to compile TensorFlow. # Please specify API level to >= 21 to build for 64-bit # archtectures or the Android NDK will automatically select biggest # API level that it supports without notice. # Note that the NDK version is not the API level. api_level=25)
build demo
bazel build -c opt //tensorflow/examples/android:tensorflow_demo
azainab TF detect project
git clone https://github.com/azainab/androidTFDetect/ cd androidTFDetect # download assets from https://drive.google.com/file/d/0B4dPZkgiYl-SWW1TNTBpNUtKbGs/view?usp=sharing cd assets unzip ~/Scaricati/Place\ in\ assets\ folder.zip
import project in android studio
- txt
buildscript { repositories { google() // Gradle 4.0+ maven { url "https://maven.google.com" } // Gradle < 4.0 jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'org.apache.httpcomponents:httpclient:4.5.2' } }