Commit 7722465207513f7503b52678f5de58e12fe3fcc8
1 parent
66a1fdbf
Update to docs and better method for getting output of net
Showing
1 changed file
with
9 additions
and
4 deletions
openbr/plugins/classification/caffe.cpp
| 1 | 1 | #include <openbr/plugins/openbr_internal.h> |
| 2 | 2 | #include <openbr/core/opencvutils.h> |
| 3 | -#include <openbr/core/qtutils.h> | |
| 4 | 3 | |
| 5 | -#include <opencv2/imgproc/imgproc.hpp> | |
| 6 | 4 | #include <caffe/caffe.hpp> |
| 7 | 5 | |
| 8 | 6 | using caffe::Caffe; |
| ... | ... | @@ -101,8 +99,9 @@ protected: |
| 101 | 99 | |
| 102 | 100 | dataLayer->AddMatVector(src.toVector().toStdVector(), std::vector<int>(src.size(), 0)); |
| 103 | 101 | |
| 104 | - Blob<float> *output = net->ForwardPrefilled()[1]; // index 0 is the labels from the data layer (in this case the 0 array we passed in above). | |
| 105 | - // index 1 is the ouput of the final layer, which is what we want | |
| 102 | + net->ForwardPrefilled(); | |
| 103 | + Blob<float> *output = net->blobs().back().get(); | |
| 104 | + | |
| 106 | 105 | int dimFeatures = output->count() / dataLayer->batch_size(); |
| 107 | 106 | for (int n = 0; n < dataLayer->batch_size(); n++) |
| 108 | 107 | dst += Mat(1, dimFeatures, CV_32FC1, output->mutable_cpu_data() + output->offset(n)); |
| ... | ... | @@ -115,6 +114,9 @@ protected: |
| 115 | 114 | * \brief This transform treats the output of the network as a feature vector and appends it unchanged to dst. Dst will have |
| 116 | 115 | * length equal to the batch size of the network. |
| 117 | 116 | * \author Jordan Cheney \cite JordanCheney |
| 117 | + * \br_property QString model path to prototxt model file | |
| 118 | + * \br_property QString weights path to caffemodel file | |
| 119 | + * \br_property int gpuDevice ID of GPU to use. gpuDevice < 0 runs on the CPU only. | |
| 118 | 120 | */ |
| 119 | 121 | class CaffeFVTransform : public CaffeBaseTransform |
| 120 | 122 | { |
| ... | ... | @@ -139,6 +141,9 @@ BR_REGISTER(Transform, CaffeFVTransform) |
| 139 | 141 | * using the keys "Labels" and "Confidences" respectively. The length of these lists is equivalent to the provided batch size. |
| 140 | 142 | * If batch size == 1, the results are stored as a float and int using the keys "Label", and "Confidence" respectively. |
| 141 | 143 | * \author Jordan Cheney \cite jcheney |
| 144 | + * \br_property QString model path to prototxt model file | |
| 145 | + * \br_property QString weights path to caffemodel file | |
| 146 | + * \br_property int gpuDevice ID of GPU to use. gpuDevice < 0 runs on the CPU only. | |
| 142 | 147 | */ |
| 143 | 148 | class CaffeClassifierTransform : public CaffeBaseTransform |
| 144 | 149 | { | ... | ... |