GithubHelp home page GithubHelp logo

barongeng / caffe-android-lib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quhezheng/caffe-android-lib

0.0 2.0 0.0 8.78 MB

Porting caffe opencl to android platform

License: Other

C 4.88% CMake 1.93% Shell 0.51% Java 0.10% Makefile 0.40% C++ 38.01% PowerShell 0.02% HTML 0.06% CSS 0.08% Jupyter Notebook 46.17% Python 3.73% Cuda 3.73% MATLAB 0.29% Batchfile 0.09%

caffe-android-lib's Introduction

Caffe-Android-Lib (OpenCL)

Goal

Porting caffe OpenCL to android platform

Support

  • Up-to-date caffe
  • CPU & GPU
  • No support for hdf5

Build

On local machine

Tested with XiaoMi 5, Android NDK r15c and cmake 3.5.1 on Ubuntu 16.06

Install NDK r15c

wget https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip
sudo unzip android-ndk-r15c-linux-x86_64.zip -d /etc

Download target libOpenCL.so from your Andriod device by adb. Normally under /vendor/lib64/libOpenCL.so

adb pull /vendor/lib64/libOpenCL.so  ~/

Start building

git clone --recursive https://github.com/quhezheng/caffe-android-lib.git
cd caffe-android-lib
export ANDROID_ABI=arm64-v8a
export NDK_ROOT=/etc/android-ndk-r15c  (or /your/path/to/ndk)
cp ~/libOpenCL.so android_lib/opencl-android/lib
./build.sh

There it will be *.so *.a libaray under caffe-android-lib/caffe/build/lib

NOTE: OpenBLAS

OpenBLAS is the only supported BLAS choice now, and the supported ABIs are the following:

  • armeabi
  • armeabi-v7a
  • arm64-v8a (default)
  • x86
  • x86_64

Issues

Any comments, issues or PRs are welcomed. Thanks.

TODO

  • Integrate using CMake's ExternalProject
  • Support HDF5

Caffe-Android-Demo (App)

Goal

Demo Andriod app to run caffe on cell phone's GPU.

Support

  • App to load caffe demo model to recognize picture (Camera)
  • CPU & GPU
  • Debug caffe C++ code on cell phone (PC as host)
  • XiaoMi 5 (Tested by this repository)

Setup & Build

Link caffe native C++ code to Android project

cd caffe-android-lib/caffe-android-demo/app/caffe-opencl
./link.sh

Android studio 2.3.3

cd ~/Downloads
wget https://dl.google.com/dl/android/studio/ide-zips/2.3.3.0/android-studio-ide-162.4069837-linux.zip
sudo unzip android-studio-ide-162.4069837-linux.zip -d /etc
  • start Android studio
cd /etc/android-studio/bin
./studio.sh
  • click 'import project(Eclipse ADT, Gradle, etc.)', brown to 'caffe-android-lib/caffe-android-demo', click 'OK' to open the project. Wait a few minutes to finish gradle building...

  • Build the project by menu 'Build -->Make Project'

  • Collect *.so files into target lib

cd YOUR/PATH/OF/caffe-android-lib/caffe-android-demo/app
cp .externalNativeBuild/cmake/release/arm64-v8a/lib/libcaffe.so src/main/jniLibs
cp .externalNativeBuild/cmake/release/arm64-v8a/lib/libcaffe_jni.so src/main/jniLibs

Deploye Caffe Model on Cell Phone

Connect USB cable between your PC and Cell phone

# Download googlenet
cd YOUR/PATH/OF/caffe-android-lib/caffe
./scripts/download_model_binary.py models/bvlc_googlenet/
# push things to your device
adb shell mkdir -p /sdcard/caffe_mobile/
adb push models/bvlc_googlenet/ /sdcard/caffe_mobile/bvlc_googlenet/

Debug C++

  • Connect USB cable between your PC and Cell phone
  • Setup a break point in a C++ code file from inside Android studio. Click 'Debug' buton in Android studio...

caffe-android-lib's People

Contributors

sh1r0 avatar quhezheng avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.