/* Return the top N predictions. */
std::vector<Prediction> Deep_Classifier::Classify(const cv::Mat& img, int N) {
    std::vector<float> output = Predict(img);

    std::vector<int> maxN = Argmax(output, N);
    std::vector<Prediction> predictions;
    for (int i = 0; i < N; ++i) {
        int idx = maxN[i];
        predictions.push_back(std::make_pair(labels_[idx], output[idx]));
    }

    return predictions;
}
Esempio n. 2
0
/* Return the top N predictions. */
std::vector<Prediction> Classifier::Classify(const cv::Mat& img, int N) {
	std::vector<float> output = Predict(img);

	std::vector<int> maxN = Argmax(output, std::min((float)N, (float)output.size()));
	std::vector<Prediction> predictions;
	for (int i = 0; i < std::min((float)N, (float)output.size()); ++i) {
		int idx = maxN[i];
		//predictions.push_back(std::make_pair(labels_[idx], output[idx]));
		predictions.push_back(std::make_pair(idx, output[idx]));
	}

	return predictions;
}
Esempio n. 3
0
std::vector<Prediction> Classifier::classify( const cv::Mat &_img,
					      int N ) {

  std::vector<float> output = this->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 ) {
    int idx = maxN[i];
    predictions.push_back( std::make_pair( labels_[idx],
					   output[idx] ) );
  }
  
  return predictions;

}