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

File not found #41

Closed
billygl opened this issue Nov 7, 2016 · 8 comments
Closed

File not found #41

billygl opened this issue Nov 7, 2016 · 8 comments
Labels

Comments

@billygl
Copy link

billygl commented Nov 7, 2016

I used

        File file = new File(modelProto);
        if(file.exists())Log.e("DEVX", "ok.");
        else Log.e("DEVX", "NOT");

And I watched ok in Android Log Monitor. It means Android can find the file. It exists.
But I got

F1107 18:01:28.624402 16834 io.cpp:36] Check failed: fd != -1 (-1 vs. -1) File not found: /storage/emulated/0/Download/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt

when the execution arrived to
caffeMobile.loadModel(modelProto, modelBinary);

It means that Android find the file but io.cpp can't find the file.

I doubled checked the path and I added
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
And I updated the code using the external storage SD card

pull /storage/278E-8716/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt

but I can't solve this issue.

I have

android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sh1r0.caffe_android_demo"
minSdkVersion 15
targetSdkVersion 23
versionName "1.0"
}

And I don't know what is the problem.
Please, help

@sh1r0
Copy link
Owner

sh1r0 commented Nov 8, 2016

@billygl
First, /storage/emulated/0/Download/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt does not match /storage/278E-8716/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt. And AFAIW, /emulated/0 is usually the primary external storage rather than the secondary one (i.e., external sd card) [1]. Please check the absolute path of your files.

[1] http://stackoverflow.com/a/29404440

@billygl
Copy link
Author

billygl commented Nov 8, 2016

Yes, I checked both locations. For that reason,

  1. First, I tried with one path
    It didn't work so
  2. I tried the other path. I thought it was caused by permissions.

Sorry for the confusion. I updated the post

@sh1r0
Copy link
Owner

sh1r0 commented Nov 10, 2016

@billygl Is your phone on android 6 (marshmallow)?

@billygl
Copy link
Author

billygl commented Nov 16, 2016

Yes Android 6.0.1. Galaxy S7 Edge.

@Uchanka
Copy link

Uchanka commented Nov 17, 2016

Maybe you should try and modify its Java source code?
The file paths are designated in its source code, both .prototxt and weight file. Push these files to somewhere you have access to.
Try enabling developer mode if you have to.
Also be advised be careful with that S7
May cause massive explosion

@billygl
Copy link
Author

billygl commented Nov 23, 2016

Yes. I pushed these files to 2 locations and I changed the source code for theses locations in different tests but I highlight that

    File file = new File(modelProto);
    if(file.exists())Log.e("test", "ok.");

It works, but
caffeMobile.loadModel(modelProto, modelBinary);
doesn't work

@sh1r0 sh1r0 added the bug label Dec 3, 2016
@sh1r0
Copy link
Owner

sh1r0 commented Dec 3, 2016

@billygl I found the problem, it's about runtime permission control introduced in android 6. Here's the workaround: manually grant the app with storage permission.
screenshot_1480756864

@billygl
Copy link
Author

billygl commented Dec 5, 2016

Excellent!
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants