Giter Site home page Giter Site logo

Feature extraction about caffe-android-lib HOT 8 CLOSED

sh1r0 avatar sh1r0 commented on August 17, 2024
Feature extraction

from caffe-android-lib.

Comments (8)

mtngld avatar mtngld commented on August 17, 2024

Hi,

Try something like that:

  //Feature extraction
    const shared_ptr<Blob<float> >& features = caffe_net->blob_by_name("fc7");
    LOG(INFO) << "Features size " << features->count();
    vector myfeatures  = vector<float>(features->cpu_data(),features->cpu_data()+features->count());

Change "fc7" to whatever layer you want

from caffe-android-lib.

isikdogan avatar isikdogan commented on August 17, 2024

I'm also trying to extract features. I need the features before they are passed through the softmax layer, just like in the code snippet above. Where should I add this code? Is it caffe_mobile.cpp?
Thanks

from caffe-android-lib.

mtngld avatar mtngld commented on August 17, 2024

Yes, you can simply add it to predict_top_k function or create a dedicated feature extraction function

from caffe-android-lib.

vimalthilak avatar vimalthilak commented on August 17, 2024

You can always modify the prototxt to extract features that are of interest to you. I have been able to extract features from the output of average pooling layer of a GoogLeNet model by simply removing the last three layers from the deploy prototxt file of the same model. You just re-run Forward() as before.

from caffe-android-lib.

isikdogan avatar isikdogan commented on August 17, 2024

Thanks for your responses. I wasn't familiar with the Java Native Interface. I was able to run it by modifying caffe_jni.cpp and caffe_mobile.cpp files.

from caffe-android-lib.

Keyurpatel93 avatar Keyurpatel93 commented on August 17, 2024

isikdogan, can you please share how you modified the caffe_jni.cpp and caffe_mobile.cpp files to be able to extract features from a layer in the network?

from caffe-android-lib.

isikdogan avatar isikdogan commented on August 17, 2024

Keyurpatel93, I just noticed your message. I no longer work on that project. The development version of OpenCV seems to have caffe-compatible functions. I don't know if those functions are available in the Android version yet, but if so then it could be more convenient to use them:
http://docs.opencv.org/master/d6/d0f/group__dnn.html

from caffe-android-lib.

sh1r0 avatar sh1r0 commented on August 17, 2024

Thanks to the discussions above. Feature extraction is integrated in the latest master branch, so I'm gonna close this issue.

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.