Comments (8)
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.
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.
Yes, you can simply add it to predict_top_k function or create a dedicated feature extraction function
from caffe-android-lib.
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.
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.
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.
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.
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)
- Performance become very slow when using multiple threads to do net_->Forward();
- OpenBlas Build failed HOT 1
- Error while running ./build.sh HOT 1
- make: *** No rule to make target 'clean'. Stop. Failed to build OpenBLAS
- How to make pycaffe and build _caffe module HOT 1
- Failed to build OpenBLAS HOT 2
- hi, Failed to build OpenBLAS,libopenblas_atom-r0.2.18.a HOT 1
- Failed to build OpenBLAS: cannot stat 'libopenblas_armv8p-r0.3.0.dev.so': No such file or directory HOT 3
- can not use asset manager HOT 1
- Failed to build OpenBLAS? HOT 29
- Is it suitable for all network?
- Is trainning available on Android?
- Failed to find header file, during [make] process HOT 1
- armeabi-v7a with: command not found HOT 1
- libtool: error: unrecognised option: '-DHAVE_CONFIG_H' HOT 2
- Build error when linking libopenblas.a to libcaffe.so
- find: '/caffe-android-lib/toolchains/armeabi/bin/': No such file or directory
- Porting an exisiting caffe net for text recognition?
- run caffee demo error HOT 3
- Compilation failed at ndk-r19c
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caffe-android-lib.