Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Application gets stuck #59

Open
AugustinasMK opened this issue Aug 7, 2018 · 0 comments
Open

Application gets stuck #59

AugustinasMK opened this issue Aug 7, 2018 · 0 comments

Comments

@AugustinasMK
Copy link

Application gets stuck while we are Instantiating predictor!

Tools

I use:
Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-29-generic
android-ndk-r13b

Code

#define alog(...) __android_log_print(ANDROID_LOG_ERROR, "F8DEMO", __VA_ARGS__);
void loadToNetDef(AAssetManager* mgr, caffe2::NetDef* net, const char *filename) {
    AAsset* asset = AAssetManager_open(mgr, filename, AASSET_MODE_BUFFER);
    assert(asset != nullptr);
    const void *data = AAsset_getBuffer(asset);
    assert(data != nullptr);
    off_t len = AAsset_getLength(asset);
    assert(len != 0);
    if (!net->ParseFromArray(data, len)) {
        alog("Couldn't parse net from data.\n");
    }
    AAsset_close(asset);
}
void Java_initCaffe2(JNIEnv* env, jobject /* this */, jobject assetManager){
    AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
    alog("Attempting to load protobuf netdefs...");
    loadToNetDef(mgr, &_initNet,   "init_net.pb");
    loadToNetDef(mgr, &_predictNet,"predict_net.pb");
    alog("done.");
    alog("Instantiating predictor...");
    _predictor = new caffe2::Predictor(_initNet, _predictNet);
    alog("done.")
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant