Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find path of model.tflite on Android. #582

Closed
sne21star opened this issue Apr 5, 2020 · 9 comments
Closed

Find path of model.tflite on Android. #582

sne21star opened this issue Apr 5, 2020 · 9 comments
Assignees
Labels
platform:android Issues with Android as Platform

Comments

@sne21star
Copy link

I have added my model.tflite in this folder https://github.com/sne21star/mediapipe/tree/master/hand-gesture-recognition.

And I need to to get the path of the model not from my directory because when I downloaded the app to my android the model is not in that exact directory. How do i get the path to model.tflite so that it can open it on an android?

@fenollp
Copy link

fenollp commented Apr 5, 2020

Use this function: https://github.com/google/mediapipe/blob/1722d4b8a25ad7c919576f9b1bab4ffa7a9299bc/mediapipe/calculators/tflite/tflite_inference_calculator.cc#L594
It has platform-specific strategies ;)

@eknight7
Copy link

eknight7 commented Apr 6, 2020

You can use that function inside the calculator or you could try to get the path in Java. Where are you trying to get the path from?

@eknight7 eknight7 self-assigned this Apr 6, 2020
@eknight7 eknight7 added the platform:android Issues with Android as Platform label Apr 6, 2020
@sne21star
Copy link
Author

I haven't pushed the changes yet, but I used the function and was able to get the path to the model. I also added it to the BUILD file in android/src/.../hand-gesture-recongition , handtrackinggpu, and hand detectiongpu under the android library shown below

android_library(
name = "mediapipe_lib",
srcs = glob(["*.java"]),
assets = [
":binary_graph",
":model",
"//mediapipe/models:model.tflite",
"//mediapipe/models:palm_detection.tflite",
"//mediapipe/models:palm_detection_labelmap.txt",
],

However, my app now works for around 10 seconds or 20 seconds and then crashes. Is there any reason why?

@eknight7
Copy link

eknight7 commented Apr 7, 2020

Can you share an adb logcat* of the app?

@sne21star
Copy link
Author

sne21star commented Apr 7, 2020

It says something about Fatal signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x7591237060 in tid 5944 (Thread-5), pid 5867 (handtrackinggpu)
down below and then it stops working I believe.

04-07 18:19:26.378 5867 5946 I native : I0407 18:19:26.378847 5946 resource_util_android.cc:53] Successfully loaded: model.tflite
04-07 18:19:26.378 5867 5946 I native : I0407 18:19:26.378980 5946 hand-gesture-recognition-calculator.cc:145] /data/user/0/com.google.mediapipe.apps.handtrackinggpu/cache/mediapipe_asset_cache/model.tflite
04-07 18:19:26.384 5867 5944 F libc : Fatal signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x7591237060 in tid 5944 (Thread-5), pid 5867 (handtrackinggpu)
04-07 18:19:26.403 5867 5945 D MainActivity: [TS:281385142869] #Landmarks for hand: 21
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[0]: (0.6504172, 0.76408595, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[1]: (0.55356693, 0.7599318, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[2]: (0.4475779, 0.70123446, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[3]: (0.3809772, 0.6261006, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[4]: (0.37896553, 0.5697964, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[5]: (0.46049115, 0.57573175, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[6]: (0.41735023, 0.50479954, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[7]: (0.40789753, 0.516513, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[8]: (0.41590476, 0.5413642, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[9]: (0.5134073, 0.5503946, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[10]: (0.4735183, 0.46109703, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[11]: (0.4457557, 0.4006798, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[12]: (0.42456353, 0.35171252, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[13]: (0.5733366, 0.54409504, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[14]: (0.53478664, 0.45468622, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[15]: (0.51490235, 0.4086092, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[16]: (0.5018861, 0.37370327, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[17]: (0.6456976, 0.55038506, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[18]: (0.6184143, 0.48311687, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[19]: (0.60361415, 0.44530934, 0.0)
04-07 18:19:26.404 5867 5945 D MainActivity: Landmark[20]: (0.5897361, 0.40823853, 0.0)
04-07 18:19:26.411 5867 5941 I native : I0407 18:19:26.411564 5941 resource_util_android.cc:53] Successfully loaded: model.tflite
04-07 18:19:26.411 5867 5941 I native : I0407 18:19:26.411682 5941 hand-gesture-recognition-calculator.cc:145] /data/user/0/com.google.mediapipe.apps.handtrackinggpu/cache/mediapipe_asset_cache/model.tflite
04-07 18:19:26.455 6581 6581 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
04-07 18:19:26.459 931 931 I /system/bin/tombstoned: received crash request for pid 5944
04-07 18:19:26.460 6581 6581 I crash_dump64: performing dump of process 5867 (target tid = 5944)
04-07 18:19:26.468 6581 6581 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-07 18:19:26.468 6581 6581 F DEBUG : Build fingerprint: 'google/walleye/walleye:9/PQ3A.190801.002/5670241:user/release-keys'
04-07 18:19:26.468 6581 6581 F DEBUG : Revision: 'MP1'
04-07 18:19:26.468 6581 6581 F DEBUG : ABI: 'arm64'
04-07 18:19:26.468 6581 6581 F DEBUG : pid: 5867, tid: 5944, name: Thread-5 >>> com.google.mediapipe.apps.handtrackinggpu <<<
04-07 18:19:26.468 6581 6581 F DEBUG : signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x7591237060

04-07 18:19:26.468 6581 6581 F DEBUG : x0 0000007591237060 x1 00000075912263f8 x2 000000759620aac0 x3 0000007592bcc000
04-07 18:19:26.468 6581 6581 F DEBUG : x4 000000759620aaa0 x5 0000007592bcc0c0 x6 000000759620aa78 x7 00000075949d7ee0
04-07 18:19:26.468 6581 6581 F DEBUG : x8 0000000000000384 x9 0000000000000380 x10 0000007592bcbff0 x11 0000000000000198
04-07 18:19:26.468 6581 6581 F DEBUG : x12 000000000000002a x13 0000007591236fc8 x14 0000000000000000 x15 0000000000000026
04-07 18:19:26.468 6581 6581 F DEBUG : x16 00000000000000a8 x17 0000007592bcc010 x18 000000759620a2ca x19 000000759620aa78
04-07 18:19:26.468 6581 6581 F DEBUG : x20 000000759620aab0 x21 000000759620aac0 x22 00000075949d7ee0 x23 000000759620b588
04-07 18:19:26.468 6581 6581 F DEBUG : x24 000000759620b588 x25 0000000000000008 x26 000000759620b588 x27 0000007592c3d000
04-07 18:19:26.468 6581 6581 F DEBUG : x28 0000000000000000 x29 000000759620aa60
04-07 18:19:26.468 6581 6581 F DEBUG : sp 000000759620a9c0 lr 0000007597fe2e88 pc 0000007597f9eacc
04-07 18:19:26.478 6581 6581 F DEBUG :
04-07 18:19:26.478 6581 6581 F DEBUG : backtrace:
04-07 18:19:26.478 6581 6581 F DEBUG : #00 pc 00000000004ddacc /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (_ZN6tflite16cpu_backend_gemm6detail10CustomGemvIffffLNS0_18QuantizationFlavorE0EEEbRKNS0_12MatrixParamsIT_EEPKS5_RKNS4_IT0_EEPKSB_RKNS4_IT2_EEPSH_RKNS0_10GemmParamsIT1_SH_XT3_EEEPNS_17CpuBackendContextE+684)
04-07 18:19:26.478 6581 6581 F DEBUG : #1 pc 0000000000521e84 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (tflite::optimized_ops::FullyConnected(tflite::FullyConnectedParams const&, tflite::RuntimeShape const&, float const*, tflite::RuntimeShape const&, float const*, tflite::RuntimeShape const&, float const*, tflite::RuntimeShape const&, float*, tflite::CpuBackendContext*)+848)
04-07 18:19:26.478 6581 6581 F DEBUG : #2 pc 0000000000520f50 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (ZN6tflite3ops7builtin15fully_connected9EvalFloatILNS2_10KernelTypeE1EEE12TfLiteStatusP13TfLiteContextP10TfLiteNodeP26TfLiteFullyConnectedParamsPNS2_6OpDataEPK12TfLiteTensorSG_SG_PSE+476)
04-07 18:19:26.478 6581 6581 F DEBUG : #3 pc 000000000060537c /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (tflite::Subgraph::Invoke()+668)
04-07 18:19:26.478 6581 6581 F DEBUG : #4 pc 0000000000608fdc /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (tflite::Interpreter::Invoke()+32)
04-07 18:19:26.478 6581 6581 F DEBUG : #5 pc 0000000000482fd0 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::HandGestureRecognitionCalculator::Process(mediapipe::CalculatorContext*)+1732)
04-07 18:19:26.478 6581 6581 F DEBUG : #6 pc 00000000006af3b0 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::CalculatorNode::ProcessNode(mediapipe::CalculatorContext*)+812)
04-07 18:19:26.478 6581 6581 F DEBUG : #7 pc 0000000000692370 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::internal::SchedulerQueue::RunCalculatorNode(mediapipe::CalculatorNode*, mediapipe::CalculatorContext*)+316)
04-07 18:19:26.478 6581 6581 F DEBUG : #8 pc 0000000000691dc8 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::internal::SchedulerQueue::RunNextTask()+232)
04-07 18:19:26.478 6581 6581 F DEBUG : #9 pc 00000000006cbadc /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::ThreadPool::RunWorker()+380)
04-07 18:19:26.478 6581 6581 F DEBUG : #10 pc 00000000006cb728 /data/app/com.google.mediapipe.apps.handtrackinggpu-AxrKpfYISBxibmWOksFmvQ==/lib/arm64/libmediapipe_jni.so (mediapipe::ThreadPool::WorkerThread::ThreadBody(void*)+1380)
04-07 18:19:26.478 6581 6581 F DEBUG : #11 pc 0000000000083114 /system/lib64/libc.so (__pthread_start(void*)+36)
04-07 18:19:26.478 6581 6581 F DEBUG : #12 pc 00000000000233bc /system/lib64/libc.so (__start_thread+68)
04-07 18:19:26.896 748 5949 D EaselControlClient: Received command 5
04-07 18:19:26.896 748 5949 D EaselControlClient: msgHandlerCallback: server heartbeat 22
04-07 18:19:26.897 748 5949 V EaselTimer: restart
04-07 18:19:26.916 1192 6597 W ActivityManager: Force finishing activity com.google.mediapipe.apps.handtrackinggpu/.MainActivity
04-07 18:19:26.917 931 931 E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_05
04-07 18:19:26.923 1192 1229 I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
04-07 18:19:26.928 1192 1212 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
04-07 18:19:26.928 1192 1212 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-07 18:19:26.928 851 851 E lowmemorykiller: Error writing /proc/5867/oom_score_adj; errno=22

@sne21star
Copy link
Author

Also, I narrowed down my problem to tflite interpreter --> Invoke()
if(interpreter->Invoke() == kTfLiteOk)
{....}

Somehow it is crashing when it reaches this statement. I'm not exactly sure how to fix it as I thought the statement should take care of it. (It is crashing before reaching any of the statement inside the if statement so it must be interpreter -> Invoke() that is causing the error)

@eknight7
Copy link

Can you confirm if the model runs at least once?

@sne21star
Copy link
Author

sne21star commented Apr 10, 2020

Can you confirm if the model runs at least once?

Yup! It is able to run for abut 30 seconds. But somehow it still segfaults after that much time.

I have also pushed everything to my github and you can now see the changes I made. The model.tflite is called here:

https://github.com/sne21star/mediapipe/blob/master/hand-gesture-recognition/hand-gesture-recognition-calculator.cc

@eknight7
Copy link

eknight7 commented Jan 8, 2021

Hi, apologies for the delayed response. Are you still running into this issue?
Please feel free to re-open if the question is still relevant. Thank you.

@eknight7 eknight7 closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:android Issues with Android as Platform
Projects
None yet
Development

No branches or pull requests

3 participants