How to do it...

We proceed with installing TensorFlow mobile for macOS and Android as follows:

  1. Install Android Studio from https://developer.android.com/studio/install.html.
  1.  Create a new project name AndroidExampleTensorflow as illustrated in the following screenshot:

An example of creating TensorFlow mobile application in AndroidStudio, first step Select Phone and Table option as explained in the following figure:

An example of creating TensorFlow mobile application in AndroidStudio, second step And select an Empty activity as shown in the following figure:

An example of creating TensorFlow mobile application in AndroidStudio, third step Then customize the MainActivity as shown in the following figure:

An example of creating TensorFlow mobile application in AndroidStudio, fourth step
  1. Insert the following lines in your build.gradle app, as illustrated in the following code:
// added for automatically connect to TensorFlow via maven
repositories {
jcenter()
maven {
url 'https://google.bintray.com/TensorFlow'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
// added for automatically compile TensorFlow
compile 'org.TensorFlow:TensorFlow-android:+'
testCompile 'junit:junit:4.12'
}

The following screenshot shows the code inserted:

  1. Run the project and get the results:

An example of compilation with the AndroidStudio, showing the connected devices.

An example of creating TensorFlow mobile application in AndroidStudio. A simple Hello World application

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset