Demonstration of using Caffe2 inside an Android application.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 4 commits ahead of caffe2:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
app
gradle/wrapper
.gitignore
Exporting Squeezenet to mobile.ipynb
LICENSE
README.md
README.orig.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Caffe2 AICamera tutorial example

This is an example for using Caffe2 on Android. See the original README for details.

Using caffe2 from PyTorch master

Newer android seems to prefer clang, at least I couldn't find the gnu stl lib.

To compile libs for armeabi-v7a I used

ANDROID_NDK=~/Android/Sdk/ndk-bundle/ ./scripts/build_android.sh -DANDROID_TOOLCHAIN=clang

For x86 (useful to debug android apps) I needed to disable AVX. To do this, I inserted if (NOT DISABLE_AVX) and endif() before and after the AVX check in cmake/MiscCheck.cmake.

I then built with

ANDROID_NDK=~/Android/Sdk/ndk-bundle/ BUILD_ROOT=$(pwd)/build_android_x86   ./scripts/build_android.sh -DANDROID_TOOLCHAIN=clang  -DANDROID_ABI=x86 -DDISABLE_AVX=1

Then I copied the resulting build_android*/lib/lib* into the corresponding x86 and armeabi-v7a subdirectories of app/src/main/jniLibs.

You would likely want to replace the headers in app/src/main/cpp with those from torch/lib/include or so (possibly after building PyTorch).