Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solrex/caffe-mobile
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0
Choose a base ref
...
head repository: solrex/caffe-mobile
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 5 commits
  • 8 files changed
  • 2 contributors

Commits on Jan 31, 2018

  1. Update README.

    solrex committed Jan 31, 2018
    Copy the full SHA
    074a241 View commit details
  2. Add thanks to sh1r0.

    solrex committed Jan 31, 2018
    Copy the full SHA
    3506138 View commit details

Commits on Aug 6, 2018

  1. Update README.md.

    solrex authored Aug 6, 2018
    Copy the full SHA
    f07d5fa View commit details

Commits on Aug 7, 2018

  1. Copy the full SHA
    2e04790 View commit details
  2. Update OpenBLAS to 0.3.2.

    solrex committed Aug 7, 2018
    Copy the full SHA
    40cd066 View commit details
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ iPhone5s | Meizu M3 note

> NOTE: Cmake version 3.7.2 builds faster lib than version 3.5.1 (verified on Ubuntu 16.10/Android NDK r14). Don't know why. So please use a newer cmake if you can.
> NOTE: NDK version r16+ is not supported. NDK r16 moves all standalone headers to [unified headers](https://android.googlesource.com/platform/ndk/+/ndk-release-r16/CHANGELOG.md). It causes a lot of cross compile problems which I cannot resolve. See issue [#52](https://github.com/solrex/caffe-mobile/issues/52).
# For iPhone or iPhone Simulator

## Step 1: Build Caffe-Mobile Lib with cmake
@@ -109,6 +111,7 @@ $ make -j 4

- Based on https://github.com/BVLC/caffe
- Inspired by https://github.com/chyh1990/caffe-compact
- Android JNI code based on https://github.com/sh1r0/caffe
- Use https://github.com/Yangqing/ios-cmake
- Use https://github.com/taka-no-me/android-cmake
- Windows build script inspired by https://github.com/luoyetx/mini-caffe/tree/master/android
1 change: 1 addition & 0 deletions examples/android/CaffeSimple/app/build.gradle
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
// Specifid for MNIST grayscale png file reading. You can remove it as you need.
//compile 'ar.com.hjg:pngj:2.0.1'
testCompile 'junit:junit:4.12'
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package com.yangwenbo.caffesimple;

import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.content.ContextCompat;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.Manifest;

import com.yangwenbo.caffemobile.CaffeMobile;

@@ -39,6 +43,28 @@ public int compareTo(Cate other) {
}
}

@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 0: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {

// permission was granted, yay! Do the
// contacts-related task you need to do.

} else {

// permission denied, boo! Disable the
// functionality that depends on this permission.
}
return;
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -48,6 +74,11 @@ protected void onCreate(Bundle savedInstanceState) {
tv.append("Loading caffe model...");
tv.setMovementMethod(new ScrollingMovementMethod());
// Show test image
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},0);
}
final File imageFile = new File(Environment.getExternalStorageDirectory(), "test_image.jpg");
Bitmap bmp = BitmapFactory.decodeFile(imageFile.getPath());
ImageView img = (ImageView) findViewById(R.id.testImage);
Original file line number Diff line number Diff line change
@@ -13,18 +13,17 @@
tools:context="com.yangwenbo.caffesimple.MainActivity">

<Button
android:text="Run Caffe Model"
android:layout_alignParentStart="true"
android:layout_marginStart="100dp"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:textAlignment="center"
android:layout_width="150dp"
android:layout_height="30dp" />
android:layout_height="36dp"
android:layout_marginStart="100dp"
android:layout_alignParentTop="true"
android:text="Run Caffe Model"
android:textAlignment="center" />

<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_width="36dp"
android:layout_height="36dp"
app:srcCompat="@mipmap/ic_launcher"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
6 changes: 6 additions & 0 deletions src/jni/caffe_jni.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Original version of this file is provided in https://github.com/sh1r0/caffe,
* which is part of https://github.com/sh1r0/caffe-android-lib.
* Thanks to github user "sh1r0" for sharing this.
*/

#include <jni.h>

#include "caffe_mobile.hpp"
6 changes: 6 additions & 0 deletions src/jni/caffe_mobile.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Original version of this file is provided in https://github.com/sh1r0/caffe,
* which is part of https://github.com/sh1r0/caffe-android-lib.
* Thanks to github user "sh1r0" for sharing this.
*/

#include "caffe_mobile.hpp"

namespace caffe {
6 changes: 6 additions & 0 deletions src/jni/caffe_mobile.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Original version of this file is provided in https://github.com/sh1r0/caffe,
* which is part of https://github.com/sh1r0/caffe-android-lib.
* Thanks to github user "sh1r0" for sharing this.
*/

#ifndef JNI_CAFFE_MOBILE_HPP_
#define JNI_CAFFE_MOBILE_HPP_

15 changes: 8 additions & 7 deletions third_party/build-openblas.sh
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
PLATFORM=Android

# Options for All
OPENBLAS_VERSION=0.2.19
OPENBLAS_VERSION=0.3.2
MAKE_FLAGS="$MAKE_FLAGS -j 4"
BUILD_DIR=".cbuild"

@@ -127,6 +127,7 @@ function build-Android {
make ${MAKE_FLAGS} \
NOFORTRAN=1 \
NO_NOLAPACKE=1 \
NO_SHARED=1 \
OSNAME=Android \
SMP=1 \
USE_THREAD=1 \
@@ -136,7 +137,7 @@ function build-Android {
HOSTCC=gcc \
TARGET=$TARGET \
ARM_SOFTFP_ABI=$ARM_SOFTFP_ABI \
BINARY=$BINARY
BINARY=$BINARY || exit 1
make \
SMP=1 \
PREFIX="../$PREFIX" \
@@ -147,9 +148,9 @@ function build-Android {
ln -s $PREFIX OpenBLAS
}

if [ "${ANDROID_ABI}" = "armeabi-v7a with NEON" ]; then
fetch-OpenBLAS-softfp
else
fetch-OpenBLAS
fi
#if [ "${ANDROID_ABI}" = "armeabi-v7a with NEON" ]; then
# fetch-OpenBLAS-softfp
#else
fetch-OpenBLAS
#fi
build-$PLATFORM