GithubHelp home page GithubHelp logo

Comments (4)

carlosporta avatar carlosporta commented on May 26, 2024

I added to caffe_jni.cpp the following lines:
JNIEXPORT jfloatArray JNICALL
Java_com_sh1r0_caffe_1android_1lib_CaffeMobile_getConfidence(JNIEnv *env,
jobject thiz,
jstring imgPath) {
CaffeMobile *caffe_mobile = CaffeMobile::Get();
vector confidence = caffe_mobile->GetConfidence(jstring2string(env, imgPath));

jfloatArray result;
result = env->NewFloatArray(4);
if (result == NULL) {
return NULL; /* out of memory error thrown */
}
// move from the temp structure to the java structure
env->SetFloatArrayRegion(result, 0, 4, &confidence[0]);
return result;
}

Then added to caffe_mobile.cpp

vector CaffeMobile::GetConfidence(const string &img_path) {
const vector probs = Forward(img_path);
return probs;
}

And created a native method on android. But it returns the following code ( I have 4 classes):
label 0 = 0.0
label 1 = 1.0
label 2 = 0.0
label 3 = 0.0

Another prediction:
label 0 = 0.0
label 0 = 0.0
label 0 = 0.0
label 0 = 1.0

So, it gives not gives to me the confidence that I want. Am I doing something wrong? Or is not possible?

from caffe-android-lib.

g1910 avatar g1910 commented on May 26, 2024

Hi,
We are trying to build an app which requires to classify objects based on whether the confidence value is higher than a threshold. This work of yours looks really promising and we would like to go forward with using it. Problem is that we really need the individual confidence values. Please see if this functionality can be added asap.

Else, it seems that only the .so is accessible in the recent commits and not the .cpp code which we can ourselves modify. See if you can re-add in the upcoming commits.

from caffe-android-lib.

sh1r0 avatar sh1r0 commented on May 26, 2024

I have updated the dev branch with GetConfidenceScore function in caffe_mobile module. The source files are right here.
Please have a try and kindly let me know if there is any problem. Thanks.

from caffe-android-lib.

g1910 avatar g1910 commented on May 26, 2024

I can see the changes in the .cpp files. But, how to get them reflected in the java class?

Please update the caffe-android-demo project with these changes. Also, please add some documentation on how to get the functionality from .cpp to .java.

from caffe-android-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.