Open fangmingbnu opened 6 years ago
I think my problem is in load model:
when I load my model in the native-lib.cpp:
line54: _predictor = new caffe2::Predictor(_initNet, _predictNet); line55: alog("done.").
The problem located in line 54. So there has "done" print out.
@fangmingbnu Have you solved it? I have the same problem when I changed the models.
@fangmingbnu @doudasek Did you manage to solve this problem?
I am experiencing similar error. In my case, I am using PyTorch 1.0 preview and Caffe2 implementation of ONNX which is now part of PyTorch repo.
My system environment:
If I run with the two pb files, squeeze_init_net.pb
and squeeze_predict_net.pb
orignated from the AICamera project assets directory, the Android app runs fine.
If I replaced the two pb files with the one generated from my own code, the Android app crashed immediately when I try to run it with the error pointing to the same line in the native-lib.cpp
that you highlighted.
Please take a look at my code for that part in this Jupyter notebook. It handles exporting the model to run on mobile devices.
Thank you.
@fangmingbnu @cedrickchee @doudasek Have you solved it? I met same problem when I changed squeezed model to my own model.
@StephenLee2016 No. I took another approach. No troublesome ONNX, no learning Caffe2. Just PyTorch and libTorch.
I load the PyTorch model in C++. High level steps:
@cedrickchee Thanks for your solution! I meet the same problem, and I want to know how to build libTorch for Android? Can you give some tips? Thanks very much!
@StephenLee2016 No. I took another approach. No troublesome ONNX, no learning Caffe2. Just PyTorch and libTorch.
I load the PyTorch model in C++. High level steps:
- Convert PyTorch model to Torch Script via tracing using the hybrid front-end
- Serialize my traced script module to a file (with this step, we have now left the Python land and ready to cross over to the C++ land)
- Load my script module in C++ by using the PyTorch C++ front-end (aka. libTorch)
- Compile using CMake
- Execute the script module
- Compile and get libTorch working on Android (arm/arm64 processor, x86 arch, etc.)
- Package everything in Android Studio and deploy the APK to mobile devices.
Thanks for your advice. I have solved this problem, but there are 3d conv in my model, and now nnpack does not seem to support this operator. So the performance of the my model on android is very poor.
I transfer a model from pytorch to caffe2. But when I load this model, the android report some error listed below.
03/15 21:46:48: Launching app $ adb push /Users/mingfang/Desktop/android/AICamera/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/facebook.f8demo $ adb shell pm install -t -r "/data/local/tmp/facebook.f8demo" pkg: /data/local/tmp/facebook.f8demo Success
$ adb shell am start -n "facebook.f8demo/facebook.f8demo.ClassifyCamera" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 28623 on device mi_3c-af58956 Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/System.out: ming I/art: Starting a blocking GC Explicit I/art: Explicit concurrent mark sweep GC freed 38759(1863KB) AllocSpace objects, 1(20KB) LOS objects, 56% free, 12MB/28MB, paused 232us total 35.909ms V/StudioProfiler: Acquiring Application for Events W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable E/F8DEMO: Attempting to load protobuf netdefs... W/System: ClassLoader referenced unknown path: /system/app/MiuiContentCatcher/lib/arm D/AccessibilityManager: current package=facebook.f8demo, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false I/System.out: ming1 I/System.out: ming1 I/System.out: ming D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true I/Adreno-EGL:: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013_msm8974_refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013__release_AU (I48a9d37399)
OpenGL ES Shader Compiler Version: E031.29.00.00
Build Date: 11/17/16 Thu
Local Branch:
Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.BF.1.1.3_RB1.06.00.01.181.013
Local Patches: NONE
Reconstruct Branch: NOTHING
I/OpenGLRenderer: Initialized EGL, version 1.4
I/CameraManagerGlobal: Connecting to camera service
I/CameraManager: Using legacy camera HAL.
I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
I/RequestThread-0: Configure outputs: 2 surfaces configured.
D/Camera: app passed NULL surface
E/F8DEMO: done.
E/F8DEMO: Instantiating predictor...
I/CameraDeviceState: Legacy camera service transitioning to state IDLE
I/RequestQueue: Repeating capture request set.
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
W/LegacyRequestMapper: Only received metering rectangles with weight 0.
W/LegacyRequestMapper: Only received metering rectangles with weight 0.
I/CameraDeviceState: Legacy camera service transitioning to state CAPTURING
E/F8DEMO: done.
I/System.out: ming
A/libc: /Users/mingfang/Desktop/android/AICamera/app/src/main/cpp/native-lib.cpp:75: jstring Java_facebook_f8demo_ClassifyCamera_classificationFromCaffe2(JNIEnv *, jobject, jint, jint, jbyteArray, jbyteArray, jbyteArray, jint, jint, jboolean): assertion "Y_len <= MAX_DATA_SIZE" failed
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 28660 (Camera backgrou)
Application terminated.
can someone help me check this? Thank you!