Skip to content

Commit

Permalink
beta 0.2.0.5
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
liqing committed Jul 25, 2019
1 parent 28245fc commit 7bb0df9
Show file tree
Hide file tree
Showing 93 changed files with 2,334 additions and 560 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ endif()
if(MNN_FORBID_MULTI_THREAD)
add_definitions(-DMNN_FORBIT_MULTI_THREADS)
endif()
if(MNN_USE_INT8_FAST)
add_definitions(-DMNN_USE_INT8_FAST)
endif()

# debug options
option(MNN_DEBUG "Enable MNN DEBUG" OFF)
Expand Down
5 changes: 1 addition & 4 deletions demo/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
</intent-filter>
</activity>
<activity android:name=".ImageActivity"></activity>
<activity android:name=".OpenGLTestActivity"></activity>
<activity android:name=".PortraitActivity"
android:theme="@style/AppTheme.NoActionBar">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class MNNNetInstance {
private static final String TAG = "MNNDemo";

public static MNNNetInstance createFromFile(Context context, String fileName) {
public static MNNNetInstance createFromFile(String fileName) {
long instance = MNNNetNative.nativeCreateNetFromFile(fileName);
if (0 == instance) {
Log.e(TAG, "Create Net Failed from file " + fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,13 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
private static final String TAG = "AiNNDemo";

private static final int MINIMUM_PREVIEW_SIZE = 320;

private static final int PREVIEW_CALLBACK_FREQUENCE = 5;
private Camera mCamera;
private Camera.Parameters mParams;
private Camera.Size mPreviewSize;

private PreviewCallback mPreviewCallback;
private int mOrientationAngle;

private int previewCallbackCount;
private static final int PREVIEW_CALLBACK_FREQUENCE = 5;

public interface PreviewCallback {
void onGetPreviewOptimalSize(int optimalWidth, int optimalHeight);

void onPreviewFrame(byte[] data, int imageWidth, int imageHeight, int angle);
}

public void setPreviewCallback(CameraView.PreviewCallback previewCallback) {
mPreviewCallback = previewCallback;
}

public CameraView(Context context) {
this(context, null);
Expand All @@ -52,6 +39,10 @@ public CameraView(Context context, AttributeSet attrs) {
holder.addCallback(this);
}

public void setPreviewCallback(CameraView.PreviewCallback previewCallback) {
mPreviewCallback = previewCallback;
}

private void openCamera(SurfaceHolder holder) {
// release Camera, if not release camera before call camera, it will be locked
releaseCamera();
Expand Down Expand Up @@ -103,7 +94,6 @@ private synchronized void releaseCamera() {
}
}


@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
Log.i("AiNNDemo", "surfaceCreated");
Expand All @@ -121,7 +111,6 @@ public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
Log.i("AiNNDemo", "surfaceDestroyed");
}


public void setCameraDisplayOrientation(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
Expand Down Expand Up @@ -180,7 +169,6 @@ public void onPreviewFrame(byte[] bytes, Camera camera) {
mPreviewCallback.onPreviewFrame(bytes, mPreviewSize.width, mPreviewSize.height, mOrientationAngle);
}


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


public interface PreviewCallback {
void onGetPreviewOptimalSize(int optimalWidth, int optimalHeight);

void onPreviewFrame(byte[] data, int imageWidth, int imageHeight, int angle);
}

// Compares two size based on their areas.
static class CompareSizesByArea implements Comparator<Camera.Size> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void prepareMobileNet() {
}

// create net instance
mNetInstance = MNNNetInstance.createFromFile(ImageActivity.this, modelPath);
mNetInstance = MNNNetInstance.createFromFile(modelPath);

// create session with config
MNNNetInstance.Config config = new MNNNetInstance.Config();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.taobao.android.mnndemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.taobao.android.opengl.CameraRenderer;

public class OpenGLTestActivity extends AppCompatActivity {

private TextView mTextView;
private CameraRenderer mRenderer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );
setContentView(R.layout.opengl_test);

mTextView = (TextView) findViewById(R.id.cost_time_text);
mRenderer = (CameraRenderer)findViewById(R.id.renderer_view);
mRenderer.setContext(this);
mRenderer.setTextView(mTextView);

}

@Override
protected void onResume() {
super.onResume();
mRenderer.onResume();
}

@Override
protected void onPause() {
mRenderer.onPause();
super.onPause();
}

@Override
protected void onDestroy() {
super.onDestroy();
mRenderer.onDestroy();
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class PortraitActivity extends AppCompatActivity {

Paint keyPaint = new Paint();

private void prepareModels() {
public void prepareModels() {

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

}

private void prepareNet() {
public void prepareNet() {
if (mNetInstance != null) {
mNetInstance.release();
}

String modelPath = mMobileModelPath;

// create net instance
mNetInstance = MNNNetInstance.createFromFile(PortraitActivity.this, modelPath);
mNetInstance = MNNNetInstance.createFromFile(modelPath);

// create session
mConfig = new MNNNetInstance.Config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void prepareNet() {
}

// create net instance
mNetInstance = MNNNetInstance.createFromFile(VideoActivity.this, modelPath);
mNetInstance = MNNNetInstance.createFromFile(modelPath);

// mConfig.saveTensors;
mSession = mNetInstance.createSession(mConfig);
Expand Down Expand Up @@ -466,6 +466,9 @@ else if (mModelSpinner.getId() == adapterView.getId()) {
} else if (i == 2) {
Intent intent = new Intent(VideoActivity.this, PortraitActivity.class);
startActivity(intent);
} else if (i == 3) {
Intent intent = new Intent(VideoActivity.this, OpenGLTestActivity.class);
startActivity(intent);
}
}

Expand Down
Loading

0 comments on commit 7bb0df9

Please sign in to comment.