wavejava / caffe-android-lib

Porting caffe to android platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caffe-Android-Lib

Goal

Porting caffe to android platform

Build

git clone --recursive https://github.com/sh1r0/caffe-android-lib.git
cd caffe-android-lib
./build.py $(NDK_PATH)

Usage

  • put required stuff into your device

     ./get_model.py
     adb shell mkdir -p /sdcard/caffe_mobile/
     adb push caffe-mobile/jni/caffe/models/bvlc_reference_caffenet/ /sdcard/caffe_mobile/bvlc_reference_caffenet/
    
  • copy caffe-mobile/libs/armeabi-v7a/*.so to your jni lib directory

  • in your main activity

     static {
     	System.loadLibrary("caffe");
     	System.loadLibrary("caffe_jni");
     }
  • create CaffeMobile.java

     package com.sh1r0.caffe_android_demo;
    
     public class CaffeMobile {
     	public native void enableLog(boolean enabled);
     	public native int loadModel(String modelPath, String weightsPath);
     	public native int predictImage(String imgPath);
     }
  • call native methods

     CaffeMobile caffeMobile = new CaffeMobile();
     caffeMobile.enableLog(true);  // optional, enable native logging
     caffeMobile.loadModel(modelPath, weightsPath);  // init once
     ...
     caffeMobile.predictImage(imgPath);

Optional

.envrc files are for direnv

direnv is an environment variable manager for your shell. It knows how to hook into bash, zsh and fish shell to load or unload environment variables depending on your current directory. This allows to have project-specific environment variables and not clutter the "~/.profile" file.

Dependency

Credits

About

Porting caffe to android platform

License:Other


Languages

Language:C++ 32.8%Language:Makefile 30.3%Language:C 18.8%Language:Python 16.0%Language:Shell 2.1%