Skip to content

Commit

Permalink
Merge pull request #2925 from flx42/fix_classification_example
Browse files Browse the repository at this point in the history
Make classification.bin support models with less than 5 classes
  • Loading branch information
jeffdonahue committed Aug 14, 2015
2 parents 65c7fa6 + 98593e3 commit c6b9f58
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/cpp_classification/classification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <algorithm>
#include <iosfwd>
#include <memory>
#include <string>
Expand Down Expand Up @@ -101,6 +102,7 @@ static std::vector<int> Argmax(const std::vector<float>& v, int N) {
std::vector<Prediction> Classifier::Classify(const cv::Mat& img, int N) {
std::vector<float> output = Predict(img);

N = std::min<int>(labels_.size(), N);
std::vector<int> maxN = Argmax(output, N);
std::vector<Prediction> predictions;
for (int i = 0; i < N; ++i) {
Expand Down

0 comments on commit c6b9f58

Please sign in to comment.