Skip to content

Commit 7bb0df9

Browse files
author
liqing
committed
beta 0.2.0.5
- CPU - add support for DepthToSpace & SpaceToDepth ops - OpenGL - add Android demo - add half / float runtime option - add support for ROIPooling, Squeeze - fix bugs in conv im2col - OpenCL - fix Concat, Eltwise, Reshape bugs - Tools - add KL threshold method in quantization tool - support optimization for graph with multiple rnn
1 parent 28245fc commit 7bb0df9

File tree

93 files changed

+2334
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2334
-560
lines changed

CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ endif()
3939
if(MNN_FORBID_MULTI_THREAD)
4040
add_definitions(-DMNN_FORBIT_MULTI_THREADS)
4141
endif()
42-
if(MNN_USE_INT8_FAST)
43-
add_definitions(-DMNN_USE_INT8_FAST)
44-
endif()
4542

4643
# debug options
4744
option(MNN_DEBUG "Enable MNN DEBUG" OFF)

demo/android/app/src/main/AndroidManifest.xml

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@
2929
</intent-filter>
3030
</activity>
3131
<activity android:name=".ImageActivity"></activity>
32+
<activity android:name=".OpenGLTestActivity"></activity>
3233
<activity android:name=".PortraitActivity"
3334
android:theme="@style/AppTheme.NoActionBar">
34-
<!--<intent-filter>-->
35-
<!--<action android:name="android.intent.action.MAIN" />-->
36-
<!--<category android:name="android.intent.category.LAUNCHER" />-->
37-
<!--</intent-filter>-->
3835
</activity>
3936
</application>
4037

demo/android/app/src/main/java/com/taobao/android/mnn/MNNNetInstance.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class MNNNetInstance {
77
private static final String TAG = "MNNDemo";
88

9-
public static MNNNetInstance createFromFile(Context context, String fileName) {
9+
public static MNNNetInstance createFromFile(String fileName) {
1010
long instance = MNNNetNative.nativeCreateNetFromFile(fileName);
1111
if (0 == instance) {
1212
Log.e(TAG, "Create Net Failed from file " + fileName);

demo/android/app/src/main/java/com/taobao/android/mnndemo/CameraView.java

+12-17
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,13 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
2020
private static final String TAG = "AiNNDemo";
2121

2222
private static final int MINIMUM_PREVIEW_SIZE = 320;
23-
23+
private static final int PREVIEW_CALLBACK_FREQUENCE = 5;
2424
private Camera mCamera;
2525
private Camera.Parameters mParams;
2626
private Camera.Size mPreviewSize;
27-
2827
private PreviewCallback mPreviewCallback;
2928
private int mOrientationAngle;
30-
3129
private int previewCallbackCount;
32-
private static final int PREVIEW_CALLBACK_FREQUENCE = 5;
33-
34-
public interface PreviewCallback {
35-
void onGetPreviewOptimalSize(int optimalWidth, int optimalHeight);
36-
37-
void onPreviewFrame(byte[] data, int imageWidth, int imageHeight, int angle);
38-
}
39-
40-
public void setPreviewCallback(CameraView.PreviewCallback previewCallback) {
41-
mPreviewCallback = previewCallback;
42-
}
4330

4431
public CameraView(Context context) {
4532
this(context, null);
@@ -52,6 +39,10 @@ public CameraView(Context context, AttributeSet attrs) {
5239
holder.addCallback(this);
5340
}
5441

42+
public void setPreviewCallback(CameraView.PreviewCallback previewCallback) {
43+
mPreviewCallback = previewCallback;
44+
}
45+
5546
private void openCamera(SurfaceHolder holder) {
5647
// release Camera, if not release camera before call camera, it will be locked
5748
releaseCamera();
@@ -103,7 +94,6 @@ private synchronized void releaseCamera() {
10394
}
10495
}
10596

106-
10797
@Override
10898
public void surfaceCreated(SurfaceHolder surfaceHolder) {
10999
Log.i("AiNNDemo", "surfaceCreated");
@@ -121,7 +111,6 @@ public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
121111
Log.i("AiNNDemo", "surfaceDestroyed");
122112
}
123113

124-
125114
public void setCameraDisplayOrientation(Activity activity,
126115
int cameraId, android.hardware.Camera camera) {
127116
android.hardware.Camera.CameraInfo info =
@@ -180,7 +169,6 @@ public void onPreviewFrame(byte[] bytes, Camera camera) {
180169
mPreviewCallback.onPreviewFrame(bytes, mPreviewSize.width, mPreviewSize.height, mOrientationAngle);
181170
}
182171

183-
184172
/**
185173
* Given choices supported by a camera, chooses the smallest one whose
186174
* width and height are at least as large as the minimum of both, or an exact match if possible.
@@ -216,6 +204,13 @@ private Camera.Size getPropPreviewSize(List<Camera.Size> choices, int minWidth,
216204
}
217205
}
218206

207+
208+
public interface PreviewCallback {
209+
void onGetPreviewOptimalSize(int optimalWidth, int optimalHeight);
210+
211+
void onPreviewFrame(byte[] data, int imageWidth, int imageHeight, int angle);
212+
}
213+
219214
// Compares two size based on their areas.
220215
static class CompareSizesByArea implements Comparator<Camera.Size> {
221216
@Override

demo/android/app/src/main/java/com/taobao/android/mnndemo/ImageActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void prepareMobileNet() {
189189
}
190190

191191
// create net instance
192-
mNetInstance = MNNNetInstance.createFromFile(ImageActivity.this, modelPath);
192+
mNetInstance = MNNNetInstance.createFromFile(modelPath);
193193

194194
// create session with config
195195
MNNNetInstance.Config config = new MNNNetInstance.Config();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.taobao.android.mnndemo;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.view.View;
6+
import android.view.Window;
7+
import android.view.WindowManager;
8+
import android.widget.TextView;
9+
10+
import com.taobao.android.opengl.CameraRenderer;
11+
12+
public class OpenGLTestActivity extends AppCompatActivity {
13+
14+
private TextView mTextView;
15+
private CameraRenderer mRenderer;
16+
17+
@Override
18+
protected void onCreate(Bundle savedInstanceState) {
19+
super.onCreate(savedInstanceState);
20+
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
21+
22+
View decorView = getWindow().getDecorView();
23+
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
24+
decorView.setSystemUiVisibility(uiOptions);
25+
26+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
27+
setContentView(R.layout.opengl_test);
28+
29+
mTextView = (TextView) findViewById(R.id.cost_time_text);
30+
mRenderer = (CameraRenderer)findViewById(R.id.renderer_view);
31+
mRenderer.setContext(this);
32+
mRenderer.setTextView(mTextView);
33+
34+
}
35+
36+
@Override
37+
protected void onResume() {
38+
super.onResume();
39+
mRenderer.onResume();
40+
}
41+
42+
@Override
43+
protected void onPause() {
44+
mRenderer.onPause();
45+
super.onPause();
46+
}
47+
48+
@Override
49+
protected void onDestroy() {
50+
super.onDestroy();
51+
mRenderer.onDestroy();
52+
}
53+
}
54+
55+

demo/android/app/src/main/java/com/taobao/android/mnndemo/PortraitActivity.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class PortraitActivity extends AppCompatActivity {
5757

5858
Paint keyPaint = new Paint();
5959

60-
private void prepareModels() {
60+
public void prepareModels() {
6161

6262
mMobileModelFileName = "Portrait/Portrait.tflite.mnn";
6363
mMobileModelPath = getCacheDir() + "/Portrait.tflite.mnn";
@@ -70,15 +70,15 @@ private void prepareModels() {
7070

7171
}
7272

73-
private void prepareNet() {
73+
public void prepareNet() {
7474
if (mNetInstance != null) {
7575
mNetInstance.release();
7676
}
7777

7878
String modelPath = mMobileModelPath;
7979

8080
// create net instance
81-
mNetInstance = MNNNetInstance.createFromFile(PortraitActivity.this, modelPath);
81+
mNetInstance = MNNNetInstance.createFromFile(modelPath);
8282

8383
// create session
8484
mConfig = new MNNNetInstance.Config();

demo/android/app/src/main/java/com/taobao/android/mnndemo/VideoActivity.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private void prepareNet() {
152152
}
153153

154154
// create net instance
155-
mNetInstance = MNNNetInstance.createFromFile(VideoActivity.this, modelPath);
155+
mNetInstance = MNNNetInstance.createFromFile(modelPath);
156156

157157
// mConfig.saveTensors;
158158
mSession = mNetInstance.createSession(mConfig);
@@ -466,6 +466,9 @@ else if (mModelSpinner.getId() == adapterView.getId()) {
466466
} else if (i == 2) {
467467
Intent intent = new Intent(VideoActivity.this, PortraitActivity.class);
468468
startActivity(intent);
469+
} else if (i == 3) {
470+
Intent intent = new Intent(VideoActivity.this, OpenGLTestActivity.class);
471+
startActivity(intent);
469472
}
470473
}
471474

0 commit comments

Comments
 (0)